Murl::Queue< DataType > Class Template Reference

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

Constructor & Destructor Documentation

◆ Queue()

template<class DataType >
Murl::Queue< DataType >::Queue ( const Queue< 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::Queue< DataType >::operator= ( const Queue< 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::Queue< DataType >::GetCount ( ) const
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()

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

Check if the queue is empty.

Returns
true if the queue is empty, false otherwise.

◆ AddHead() [1/2]

template<class DataType >
DataType& Murl::Queue< 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::Util::DeepCopy::PlacementNew().

Referenced by Murl::ObjectQueue< DataType >::AddHead().

◆ AddTail() [1/2]

template<class DataType >
DataType& Murl::Queue< 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::Util::DeepCopy::PlacementNew().

Referenced by Murl::ObjectQueue< DataType >::AddTail().

◆ AddHead() [2/2]

template<class DataType >
DataType& Murl::Queue< 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::Util::DeepCopy::PlacementNew().

◆ AddTail() [2/2]

template<class DataType >
DataType& Murl::Queue< 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::Util::DeepCopy::PlacementNew().

◆ Head() [1/2]

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

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

template<class DataType >
const DataType& Murl::Queue< 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.

◆ Tail() [2/2]

template<class DataType >
const DataType& Murl::Queue< 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.

◆ DropGetHead()

template<class DataType >
DataType Murl::Queue< 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 >::DropHead(), and Murl::Queue< DataType >::Head().

Referenced by Murl::ObjectQueue< DataType >::DetachHead(), Murl::ObjectQueue< DataType >::DropGetHead(), and Murl::ObjectQueue< DataType >::DropHead().

◆ DropGetTail()

template<class DataType >
DataType Murl::Queue< 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 >::DropTail(), and Murl::Queue< DataType >::Tail().

Referenced by Murl::ObjectQueue< DataType >::DetachTail(), Murl::ObjectQueue< DataType >::DropGetTail(), and Murl::ObjectQueue< DataType >::DropTail().

◆ DropHead()

template<class DataType >
void Murl::Queue< 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 >::DropHead().

◆ DropTail()

template<class DataType >
void Murl::Queue< 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 >::DropTail().

◆ operator[]() [1/2]

template<class DataType >
const DataType& Murl::Queue< 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::Queue< 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::Queue< 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::Queue< 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::Queue< 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.

Referenced by Murl::ObjectQueue< DataType >::Reserve().

◆ GetAlloc()

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

Get the number of actually allocated items.

Returns
The number of allocated items.

Referenced by Murl::ObjectQueue< DataType >::GetAlloc().

◆ IsEqual()

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

Compare the queue to another one.

Parameters
otherThe queue to compare.
Returns
true if both queue have identical contents.

Referenced by Murl::Queue< DataType >::operator!=(), and Murl::Queue< DataType >::operator==().

◆ operator==()

template<class DataType >
bool Murl::Queue< DataType >::operator== ( const Queue< 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::Queue< DataType >::IsEqual().

◆ operator!=()

template<class DataType >
bool Murl::Queue< DataType >::operator!= ( const Queue< 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::Queue< DataType >::IsEqual().

◆ Swap()

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

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

Parameters
otherThe second queue.

References Murl::Util::Swap().

Referenced by Murl::ObjectQueue< DataType >::Swap().

◆ Begin() [1/2]

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

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

template<class DataType >
Iterator Murl::Queue< 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_queue.h


Copyright © 2011-2024 Spraylight GmbH.