CMS 3D CMS Logo

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 10 of file FQueue.h.

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

11  {
12  theSize = 0;
13  theFront = 0;
14  theTail = 0;
15  theCapacity = 0;
16  }
unsigned int theTail
Definition: FQueue.h:115
unsigned int theFront
Definition: FQueue.h:114
unsigned int theCapacity
Definition: FQueue.h:117
unsigned int theSize
Definition: FQueue.h:113
template<class T>
FQueue< T >::FQueue ( unsigned int  initialCapacity)
inline

Definition at line 18 of file FQueue.h.

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

19  {
20  theBuffer.resize(initialCapacity);
21  theSize = 0;
22  theFront = 0;
23  theTail = 0;
24  theCapacity = initialCapacity;
25  }
unsigned int theTail
Definition: FQueue.h:115
unsigned int theFront
Definition: FQueue.h:114
std::vector< T > theBuffer
Definition: FQueue.h:116
unsigned int theCapacity
Definition: FQueue.h:117
unsigned int theSize
Definition: FQueue.h:113

Member Function Documentation

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

Definition at line 32 of file FQueue.h.

References FQueue< T >::theSize.

Referenced by Vispa.Gui.VispaWidget.TextField::setAutosizeFont(), and Vispa.Gui.VispaWidget.TextField::setAutotruncate().

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

Definition at line 37 of file FQueue.h.

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

38  {
39  return theBuffer[theFront];
40  }
unsigned int theFront
Definition: FQueue.h:114
std::vector< T > theBuffer
Definition: FQueue.h:116
template<class T>
T& FQueue< T >::operator[] ( unsigned int  index)
inline

Definition at line 99 of file FQueue.h.

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

100  {
101  return theBuffer[wrapIndex(theFront + index)];
102  }
constexpr unsigned int wrapIndex(unsigned int i)
Definition: FQueue.h:47
unsigned int theFront
Definition: FQueue.h:114
std::vector< T > theBuffer
Definition: FQueue.h:116
template<class T>
void FQueue< T >::pop_front ( )
inline

Definition at line 77 of file FQueue.h.

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

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

78  {
79  if (theSize > 0)
80  {
82  theSize--;
83  }
84  }
constexpr unsigned int wrapIndex(unsigned int i)
Definition: FQueue.h:47
unsigned int theFront
Definition: FQueue.h:114
unsigned int theSize
Definition: FQueue.h:113
template<class T>
void FQueue< T >::pop_front ( const unsigned int  numberOfElementsToPop)
inline

Definition at line 86 of file FQueue.h.

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

87  {
88  unsigned int elementsToErase =
89  theSize > numberOfElementsToPop ? numberOfElementsToPop : theSize;
90  theSize -= elementsToErase;
91  theFront = wrapIndex(theFront + elementsToErase);
92  }
constexpr unsigned int wrapIndex(unsigned int i)
Definition: FQueue.h:47
unsigned int theFront
Definition: FQueue.h:114
unsigned int theSize
Definition: FQueue.h:113
template<class T>
void FQueue< T >::push_back ( const T value)
inline

Definition at line 52 of file FQueue.h.

References popcon2dropbox::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().

53  {
54  if (theSize >= theCapacity)
55  {
56  theBuffer.resize(theCapacity * 2);
57  if (theFront != 0)
58  {
59  std::copy(theBuffer.begin(), theBuffer.begin() + theTail,
60  theBuffer.begin() + theCapacity);
61 
62  theTail += theSize;
63 
64  }
65  else
66  {
68  }
69  theCapacity *= 2;
70  }
72  theTail = wrapIndex(theTail + 1);
73  theSize++;
74 
75  }
unsigned int theTail
Definition: FQueue.h:115
def copy(args, dbName)
constexpr unsigned int wrapIndex(unsigned int i)
Definition: FQueue.h:47
unsigned int theFront
Definition: FQueue.h:114
std::vector< T > theBuffer
Definition: FQueue.h:116
unsigned int theCapacity
Definition: FQueue.h:117
unsigned int theSize
Definition: FQueue.h:113
template<class T>
void FQueue< T >::reserve ( unsigned int  capacity)
inline

Definition at line 94 of file FQueue.h.

References FQueue< T >::theBuffer.

95  {
96  theBuffer.reserve(capacity);
97  }
std::vector< T > theBuffer
Definition: FQueue.h:116
template<class T>
unsigned int FQueue< T >::size ( void  ) const
inline

Definition at line 27 of file FQueue.h.

References FQueue< T >::theSize.

Referenced by ntupleDataFormat._Collection::__iter__(), ntupleDataFormat._Collection::__len__(), and FKDTree< TYPE, numberOfDimensions >::search().

28  {
29  return theSize;
30  }
unsigned int theSize
Definition: FQueue.h:113
template<class T>
T& FQueue< T >::tail ( )
inline

Definition at line 42 of file FQueue.h.

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

43  {
44  return theBuffer[theTail];
45  }
unsigned int theTail
Definition: FQueue.h:115
std::vector< T > theBuffer
Definition: FQueue.h:116
template<class T>
constexpr unsigned int FQueue< T >::wrapIndex ( unsigned int  i)
inline

Definition at line 47 of file FQueue.h.

References FQueue< T >::theBuffer.

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

48  {
49  return i & (theBuffer.size() - 1);
50  }
std::vector< T > theBuffer
Definition: FQueue.h:116

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 117 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