Murl::ObjectQueue< DataType > Class Template Reference

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
DataTypeThe value's data type of the queue.

Constructor & Destructor Documentation

◆ ObjectQueue()

template<class DataType >
Murl::ObjectQueue< DataType >::ObjectQueue ( const ObjectQueue< DataType > &  other)
inline

Construct a queue from an already existing one, performing a deep copy.

Parameters
otherThe queue to copy.

Member Function Documentation

◆ operator=()

template<class DataType >
void Murl::ObjectQueue< DataType >::operator= ( const ObjectQueue< DataType > &  other)
inline

Assign the content of another queue to this one, performing a deep copy.

Parameters
otherThe source queue.

◆ GetCount()

template<class DataType >
SInt32 Murl::ObjectQueue< DataType >::GetCount ( ) const
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()

template<class DataType >
Bool Murl::ObjectQueue< DataType >::IsEmpty ( ) const
inline

Check if the queue is empty.

Returns
true if the queue is empty, false otherwise.

References Murl::ObjectQueue< DataType >::GetCount().

◆ AddHead() [1/3]

template<class DataType >
DataType& Murl::ObjectQueue< DataType >::AddHead ( )
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]

template<class DataType >
DataType& Murl::ObjectQueue< DataType >::AddTail ( )
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]

template<class DataType >
DataType& Murl::ObjectQueue< DataType >::AddHead ( const DataType &  item)
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
itemThe 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]

template<class DataType >
DataType& Murl::ObjectQueue< DataType >::AddTail ( const DataType &  item)
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
itemThe 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]

template<class DataType >
DataType& Murl::ObjectQueue< DataType >::AddHead ( DataType *  item)
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
itemThe 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]

template<class DataType >
DataType& Murl::ObjectQueue< DataType >::AddTail ( DataType *  item)
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
itemThe 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]

template<class DataType >
DataType& Murl::ObjectQueue< DataType >::Head ( )
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]

template<class DataType >
DataType& Murl::ObjectQueue< DataType >::Tail ( )
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]

template<class DataType >
const DataType& Murl::ObjectQueue< DataType >::Head ( ) const
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]

template<class DataType >
const DataType& Murl::ObjectQueue< DataType >::Tail ( ) const
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()

template<class DataType >
DataType Murl::ObjectQueue< DataType >::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()

template<class DataType >
DataType Murl::ObjectQueue< DataType >::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()

template<class DataType >
void Murl::ObjectQueue< DataType >::DropHead ( SInt32  n)
inline

Drop a specified number of items from the head of the queue.

Parameters
nThe number of items to remove from the head.

References Murl::Queue< DataType >::DropGetHead().

◆ DropTail()

template<class DataType >
void Murl::ObjectQueue< DataType >::DropTail ( SInt32  n)
inline

Drop a specified number of items from the tail of the queue.

Parameters
nThe number of items to remove from the tail.

References Murl::Queue< DataType >::DropGetTail().

◆ DetachHead()

template<class DataType >
DataType* Murl::ObjectQueue< DataType >::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()

template<class DataType >
DataType* Murl::ObjectQueue< DataType >::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]

template<class DataType >
const DataType& Murl::ObjectQueue< DataType >::operator[] ( SInt32  index) const
inline

Retrieve the item at a given position from the queue.

Parameters
indexThe zero-based index of the item to retrieve.
Returns
A const reference to the specified item.

◆ operator[]() [2/2]

template<class DataType >
DataType& Murl::ObjectQueue< DataType >::operator[] ( SInt32  index)
inline

Retrieve the item at a given position from the queue.

Parameters
indexThe zero-based index of the item to retrieve.
Returns
A reference to the specified item.

◆ Get() [1/2]

template<class DataType >
DataType& Murl::ObjectQueue< DataType >::Get ( SInt32  index)
inline

Get the item at a given position from the queue.

Parameters
indexThe zero-based index of the item to retrieve.
Returns
A reference to the specified item.

◆ Get() [2/2]

template<class DataType >
const DataType& Murl::ObjectQueue< DataType >::Get ( SInt32  index) const
inline

Get the item at a given position from the queue.

Parameters
indexThe zero-based index of the item to retrieve.
Returns
A const reference to the specified item.

◆ Reserve()

template<class DataType >
void Murl::ObjectQueue< DataType >::Reserve ( SInt32  n)
inline

Reserve storage space.

If the given size is less than the actual size, nothing is done.

Parameters
nThe number of items the underlying storage should hold.

References Murl::Queue< DataType >::Reserve().

◆ GetAlloc()

template<class DataType >
SInt32 Murl::ObjectQueue< DataType >::GetAlloc ( ) const
inline

Get the number of actually allocated items.

Returns
The number of allocated items.

References Murl::Queue< DataType >::GetAlloc().

◆ IsEqual()

template<class DataType >
Bool Murl::ObjectQueue< DataType >::IsEqual ( const ObjectQueue< DataType > &  other) const
inline

Compare the queue to another one.

Parameters
otherThe 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==()

template<class DataType >
bool Murl::ObjectQueue< DataType >::operator== ( const ObjectQueue< DataType > &  rhs) const
inline

The "equal to" comparison operator, calls IsEqual().

Parameters
rhsThe right hand side queue to compare.
Returns
true if both queues have identical contents.

References Murl::ObjectQueue< DataType >::IsEqual().

◆ operator!=()

template<class DataType >
bool Murl::ObjectQueue< DataType >::operator!= ( const ObjectQueue< DataType > &  rhs) const
inline

The "not equal to" comparison operator, calls IsEqual().

Parameters
rhsThe right hand side queue to compare.
Returns
true if the queues differ.

References Murl::ObjectQueue< DataType >::IsEqual().

◆ Swap()

template<class DataType >
void Murl::ObjectQueue< DataType >::Swap ( ObjectQueue< DataType > &  other)
inline

Exchange the content of the queue with a given second one.

Parameters
otherThe second queue.

References Murl::Queue< DataType >::Swap().

◆ Begin() [1/2]

template<class DataType >
ConstIterator Murl::ObjectQueue< DataType >::Begin ( ) const
inline

Get the const iterator to the first item.

Returns
The const iterator to the first item.

◆ End() [1/2]

template<class DataType >
ConstIterator Murl::ObjectQueue< DataType >::End ( ) const
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]

template<class DataType >
ConstIterator Murl::ObjectQueue< DataType >::GetIter ( SInt32  index) const
inline

Get the const iterator of a specified index.

Parameters
indexThe index for the iterator.
Returns
The const iterator or null if the index is out of range.

◆ Begin() [2/2]

template<class DataType >
Iterator Murl::ObjectQueue< DataType >::Begin ( )
inline

Get the iterator to the first item.

Returns
The iterator to the first item.

◆ End() [2/2]

template<class DataType >
Iterator Murl::ObjectQueue< DataType >::End ( )
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]

template<class DataType >
Iterator Murl::ObjectQueue< DataType >::GetIter ( SInt32  index)
inline

Get the iterator of a specified index.

Parameters
indexThe 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


Copyright © 2011-2024 Spraylight GmbH.