A generic queue template class for non-moveable objects eg. NonCopyable classes. More...
#include "murl_object_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 | |
ObjectQueue () | |
Construct an empty queue. | |
ObjectQueue (const ObjectQueue &other) | |
Construct a queue from an already existing one, performing a deep copy. More... | |
~ObjectQueue () | |
Destroy the queue and all of its contents. | |
void | operator= (const ObjectQueue &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 & | AddHead (DataType *item) |
Add a new allocated item at the head of the queue. More... | |
DataType & | AddTail (DataType *item) |
Add a new allocated 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... | |
DataType * | DetachHead () |
Removes the item from the head and giving up ownership. More... | |
DataType * | DetachTail () |
Removes the item from the tail and giving up ownership. 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 ObjectQueue &other) const |
Compare the queue to another one. More... | |
bool | operator== (const ObjectQueue &rhs) const |
The "equal to" comparison operator, calls IsEqual(). More... | |
bool | operator!= (const ObjectQueue &rhs) const |
The "not equal to" comparison operator, calls IsEqual(). More... | |
void | Swap (ObjectQueue &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::ObjectQueue< DataType >
A generic queue template class for non-moveable objects eg. NonCopyable classes.
The object queue class uses a queue of pointers to the objects, this ensures that the object's memory location is unchanged when modifying the queue.
This class is based on the NTL BiArray container, see http://www.ultimatepp.org
- Template Parameters
-
DataType The value's data type of the queue.
Constructor & Destructor Documentation
◆ ObjectQueue()
|
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.
References Murl::Queue< DataType >::GetCount().
Referenced by Murl::ObjectQueue< DataType >::End(), Murl::ObjectQueue< DataType >::IsEmpty(), and Murl::ObjectQueue< DataType >::IsEqual().
◆ IsEmpty()
|
inline |
Check if the queue is empty.
- Returns
- true if the queue is empty, false otherwise.
References Murl::ObjectQueue< DataType >::GetCount().
◆ AddHead() [1/3]
|
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::Queue< DataType >::AddHead().
◆ AddTail() [1/3]
|
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::Queue< DataType >::AddTail().
◆ AddHead() [2/3]
|
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::Queue< DataType >::AddHead().
◆ AddTail() [2/3]
|
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::Queue< DataType >::AddTail().
◆ AddHead() [3/3]
|
inline |
Add a new allocated item at the head of the queue.
The queue takes the ownership of the item. 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 item.
References Murl::Queue< DataType >::AddHead().
◆ AddTail() [3/3]
|
inline |
Add a new allocated item at the tail of the queue.
The queue takes the ownership of the item. 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 item.
References Murl::Queue< DataType >::AddTail().
◆ 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.
References Murl::Queue< 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.
References Murl::Queue< 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.
References Murl::Queue< DataType >::Head().
◆ 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.
References Murl::Queue< DataType >::Tail().
◆ 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 >::DropGetHead().
◆ 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 >::DropGetTail().
◆ 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 >::DropGetHead().
◆ 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 >::DropGetTail().
◆ DetachHead()
|
inline |
Removes the item from the head and giving up ownership.
(!) The client is responsible for deletion of the returned item.
- Returns
- The pointer to the heap allocated item.
References Murl::Queue< DataType >::DropGetHead().
◆ DetachTail()
|
inline |
Removes the item from the tail and giving up ownership.
(!) The client is responsible for deletion of the returned item.
- Returns
- The pointer to the heap allocated item.
References Murl::Queue< DataType >::DropGetTail().
◆ 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.
References Murl::Queue< DataType >::Reserve().
◆ GetAlloc()
|
inline |
Get the number of actually allocated items.
- Returns
- The number of allocated items.
References Murl::Queue< DataType >::GetAlloc().
◆ IsEqual()
|
inline |
Compare the queue to another one.
- Parameters
-
other The queue to compare.
- Returns
- true if both queue have identical contents.
References Murl::ObjectQueue< DataType >::GetCount().
Referenced by Murl::ObjectQueue< DataType >::operator!=(), and Murl::ObjectQueue< 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::ObjectQueue< 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::ObjectQueue< DataType >::IsEqual().
◆ Swap()
|
inline |
Exchange the content of the queue with a given second one.
- Parameters
-
other The second queue.
References Murl::Queue< 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::ObjectQueue< 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::ObjectQueue< 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_object_queue.h