A generic queue template class for moveable objects eg. structs or fundamental data types like UInt32, Real, etc. More...
#include "murl_queue.h"
Classes | |
class | ConstIterator |
Definition of the const iterator. More... | |
class | Iterator |
Definition of the iterator. More... | |
Public Types | |
using | ValueType = DataType |
The template parameter value type. | |
Public Member Functions | |
Queue () | |
Construct an empty queue. | |
Queue (const Queue &other) | |
Construct a queue from an already existing one, performing a deep copy. More... | |
~Queue () | |
Destroy the queue and all of its contents. | |
void | operator= (const Queue &other) |
Assign the content of another queue to this one, performing a deep copy. More... | |
SInt32 | GetCount () const |
Get the number of items in the queue. More... | |
Bool | IsEmpty () const |
Check if the queue is empty. More... | |
void | Clear () |
Clear the queue and remove the underlying storage. | |
void | Empty () |
Empty the queue, but keep the underlying storage. | |
DataType & | AddHead () |
Add a new item at the head of the queue. More... | |
DataType & | AddTail () |
Add a new item at the tail of the queue. More... | |
DataType & | AddHead (const DataType &item) |
Add a given item at the head of the queue. More... | |
DataType & | AddTail (const DataType &item) |
Add a given item at the tail of the queue. More... | |
DataType & | Head () |
Get the item at the head of the queue. More... | |
DataType & | Tail () |
Get the item at the tail of the queue. More... | |
const DataType & | Head () const |
Get the item at the head of the queue. More... | |
const DataType & | Tail () const |
Get the item at the tail of the queue. More... | |
DataType | DropGetHead () |
Drop the item from the head of the queue and get a copy of the item. More... | |
DataType | DropGetTail () |
Drop the item from the tail of the queue and get a copy of the item. More... | |
void | DropHead () |
Drop the item from the head of the queue. | |
void | DropTail () |
Drop the item from the tail of the queue. | |
void | DropHead (SInt32 n) |
Drop a specified number of items from the head of the queue. More... | |
void | DropTail (SInt32 n) |
Drop a specified number of items from the tail of the queue. More... | |
const DataType & | operator[] (SInt32 index) const |
Retrieve the item at a given position from the queue. More... | |
DataType & | operator[] (SInt32 index) |
Retrieve the item at a given position from the queue. More... | |
DataType & | Get (SInt32 index) |
Get the item at a given position from the queue. More... | |
const DataType & | Get (SInt32 index) const |
Get the item at a given position from the queue. More... | |
void | Shrink () |
Shrink the queue so that the underlying storage is only as large as necessary. | |
void | Reserve (SInt32 n) |
Reserve storage space. More... | |
SInt32 | GetAlloc () const |
Get the number of actually allocated items. More... | |
Bool | IsEqual (const Queue &other) const |
Compare the queue to another one. More... | |
bool | operator== (const Queue &rhs) const |
The "equal to" comparison operator, calls IsEqual(). More... | |
bool | operator!= (const Queue &rhs) const |
The "not equal to" comparison operator, calls IsEqual(). More... | |
void | Swap (Queue &other) |
Exchange the content of the queue with a given second one. More... | |
ConstIterator | Begin () const |
Get the const iterator to the first item. More... | |
ConstIterator | End () const |
Get the const iterator next to the last item. More... | |
ConstIterator | GetIter (SInt32 index) const |
Get the const iterator of a specified index. More... | |
Iterator | Begin () |
Get the iterator to the first item. More... | |
Iterator | End () |
Get the iterator next to the last item. More... | |
Iterator | GetIter (SInt32 index) |
Get the iterator of a specified index. More... | |
Detailed Description
template<class DataType>
class Murl::Queue< DataType >
A generic queue template class for moveable objects eg. structs or fundamental data types like UInt32, Real, etc.
The Queue class works for moveable objects only, use ObjectQueue class for storing non-moveable objects.
This class is based on the NTL BiVector container, see http://www.ultimatepp.org
- Template Parameters
-
DataType The value's data type of the queue.
Constructor & Destructor Documentation
◆ Queue()
|
inline |
Construct a queue from an already existing one, performing a deep copy.
- Parameters
-
other The queue to copy.
Member Function Documentation
◆ operator=()
|
inline |
Assign the content of another queue to this one, performing a deep copy.
- Parameters
-
other The source queue.
◆ GetCount()
|
inline |
Get the number of items in the queue.
- Returns
- The number of items.
Referenced by Murl::Queue< DataType >::End(), and Murl::ObjectQueue< DataType >::GetCount().
◆ IsEmpty()
|
inline |
Check if the queue is empty.
- Returns
- true if the queue is empty, false otherwise.
◆ AddHead() [1/2]
|
inline |
Add a new item at the head of the queue.
The new item entry is initialized using the value type's default constructor. The new item will be at position 0.
- Returns
- A reference to the newly created item.
References Murl::Util::DeepCopy::PlacementNew().
Referenced by Murl::ObjectQueue< DataType >::AddHead().
◆ AddTail() [1/2]
|
inline |
Add a new item at the tail of the queue.
The new item entry is initialized using the value type's default constructor. The new item will be at position GetCount() - 1.
- Returns
- A reference to the newly created item.
References Murl::Util::DeepCopy::PlacementNew().
Referenced by Murl::ObjectQueue< DataType >::AddTail().
◆ AddHead() [2/2]
|
inline |
Add a given item at the head of the queue.
The new item entry is initialized using the given item's copy constructor. The new item will be at position 0.
- Parameters
-
item The given item to be inserted at the head of the queue.
- Returns
- A reference to the newly created item.
References Murl::Util::DeepCopy::PlacementNew().
◆ AddTail() [2/2]
|
inline |
Add a given item at the tail of the queue.
The new item entry is initialized using the given item's copy constructor. The new item will be at position GetCount() - 1.
- Parameters
-
item The given item to be inserted at the tail of the queue.
- Returns
- A reference to the newly created item.
References Murl::Util::DeepCopy::PlacementNew().
◆ Head() [1/2]
|
inline |
Get the item at the head of the queue.
- Returns
- A reference to the item at the head of the queue.
Referenced by Murl::Queue< DataType >::DropGetHead(), Murl::Queue< DataType >::DropHead(), and Murl::ObjectQueue< DataType >::Head().
◆ Tail() [1/2]
|
inline |
Get the item at the tail of the queue.
- Returns
- A reference to the item at the tail of the queue.
Referenced by Murl::Queue< DataType >::DropGetTail(), Murl::Queue< DataType >::DropTail(), and Murl::ObjectQueue< DataType >::Tail().
◆ Head() [2/2]
|
inline |
Get the item at the head of the queue.
- Returns
- A const reference to the item at the head of the queue.
◆ Tail() [2/2]
|
inline |
Get the item at the tail of the queue.
- Returns
- A const reference to the item at the tail of the queue.
◆ DropGetHead()
|
inline |
Drop the item from the head of the queue and get a copy of the item.
- Returns
- A copy of the removed item.
References Murl::Queue< DataType >::DropHead(), and Murl::Queue< DataType >::Head().
Referenced by Murl::ObjectQueue< DataType >::DetachHead(), Murl::ObjectQueue< DataType >::DropGetHead(), and Murl::ObjectQueue< DataType >::DropHead().
◆ DropGetTail()
|
inline |
Drop the item from the tail of the queue and get a copy of the item.
- Returns
- A copy of the removed item.
References Murl::Queue< DataType >::DropTail(), and Murl::Queue< DataType >::Tail().
Referenced by Murl::ObjectQueue< DataType >::DetachTail(), Murl::ObjectQueue< DataType >::DropGetTail(), and Murl::ObjectQueue< DataType >::DropTail().
◆ DropHead()
|
inline |
Drop a specified number of items from the head of the queue.
- Parameters
-
n The number of items to remove from the head.
References Murl::Queue< DataType >::DropHead().
◆ DropTail()
|
inline |
Drop a specified number of items from the tail of the queue.
- Parameters
-
n The number of items to remove from the tail.
References Murl::Queue< DataType >::DropTail().
◆ operator[]() [1/2]
|
inline |
Retrieve the item at a given position from the queue.
- Parameters
-
index The zero-based index of the item to retrieve.
- Returns
- A const reference to the specified item.
◆ operator[]() [2/2]
|
inline |
Retrieve the item at a given position from the queue.
- Parameters
-
index The zero-based index of the item to retrieve.
- Returns
- A reference to the specified item.
◆ Get() [1/2]
|
inline |
Get the item at a given position from the queue.
- Parameters
-
index The zero-based index of the item to retrieve.
- Returns
- A reference to the specified item.
◆ Get() [2/2]
|
inline |
Get the item at a given position from the queue.
- Parameters
-
index The zero-based index of the item to retrieve.
- Returns
- A const reference to the specified item.
◆ Reserve()
|
inline |
Reserve storage space.
If the given size is less than the actual size, nothing is done.
- Parameters
-
n The number of items the underlying storage should hold.
Referenced by Murl::ObjectQueue< DataType >::Reserve().
◆ GetAlloc()
|
inline |
Get the number of actually allocated items.
- Returns
- The number of allocated items.
Referenced by Murl::ObjectQueue< DataType >::GetAlloc().
◆ IsEqual()
|
inline |
Compare the queue to another one.
- Parameters
-
other The queue to compare.
- Returns
- true if both queue have identical contents.
Referenced by Murl::Queue< DataType >::operator!=(), and Murl::Queue< DataType >::operator==().
◆ operator==()
|
inline |
The "equal to" comparison operator, calls IsEqual().
- Parameters
-
rhs The right hand side queue to compare.
- Returns
- true if both queues have identical contents.
References Murl::Queue< DataType >::IsEqual().
◆ operator!=()
|
inline |
The "not equal to" comparison operator, calls IsEqual().
- Parameters
-
rhs The right hand side queue to compare.
- Returns
- true if the queues differ.
References Murl::Queue< DataType >::IsEqual().
◆ Swap()
|
inline |
Exchange the content of the queue with a given second one.
- Parameters
-
other The second queue.
References Murl::Util::Swap().
Referenced by Murl::ObjectQueue< DataType >::Swap().
◆ Begin() [1/2]
|
inline |
Get the const iterator to the first item.
- Returns
- The const iterator to the first item.
◆ End() [1/2]
|
inline |
Get the const iterator next to the last item.
- Returns
- The const iterator next to the last item.
References Murl::Queue< DataType >::GetCount().
◆ GetIter() [1/2]
|
inline |
Get the const iterator of a specified index.
- Parameters
-
index The index for the iterator.
- Returns
- The const iterator or null if the index is out of range.
◆ Begin() [2/2]
|
inline |
Get the iterator to the first item.
- Returns
- The iterator to the first item.
◆ End() [2/2]
|
inline |
Get the iterator next to the last item.
- Returns
- The iterator next to the last item.
References Murl::Queue< DataType >::GetCount().
◆ GetIter() [2/2]
|
inline |
Get the iterator of a specified index.
- Parameters
-
index The index for the iterator.
- Returns
- The iterator or null if the index is out of range.
The documentation for this class was generated from the following file:
- murl_queue.h