CoreComponents 3.0.0
A Modern C++ Toolkit
Loading...
Searching...
No Matches
Queue< T > Class Template Reference

Double-ended queue data container. More...

#include <cc/Queue>

Public Types

using Item = T
 Item type.
 

Standard Iterators

using value_type = Item
 Item value type.
 
using size_type = long
 Type of the container capacity.
 
using const_iterator = Iterator<const BucketChain<Item>>
 Readonly value iterator.
 
using const_reverse_iterator = ReverseIterator<const BucketChain<Item>>
 Readonly reverse value iterator.
 
const_iterator begin () const
 Return readonly iterator pointing to the first item (if any)
 
const_iterator cbegin () const
 Return readonly iterator pointing to the first item (if any)
 
const_iterator end () const
 Return readonly iterator pointing behind the last item
 
const_iterator cend () const
 Return readonly iterator pointing behind the last item
 
const_reverse_iterator rbegin () const
 Return readonly reverse iterator pointing to the last item (if any)
 
const_reverse_iterator crbegin () const
 Return readonly reverse iterator pointing to the last item (if any)
 
const_reverse_iterator rend () const
 Return reverse iterator pointing before the first item
 
const_reverse_iterator crend () const
 Return reverse iterator pointing before the first item
 

Construction and Assignment

 Queue ()=default
 Construct an empty queue.
 
 Queue (const Queue &other)=default
 Construct a copy of other.
 
 Queue (std::initializer_list< Item > items)
 Construct with initial items.
 
 Queue (Queue &&other)
 Take over the right-side other.
 
Queueoperator= (const Queue &other)=default
 Assign queue other.
 
Queueoperator= (Queue &&other)
 Assign right-side queue other.
 

Item Access

Locator head () const
 Get a locator pointing to the first item.
 
Locator tail () const
 Get a locator pointing to the last item.
 
long count () const
 Get the number of items stored in the queue.
 
long size () const
 Get the number of items stored in the queue.
 
long operator+ () const
 Get the number of items stored in the queue.
 
const Itemat (Locator pos) const
 Get the constant reference to item at position pos.
 
const Itemfirst () const
 Get constant reference to first item.
 
const Itemlast () const
 Get constant reference to last item.
 
bool first (const Item &item) const
 Tell if item is the first item.
 
bool last (const Item &item) const
 Tell if item is the last item.
 

Front and Back Operations

template<class... Args>
void emplaceBack (Args... args)
 Insert a new last item.
 
template<class... Args>
void emplaceFront (Args... args)
 Insert a new first item.
 
void pushBack (const Item &item)
 Append item to the queue.
 
void pushFront (const Item &item)
 Prepend item to the queue.
 
void popBack (Out< Item > item=None{})
 Remove and return the last item in the queue.
 
void popFront (Out< Item > item=None{})
 Remove and return the first item in the queue.
 
void operator<< (const Item &item)
 Append item to the end of the queue.
 
void operator>> (Item &item)
 Remove and return item from the front of the queue.
 

Global Operations

template<class F >
void forEach (F f) const
 Call function f for each item.
 
template<class Item >
Array< ItemtoArray () const
 Convert to an array or list.
 
void deplete ()
 Remove all items.
 

Comparism Operators

template<class Other >
bool operator== (const Other &other) const
 Equality operator.
 
template<class Other >
std::strong_ordering operator<=> (const Other &other) const
 Ordering operator.
 

Detailed Description

template<class T>
class cc::Queue< T >

Double-ended queue data container.

Template Parameters
TItem type

Member Typedef Documentation

◆ Item

template<class T >
using Item = T

Item type.

◆ value_type

template<class T >
using value_type = Item

Item value type.

◆ size_type

template<class T >
using size_type = long

Type of the container capacity.

◆ const_iterator

template<class T >
using const_iterator = Iterator<const BucketChain<Item>>

Readonly value iterator.

◆ const_reverse_iterator

template<class T >
using const_reverse_iterator = ReverseIterator<const BucketChain<Item>>

Readonly reverse value iterator.

Constructor & Destructor Documentation

◆ Queue() [1/4]

template<class T >
Queue ( )
default

Construct an empty queue.

