BDE 4.39.x Production Release
Loading...
Searching...
No Matches
bsl::queue< VALUE, CONTAINER > Class Template Reference

#include <bslstl_queue.h>

Detailed Description

template<class VALUE, class CONTAINER = deque<VALUE>>
class bsl::queue< VALUE, CONTAINER >

This class is a value-semantic class template, having a container of the parameterized CONTAINER type that holds elements of the parameterized VALUE type, to provide a first-in-first-out queue data structure. The container object held by a queue class object is referenced as c in the following function-level documentation.

See bslstl_queue

Public Types

typedef CONTAINER::value_type value_type
 
typedef CONTAINER::reference reference
 
typedef CONTAINER::const_reference const_reference
 
typedef CONTAINER::size_type size_type
 
typedef CONTAINER container_type
 

Public Member Functions

 BSLMF_NESTED_TRAIT_DECLARATION_IF (queue, BloombergLP::bslma::UsesBslmaAllocator, BloombergLP::bslma::UsesBslmaAllocator< container_type >::value)
 
 queue ()
 
 queue (const queue &original)
 
 queue (BloombergLP::bslmf::MovableRef< queue > container)
 
 queue (const CONTAINER &container)
 
 queue (BloombergLP::bslmf::MovableRef< CONTAINER > container)
 
template<class ALLOCATOR >
 queue (const ALLOCATOR &basicAllocator, typename enable_if< bsl::uses_allocator< CONTAINER, ALLOCATOR >::value, ALLOCATOR >::type *=0)
 
template<class ALLOCATOR >
 queue (const CONTAINER &container, const ALLOCATOR &basicAllocator, typename enable_if< bsl::uses_allocator< CONTAINER, ALLOCATOR >::value, ALLOCATOR >::type *=0)
 
template<class ALLOCATOR >
 queue (const queue &original, const ALLOCATOR &basicAllocator, typename enable_if< bsl::uses_allocator< CONTAINER, ALLOCATOR >::value, ALLOCATOR >::type *=0)
 
template<class ALLOCATOR >
 queue (BloombergLP::bslmf::MovableRef< CONTAINER > container, const ALLOCATOR &basicAllocator, typename enable_if< bsl::uses_allocator< CONTAINER, ALLOCATOR >::value, ALLOCATOR >::type *=0)
 
template<class ALLOCATOR >
 queue (BloombergLP::bslmf::MovableRef< queue > original, const ALLOCATOR &basicAllocator, typename enable_if< bsl::uses_allocator< CONTAINER, ALLOCATOR >::value, ALLOCATOR >::type *=0)
 
template<class INPUT_ITER >
 queue (INPUT_ITER first, INPUT_ITER last)
 
template<class INPUT_ITER , class ALLOCATOR >
 queue (INPUT_ITER first, INPUT_ITER last, const ALLOCATOR &allocator, typename enable_if< bsl::uses_allocator< CONTAINER, ALLOCATOR >::value, ALLOCATOR >::type *=0)
 
template<class t_RANGE >
 queue (from_range_t, BSLS_COMPILERFEATURES_FORWARD_REF(t_RANGE) range)
 
template<class t_RANGE , class t_ALLOCATOR >
 queue (from_range_t, BSLS_COMPILERFEATURES_FORWARD_REF(t_RANGE) range, const t_ALLOCATOR &allocator, typename enable_if< bsl::uses_allocator< CONTAINER, t_ALLOCATOR >::value, t_ALLOCATOR >::type *=0)
 
queueoperator= (const queue &rhs)
 
queueoperator= (BloombergLP::bslmf::MovableRef< queue > rhs)
 
template<class... Args>
reference emplace (Args &&... args)
 
void push (const value_type &value)
 
void push (BloombergLP::bslmf::MovableRef< value_type > value)
 
template<class t_RANGE >
void push_range (BSLS_COMPILERFEATURES_FORWARD_REF(t_RANGE) range)
 
void pop ()
 
reference back ()
 
bool empty () const
 
size_type size () const
 
const_reference front () const
 
