CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
List of all members | Public Member Functions | Private Attributes
FQueue< T > Class Template Reference

#include <FQueue.h>

Public Member Functions

void clear ()
 
bool empty () const
 
 FQueue ()
 
 FQueue (unsigned int initialCapacity)
 
T front () const
 
Toperator[] (unsigned int index)
 
void pop_front ()
 
void pop_front (const unsigned int numberOfElementsToPop)
 
void push_back (const T &value)
 
void reserve (unsigned int capacity)
 
unsigned int size () const
 
Ttail ()
 
constexpr unsigned int wrapIndex (unsigned int i)
 

Private Attributes

std::vector< TtheBuffer
 
unsigned int theCapacity
 
unsigned int theFront
 
unsigned int theSize
 
unsigned int theTail
 

Detailed Description

template<class T>
class FQueue< T >

Definition at line 7 of file FQueue.h.

Constructor & Destructor Documentation

template<class T>
FQueue< T >::FQueue ( )
inline

Definition at line 9 of file FQueue.h.

References FQueue< T >::theCapacity, FQueue< T >::theFront, FQueue< T >::theSize, and FQueue< T >::theTail.

9  {
10  theSize = 0;
11  theFront = 0;
12  theTail = 0;
13  theCapacity = 0;
14  }
unsigned int theTail
Definition: FQueue.h:79
unsigned int theFront
Definition: FQueue.h:78
unsigned int theCapacity
Definition: FQueue.h:81
unsigned int theSize
Definition: FQueue.h:77
template<class T>
FQueue< T >::FQueue ( unsigned int  initialCapacity)
inline

Definition at line 16 of file FQueue.h.

References FQueue< T >::theBuffer, FQueue< T >::theCapacity, FQueue< T >::theFront, FQueue< T >::theSize, and FQueue< T >::theTail.

16  {
17  theBuffer.resize(initialCapacity);
18  theSize = 0;
19  theFront = 0;
20  theTail = 0;
21  theCapacity = initialCapacity;
22  }
unsigned int theTail
Definition: FQueue.h:79
unsigned int theFront
Definition: FQueue.h:78
std::vector< T > theBuffer
Definition: FQueue.h:80
unsigned int theCapacity
Definition: FQueue.h:81
unsigned int theSize
Definition: FQueue.h:77

Member Function Documentation

template<class T>
void FQueue< T >::clear ( void  )
inline

Definition at line 69 of file FQueue.h.

References FQueue< T >::theBuffer, FQueue< T >::theFront, FQueue< T >::theSize, and FQueue< T >::theTail.

Referenced by BeautifulSoup.Tag::setString().

69  {
70  theBuffer.clear();
71  theSize = 0;
72  theFront = 0;
73  theTail = 0;
74  }
unsigned int theTail
Definition: FQueue.h:79
unsigned int theFront
Definition: FQueue.h:78
std::vector< T > theBuffer
Definition: FQueue.h:80
unsigned int theSize
Definition: FQueue.h:77
template<class T>
bool FQueue< T >::empty ( ) const
inline

Definition at line 26 of file FQueue.h.

References FQueue< T >::theSize.

26 { return theSize == 0; }
unsigned int theSize
Definition: FQueue.h:77
template<class T>
T FQueue< T >::front ( ) const
inline

Definition at line 28 of file FQueue.h.

References FQueue< T >::theBuffer, and FQueue< T >::theFront.

28 { return theBuffer[theFront]; }
unsigned int theFront
Definition: FQueue.h:78
std::vector< T > theBuffer
Definition: FQueue.h:80
template<class T>
T& FQueue< T >::operator[] ( unsigned int  index)
inline

Definition at line 67 of file FQueue.h.

References FQueue< T >::theBuffer, FQueue< T >::theFront, and FQueue< T >::wrapIndex().

67 { return theBuffer[wrapIndex(theFront + index)]; }
constexpr unsigned int wrapIndex(unsigned int i)
Definition: FQueue.h:32
unsigned int theFront
Definition: FQueue.h:78
std::vector< T > theBuffer
Definition: FQueue.h:80
template<class T>
void FQueue< T >::pop_front ( )
inline