◆ Queue() [2/4]

template<class T >
Queue ( const Queue< T > & other)
default

Construct a copy of other.

◆ Queue() [3/4]

template<class T >
Queue ( std::initializer_list< Item > items)

Construct with initial items.

◆ Queue() [4/4]

template<class T >
Queue ( Queue< T > && other)

Take over the right-side other.

Member Function Documentation

◆ operator=() [1/2]

template<class T >
Queue & operator= ( const Queue< T > & other)
default

Assign queue other.

◆ operator=() [2/2]

template<class T >
Queue & operator= ( Queue< T > && other)

Assign right-side queue other.

◆ head()

template<class T >
Locator head ( ) const

Get a locator pointing to the first item.

◆ tail()

template<class T >
Locator tail ( ) const

Get a locator pointing to the last item.

◆ count()

template<class T >
long count ( ) const

Get the number of items stored in the queue.

◆ size()

template<class T >
long size ( ) const

Get the number of items stored in the queue.

◆ operator+()

template<class T >
long operator+ ( ) const

Get the number of items stored in the queue.

◆ at()

template<class T >
const Item & at ( Locator pos) const

Get the constant reference to item at position pos.

◆ first() [1/2]

template<class T >
const Item & first ( ) const

Get constant reference to first item.

◆ last() [1/2]

template<class T >
const Item & last ( ) const

Get constant reference to last item.

◆ first() [2/2]

template<class T >
bool first ( const Item & item) const

Tell if item is the first item.

◆ last() [2/2]

template<class T >
bool last ( const Item & item) const

Tell if item is the last item.

◆ emplaceBack()

template<class T >
template<class... Args>
void emplaceBack ( Args... args)

Insert a new last item.

Parameters
argsconstruction arguments

◆ emplaceFront()

template<class T >
template<class... Args>
void emplaceFront ( Args... args)

Insert a new first item.

Parameters
argsconstruction arguments

◆ pushBack()

template<class T >
void pushBack ( const Item & item)

Append item to the queue.

◆ pushFront()

template<class T >
void pushFront ( const Item & item)

Prepend item to the queue.

◆ popBack()

template<class T >
void popBack ( Out< Item > item = None{})

Remove and return the last item in the queue.

◆ popFront()

template<class T >
void popFront ( Out< Item > item = None{})

Remove and return the first item in the queue.

◆ operator<<()

template<class T >
void operator<< ( const Item & item)

Append item to the end of the queue.

◆ operator>>()

template<class T >
void operator>> ( Item & item)

Remove and return item from the front of the queue.

◆ forEach()

template<class T >
template<class F >
void forEach ( F f) const

Call function f for each item.

Template Parameters
FFunction type (lambda or functor)
Parameters
fUnary function which gets called for each item

◆ toArray()

template<class T >
template<class Item >
Array< Item > toArray ( ) const

Convert to an array or list.

Template Parameters
ItemTarget item type

◆ deplete()

template<class T >
void deplete ( )

Remove all items.

◆ begin()

template<class T >
const_iterator begin ( ) const

Return readonly iterator pointing to the first item (if any)

◆ cbegin()

template<class T >
const_iterator cbegin ( ) const

Return readonly iterator pointing to the first item (if any)

◆ end()

template<class T >
const_iterator end ( ) const

Return readonly iterator pointing behind the last item

◆ cend()

template<class T >
const_iterator cend ( ) const

Return readonly iterator pointing behind the last item

◆ rbegin()

template<class T >
const_reverse_iterator rbegin ( ) const

Return readonly reverse iterator pointing to the last item (if any)

◆ crbegin()

template<class T >
const_reverse_iterator crbegin ( ) const

Return readonly reverse iterator pointing to the last item (if any)

◆ rend()

template<class T >
const_reverse_iterator rend ( ) const

Return reverse iterator pointing before the first item

◆ crend()

template<class T >
const_reverse_iterator crend ( ) const

Return reverse iterator pointing before the first item

◆ operator==()

template<class T >
template<class Other >
bool operator== ( const Other & other) const

Equality operator.

◆ operator<=>()

template<class T >
template<class Other >
std::strong_ordering operator<=> ( const Other & other) const

Ordering operator.