const_reference back () const
 

Public Attributes

void swap(queue &other) BSLS_KEYWORD_NOEXCEPT_SPECIFICATION(bsl reference front ()
 

Protected Attributes

CONTAINER c
 

Friends

template<class VALUE2 , class CONTAINER2 >
bool operator== (const queue< VALUE2, CONTAINER2 > &, const queue< VALUE2, CONTAINER2 > &)
 
template<class VALUE2 , class CONTAINER2 >
bool operator!= (const queue< VALUE2, CONTAINER2 > &, const queue< VALUE2, CONTAINER2 > &)
 
template<class VALUE2 , class CONTAINER2 >
bool operator< (const queue< VALUE2, CONTAINER2 > &, const queue< VALUE2, CONTAINER2 > &)
 
template<class VALUE2 , class CONTAINER2 >
bool operator> (const queue< VALUE2, CONTAINER2 > &, const queue< VALUE2, CONTAINER2 > &)
 
template<class VALUE2 , class CONTAINER2 >
bool operator<= (const queue< VALUE2, CONTAINER2 > &, const queue< VALUE2, CONTAINER2 > &)
 
template<class VALUE2 , class CONTAINER2 >
bool operator>= (const queue< VALUE2, CONTAINER2 > &, const queue< VALUE2, CONTAINER2 > &)
 

Member Typedef Documentation

◆ const_reference

template<class VALUE , class CONTAINER = deque<VALUE>>
typedef CONTAINER::const_reference bsl::queue< VALUE, CONTAINER >::const_reference

◆ container_type

template<class VALUE , class CONTAINER = deque<VALUE>>
typedef CONTAINER bsl::queue< VALUE, CONTAINER >::container_type

◆ reference

template<class VALUE , class CONTAINER = deque<VALUE>>
typedef CONTAINER::reference bsl::queue< VALUE, CONTAINER >::reference

◆ size_type

template<class VALUE , class CONTAINER = deque<VALUE>>
typedef CONTAINER::size_type bsl::queue< VALUE, CONTAINER >::size_type

◆ value_type

template<class VALUE , class CONTAINER = deque<VALUE>>
typedef CONTAINER::value_type bsl::queue< VALUE, CONTAINER >::value_type

Constructor & Destructor Documentation

◆ queue() [1/14]

template<class VALUE , class CONTAINER >
bsl::queue< VALUE, CONTAINER >::queue ( )
inlineexplicit

Create an empty queue having a container of the parameterized CONTAINER type.

◆ queue() [2/14]

template<class VALUE , class CONTAINER >
bsl::queue< VALUE, CONTAINER >::queue ( const queue< VALUE, CONTAINER > &  original)
inline

Create a queue having the value of the specified original.

◆ queue() [3/14]

template<class VALUE , class CONTAINER >
bsl::queue< VALUE, CONTAINER >::queue ( BloombergLP::bslmf::MovableRef< queue< VALUE, CONTAINER > >  container)
inline

Create a queue having the value of the specified original. The allocator associated with original (if any) is propagated for use in the new queue. original is left in valid but unspecified state.

◆ queue() [4/14]

template<class VALUE , class CONTAINER >
bsl::queue< VALUE, CONTAINER >::queue ( const CONTAINER &  container)
inlineexplicit

Create a queue having the specified container that holds elements of the parameterized VALUE type.

◆ queue() [5/14]

template<class VALUE , class CONTAINER >
bsl::queue< VALUE, CONTAINER >::queue ( BloombergLP::bslmf::MovableRef< CONTAINER >  container)
inlineexplicit

Create a queue having the same sequence of values as the specified container. The allocator associated with container (if any) is propagated for use in the new queue. container is left in valid but unspecified state.

◆ queue() [6/14]

template<class VALUE , class CONTAINER >
template<class ALLOCATOR >
bsl::queue< VALUE, CONTAINER >::queue ( const ALLOCATOR &  basicAllocator,
typename enable_if< bsl::uses_allocator< CONTAINER, ALLOCATOR >::value, ALLOCATOR >::type *  = 0 
)
inlineexplicit

Create an empty queue. This queue object uses the specified basicAllocator to supply memory.

Note
Note that the ALLOCATOR parameter type has to be convertible to the allocator of the CONTAINER parameter type, CONTAINER::allocator_type; otherwise, this constructor is disabled.

◆ queue() [7/14]

template<class VALUE , class CONTAINER >
template<class ALLOCATOR >
bsl::queue< VALUE, CONTAINER >::queue ( const CONTAINER &  container,
const ALLOCATOR &  basicAllocator,
typename enable_if< bsl::uses_allocator< CONTAINER, ALLOCATOR >::value, ALLOCATOR >::type *  = 0 
)
inline

Create a queue having the same sequence of values as the specified container. The queue object uses the specified basicAllocator to obtain memory.

Note
Note that the ALLOCATOR parameter type has to be convertible to the allocator of the CONTAINER parameter type, CONTAINER::allocator_type; otherwise, this constructor is disabled.

◆ queue() [8/14]

template<class VALUE , class CONTAINER >
template<class ALLOCATOR >
bsl::queue< VALUE, CONTAINER >::queue ( const queue< VALUE, CONTAINER > &  original,
const ALLOCATOR &  basicAllocator,
typename enable_if< bsl::uses_allocator< CONTAINER, ALLOCATOR >::value, ALLOCATOR >::type *  = 0 
)
inline

Create a queue having the value of the specified original that will use the specified basicAllocator to supply memory.

Note
Note that the ALLOCATOR parameter type has to be convertible to the allocator of the CONTAINER parameter type, CONTAINER::allocator_type. Otherwise this constructor is disabled.

◆ queue() [9/14]

template<class VALUE , class CONTAINER >
template<class ALLOCATOR >
bsl::queue< VALUE, CONTAINER >::queue ( BloombergLP::bslmf::MovableRef< CONTAINER >  container,
const ALLOCATOR &  basicAllocator,
typename enable_if< bsl::uses_allocator< CONTAINER, ALLOCATOR >::value, ALLOCATOR >::type *  = 0 
)
inline

Create a queue whose underlying container has the value of the specified container (on entry) and uses basicAllocator to supply memory. The allocated-extended move constructor of CONTAINER is used to create the new queue. container is left in a valid but unspecified state.

Note
Note that a bslma::Allocator * can be supplied for basicAllocator if the (template parameter) ALLOCATOR is bsl::allocator (the default). Also note that this method assumes that CONTAINER has a move constructor. Also note that if CONTAINER::allocator_type does not exist, this constructor is disabled.

◆ queue() [10/14]

template<class VALUE , class CONTAINER >
template<class ALLOCATOR >
bsl::queue< VALUE, CONTAINER >::queue ( BloombergLP::bslmf::MovableRef< queue< VALUE, CONTAINER > >  original,
const ALLOCATOR &  basicAllocator,
typename enable_if< bsl::uses_allocator< CONTAINER, ALLOCATOR >::value, ALLOCATOR >::type *  = 0 
)
inline

Create a queue having the value of the specified original (on entry), that uses basicAllocator to supply memory. The allocator-extended move constructor of CONTAINER is used to create the new queue. original is left in a valid but unspecified state.

Note
Note that a bslma::Allocator * can be supplied for basicAllocator if the (template parameter) ALLOCATOR is bsl::allocator (the default). Also note that this method assumes that CONTAINER has a move constructor. Also note that if CONTAINER::allocator_type does not exist, this constructor is disabled.

◆ queue() [11/14]

template<class VALUE , class CONTAINER >
template<class INPUT_ITER >
bsl::queue< VALUE, CONTAINER >::queue ( INPUT_ITER  first,
INPUT_ITER  last 
)
inline

Create a queue passing the specified first and last to the constructor of the underlying container. Optionally specify an allocator used to supply memory. If allocator is not specified, a default-constructed object of the (template parameter) type ALLOCATOR is used.

◆ queue() [12/14]

template<class VALUE , class CONTAINER >
template<class INPUT_ITER , class ALLOCATOR >
bsl::queue< VALUE, CONTAINER >::queue ( INPUT_ITER  first,
INPUT_ITER  last,
const ALLOCATOR &  allocator,
typename enable_if< bsl::uses_allocator< CONTAINER, ALLOCATOR >::value, ALLOCATOR >::type *  = 0 
)
inline

◆ queue() [13/14]

template<class VALUE , class CONTAINER >
template<class t_RANGE >
bsl::queue< VALUE, CONTAINER >::queue ( from_range_t  ,
BSLS_COMPILERFEATURES_FORWARD_REF(t_RANGE)  range 
)
inline

Create a queue from the elements of the specifed range. Optionally specify an allocator used to supply memory. If allocator is not specified, a default-constructed object of the (template parameter) type t_ALLOCATOR is used.

Note
Note that range must meet the requirements of an input range and the values from range must have a type matching or convertible to (template parameter) VALUE.

◆ queue() [14/14]

template<class VALUE , class CONTAINER >
template<class t_RANGE , class t_ALLOCATOR >
bsl::queue< VALUE, CONTAINER >::queue ( from_range_t  ,
BSLS_COMPILERFEATURES_FORWARD_REF(t_RANGE)  range,
const t_ALLOCATOR &  allocator,
typename enable_if< bsl::uses_allocator< CONTAINER, t_ALLOCATOR >::value, t_ALLOCATOR >::type *  = 0 
)
inline

Member Function Documentation

◆ back() [1/2]

template<class VALUE , class CONTAINER >
queue< VALUE, CONTAINER >::reference bsl::queue< VALUE, CONTAINER >::back ( )
inline

Return a reference providing modifiable access to the back (the latest pushed) element of this queue object.

◆ back() [2/2]

template<class VALUE , class CONTAINER >
queue< VALUE, CONTAINER >::const_reference bsl::queue< VALUE, CONTAINER >::back ( ) const
inline

Return the immutable back (the latest pushed) element from this queue object. In effect, performs c.back().

◆ BSLMF_NESTED_TRAIT_DECLARATION_IF()

template<class VALUE , class CONTAINER = deque<VALUE>>
bsl::queue< VALUE, CONTAINER >::BSLMF_NESTED_TRAIT_DECLARATION_IF ( queue< VALUE, CONTAINER >  ,
BloombergLP::bslma::UsesBslmaAllocator  ,
BloombergLP::bslma::UsesBslmaAllocator< container_type >::value   
)

◆ emplace()

template<class VALUE , class CONTAINER >
template<class... Args>
queue< VALUE, CONTAINER >::reference bsl::queue< VALUE, CONTAINER >::emplace ( Args &&...  args)
inline

Push onto this queue a newly created value_type object constructed by forwarding get_allocator() (if required) and the specified (variable number of) args to the corresponding constructor of value_type. Return a reference providing modifiable access to the inserted element.

◆ empty()

template<class VALUE , class CONTAINER >
bool bsl::queue< VALUE, CONTAINER >::empty ( ) const
inline

Return true if this queue object contains no elements, and false otherwise. In effect, performs return c.empty();.

◆ front()

template<class VALUE , class CONTAINER = deque<VALUE>>
const_reference bsl::queue< VALUE, CONTAINER >::front ( ) const

Return the immutable front (the earliest pushed) element from this queue object. In effect, performs c.front().

◆ operator=() [1/2]

template<class VALUE , class CONTAINER >
queue< VALUE, CONTAINER > & bsl::queue< VALUE, CONTAINER >::operator= ( BloombergLP::bslmf::MovableRef< queue< VALUE, CONTAINER > >  rhs)
inline

Assign to this queue the value as the specified rhs and return a reference providing modifiable access to this queue. The move-assignment operator of CONTAINER is used to set the value of this queue. rhs is left in a valid but unspecified state, and if an exception is thrown, *this is left in a valid but unspecified state.

◆ operator=() [2/2]

template<class VALUE , class CONTAINER >
queue< VALUE, CONTAINER > & bsl::queue< VALUE, CONTAINER >::operator= ( const queue< VALUE, CONTAINER > &  rhs)
inline

Assign to this queue the value of the specified rhs, and return a reference providing modifiable access to this queue.

◆ pop()

template<class VALUE , class CONTAINER >
void bsl::queue< VALUE, CONTAINER >::pop ( )
inline

Remove the front (the earliest pushed) element from this queue object.

◆ push() [1/2]

template<class VALUE , class CONTAINER >
void bsl::queue< VALUE, CONTAINER >::push ( BloombergLP::bslmf::MovableRef< value_type value)
inline

Push onto the back of this queue a value_type object having the value of the specified value (on entry) by moving the contents of value to the new object on this queue. value is left in a valid but unspecified state.

◆ push() [2/2]

template<class VALUE , class CONTAINER >
void bsl::queue< VALUE, CONTAINER >::push ( const value_type value)
inline

Push onto the back of this queue a value_type object having the specified value.

◆ push_range()

template<class VALUE , class CONTAINER >
template<class t_RANGE >
void bsl::queue< VALUE, CONTAINER >::push_range ( BSLS_COMPILERFEATURES_FORWARD_REF(t_RANGE)  range)

Push onto the back of this queue the elements of the specified range.

Note
Note that range must meet the requirements of an input range and the values from range must have a type matching or convertible to (template parameter) VALUE.

◆ size()

template<class VALUE , class CONTAINER >
queue< VALUE, CONTAINER >::size_type bsl::queue< VALUE, CONTAINER >::size ( ) const
inline

Return the number of elements in this queue. In effect, performs return c.size();.

Friends And Related Symbol Documentation

◆ operator!=

template<class VALUE , class CONTAINER = deque<VALUE>>
template<class VALUE2 , class CONTAINER2 >
bool operator!= ( const queue< VALUE2, CONTAINER2 > &  ,
const queue< VALUE2, CONTAINER2 > &   
)
friend

◆ operator<

template<class VALUE , class CONTAINER = deque<VALUE>>
template<class VALUE2 , class CONTAINER2 >
bool operator< ( const queue< VALUE2, CONTAINER2 > &  ,
const queue< VALUE2, CONTAINER2 > &   
)
friend

◆ operator<=

template<class VALUE , class CONTAINER = deque<VALUE>>
template<class VALUE2 , class CONTAINER2 >
bool operator<= ( const queue< VALUE2, CONTAINER2 > &  ,
const queue< VALUE2, CONTAINER2 > &   
)
friend

◆ operator==

template<class VALUE , class CONTAINER = deque<VALUE>>
template<class VALUE2 , class CONTAINER2 >
bool operator== ( const queue< VALUE2, CONTAINER2 > &  ,
const queue< VALUE2, CONTAINER2 > &   
)
friend

◆ operator>

template<class VALUE , class CONTAINER = deque<VALUE>>
template<class VALUE2 , class CONTAINER2 >
bool operator> ( const queue< VALUE2, CONTAINER2 > &  ,
const queue< VALUE2, CONTAINER2 > &   
)
friend

◆ operator>=

template<class VALUE , class CONTAINER = deque<VALUE>>
template<class VALUE2 , class CONTAINER2 >
bool operator>= ( const queue< VALUE2, CONTAINER2 > &  ,
const queue< VALUE2, CONTAINER2 > &   
)
friend

Member Data Documentation

◆ c

template<class VALUE , class CONTAINER = deque<VALUE>>
CONTAINER bsl::queue< VALUE, CONTAINER >::c
protected

◆ front

template<class VALUE , class CONTAINER >
queue< VALUE, CONTAINER >::const_reference bsl::queue< VALUE, CONTAINER >::front
inline

Efficiently exchange the value of this object with the value of the specified other object. In effect, performs using bsl::swap; swap(c, other.c);. Return a reference providing modifiable access to the front (the earliest pushed) element from this queue object.


The documentation for this class was generated from the following file: