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

◆ FQueue() [1/2]

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

Definition at line 9 of file FQueue.h.

9  {
10  theSize = 0;
11  theFront = 0;
12  theTail = 0;
13  theCapacity = 0;
14  }

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

◆ FQueue() [2/2]

template<class T>
FQueue< T >::FQueue ( unsigned int  initialCapacity)
inline

Definition at line 16 of file FQueue.h.

16  {
17  theBuffer.resize(initialCapacity);
18  theSize = 0;
19  theFront = 0;
20  theTail = 0;
21  theCapacity = initialCapacity;
22  }

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

Member Function Documentation

◆ clear()

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

Definition at line 69 of file FQueue.h.

69  {
70  theBuffer.clear();
71  theSize = 0;
72  theFront = 0;
73  theTail = 0;
74  }

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

Referenced by BeautifulSoup.Tag::setString().

◆ empty()

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

Definition at line 26 of file FQueue.h.

26 { return theSize == 0; }

References FQueue< T >::theSize.

◆ front()

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

Definition at line 28 of file FQueue.h.

28 { return theBuffer[theFront]; }

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

◆ operator[]()

template<class T>
T& FQueue< T >::operator[] ( unsigned int  index)
inline

Definition at line 67 of file FQueue.h.

67 { return theBuffer[wrapIndex(theFront + index)]; }

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

◆ pop_front() [1/2]

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

Definition at line 52 of file FQueue.h.

52  {
53  if (theSize > 0) {
55  theSize--;
56  }
57  }

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

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

◆ pop_front() [2/2]

template<class T>
void FQueue< T >::pop_front ( const unsigned int  numberOfElementsToPop)
inline

Definition at line 59 of file FQueue.h.

59  {
60  unsigned int elementsToErase = theSize > numberOfElementsToPop ? numberOfElementsToPop : theSize;
61  theSize -= elementsToErase;
62  theFront = wrapIndex(theFront + elementsToErase);
63  }

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

◆ push_back()

template<class T>
void FQueue< T >::push_back ( const T value)
inline

Definition at line 34 of file FQueue.h.

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  }

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().

◆ reserve()

template<class T>
void FQueue< T >::reserve ( unsigned int  capacity)
inline

Definition at line 65 of file FQueue.h.

65 { theBuffer.reserve(capacity); }

References FQueue< T >::theBuffer.

◆ size()

template<class T>
unsigned int FQueue< T >::size ( void  ) const
inline

◆ tail()

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

Definition at line 30 of file FQueue.h.

30 { return theBuffer[theTail]; }

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

◆ wrapIndex()

template<class T>
constexpr unsigned int FQueue< T >::wrapIndex ( unsigned int  i)
inlineconstexpr

Definition at line 32 of file FQueue.h.

32 { return i & (theBuffer.size() - 1); }

References mps_fire::i, and FQueue< T >::theBuffer.

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

Member Data Documentation

◆ theBuffer

template<class T>
std::vector<T> FQueue< T >::theBuffer
private

◆ theCapacity

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().

◆ theFront

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

◆ theSize

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

◆ theTail

template<class T>
unsigned int FQueue< T >::theTail
private
FQueue::wrapIndex
constexpr unsigned int wrapIndex(unsigned int i)
Definition: FQueue.h:32
mps_fire.i
i
Definition: mps_fire.py:355
filterCSVwithJSON.copy
copy
Definition: filterCSVwithJSON.py:36
FQueue::theBuffer
std::vector< T > theBuffer
Definition: FQueue.h:80
FQueue::theSize
unsigned int theSize
Definition: FQueue.h:77
FQueue::theFront
unsigned int theFront
Definition: FQueue.h:78
FQueue::theCapacity
unsigned int theCapacity
Definition: FQueue.h:81
relativeConstraints.value
value
Definition: relativeConstraints.py:53
FQueue::theTail
unsigned int theTail
Definition: FQueue.h:79
AlignmentPI::index
index
Definition: AlignmentPayloadInspectorHelper.h:46