Definition at line 52 of file FQueue.h.

References FQueue< T >::theFront, FQueue< T >::theSize, and FQueue< T >::wrapIndex().

Referenced by FKDTree< TYPE, numberOfDimensions >::search().

52  {
53  if (theSize > 0) {
55  theSize--;
56  }
57  }
constexpr unsigned int wrapIndex(unsigned int i)
Definition: FQueue.h:32
unsigned int theFront
Definition: FQueue.h:78
unsigned int theSize
Definition: FQueue.h:77
template<class T>
void FQueue< T >::pop_front ( const unsigned int  numberOfElementsToPop)
inline

Definition at line 59 of file FQueue.h.

References FQueue< T >::theFront, FQueue< T >::theSize, and FQueue< T >::wrapIndex().

59  {
60  unsigned int elementsToErase = theSize > numberOfElementsToPop ? numberOfElementsToPop : theSize;
61  theSize -= elementsToErase;
62  theFront = wrapIndex(theFront + elementsToErase);
63  }
constexpr unsigned int wrapIndex(unsigned int i)
Definition: FQueue.h:32
unsigned int theFront
Definition: FQueue.h:78
unsigned int theSize
Definition: FQueue.h:77
template<class T>
void FQueue< T >::push_back ( const T value)
inline

Definition at line 34 of file FQueue.h.

References filterCSVwithJSON::copy, FQueue< T >::theBuffer, FQueue< T >::theCapacity, FQueue< T >::theFront, FQueue< T >::theSize, FQueue< T >::theTail, relativeConstraints::value, and FQueue< T >::wrapIndex().

Referenced by FKDTree< TYPE, numberOfDimensions >::search().

34  {
35  if (theSize >= theCapacity) {
36  theBuffer.resize(theCapacity * 2);
37  if (theFront != 0) {
38  std::copy(theBuffer.begin(), theBuffer.begin() + theTail, theBuffer.begin() + theCapacity);
39 
40  theTail += theSize;
41 
42  } else {
44  }
45  theCapacity *= 2;
46  }
48  theTail = wrapIndex(theTail + 1);
49  theSize++;
50  }
unsigned int theTail
Definition: FQueue.h:79
constexpr unsigned int wrapIndex(unsigned int i)
Definition: FQueue.h:32
unsigned int theFront
Definition: FQueue.h:78
std::vector< T > theBuffer
Definition: FQueue.h:80
unsigned int theCapacity
Definition: FQueue.h:81
unsigned int theSize
Definition: FQueue.h:77
template<class T>
void FQueue< T >::reserve ( unsigned int  capacity)
inline

Definition at line 65 of file FQueue.h.

References FQueue< T >::theBuffer.

65 { theBuffer.reserve(capacity); }
std::vector< T > theBuffer
Definition: FQueue.h:80
template<class T>
unsigned int FQueue< T >::size ( void  ) const
inline
template<class T>
T& FQueue< T >::tail ( )
inline

Definition at line 30 of file FQueue.h.

References FQueue< T >::theBuffer, and FQueue< T >::theTail.

30 { return theBuffer[theTail]; }
unsigned int theTail
Definition: FQueue.h:79
std::vector< T > theBuffer
Definition: FQueue.h:80
template<class T>
constexpr unsigned int FQueue< T >::wrapIndex ( unsigned int  i)
inline

Definition at line 32 of file FQueue.h.

References FQueue< T >::theBuffer.

Referenced by FQueue< T >::operator[](), FQueue< T >::pop_front(), and FQueue< T >::push_back().

32 { return i & (theBuffer.size() - 1); }
std::vector< T > theBuffer
Definition: FQueue.h:80

Member Data Documentation

template<class T>
std::vector<T> FQueue< T >::theBuffer
private
template<class T>
unsigned int FQueue< T >::theCapacity
private

Definition at line 81 of file FQueue.h.

Referenced by FQueue< T >::FQueue(), and FQueue< T >::push_back().

template<class T>
unsigned int FQueue< T >::theFront
private
template<class T>
unsigned int FQueue< T >::theSize
private
template<class T>
unsigned int FQueue< T >::theTail
private