BDE 4.14.0 Production release
|
#include <bdlcc_deque.h>
Classes | |
class | ConstProctor |
class | DequeThrowGuard |
class | Proctor |
Public Types | |
typedef bsl::deque< TYPE > | MonoDeque |
typedef MonoDeque::size_type | size_type |
Public Member Functions | |
Deque (bslma::Allocator *basicAllocator=0) | |
Deque (bsls::SystemClockType::Enum clockType, bslma::Allocator *basicAllocator=0) | |
Deque (bsl::size_t highWaterMark, bslma::Allocator *basicAllocator=0) | |
Deque (bsl::size_t highWaterMark, bsls::SystemClockType::Enum clockType, bslma::Allocator *basicAllocator=0) | |
template<class INPUT_ITER > | |
Deque (INPUT_ITER begin, INPUT_ITER end, bslma::Allocator *basicAllocator=0) | |
template<class INPUT_ITER > | |
Deque (INPUT_ITER begin, INPUT_ITER end, bsls::SystemClockType::Enum clockType, bslma::Allocator *basicAllocator=0) | |
template<class INPUT_ITER > | |
Deque (INPUT_ITER begin, INPUT_ITER end, bsl::size_t highWaterMark, bslma::Allocator *basicAllocator=0) | |
template<class INPUT_ITER > | |
Deque (INPUT_ITER begin, INPUT_ITER end, bsl::size_t highWaterMark, bsls::SystemClockType::Enum clockType, bslma::Allocator *basicAllocator=0) | |
Deque (const Deque< TYPE > &original, bslma::Allocator *basicAllocator=0) | |
~Deque () | |
void | forcePushBack (const TYPE &item) |
void | forcePushBack (bslmf::MovableRef< TYPE > item) |
template<class INPUT_ITER > | |
void | forcePushBack (INPUT_ITER begin, INPUT_ITER end) |
void | forcePushFront (const TYPE &item) |
void | forcePushFront (bslmf::MovableRef< TYPE > item) |
template<class INPUT_ITER > | |
void | forcePushFront (INPUT_ITER begin, INPUT_ITER end) |
TYPE | popBack () |
void | popBack (TYPE *item) |
TYPE | popFront () |
void | popFront (TYPE *item) |
void | pushBack (const TYPE &item) |
void | pushBack (bslmf::MovableRef< TYPE > item) |
void | pushFront (const TYPE &item) |
void | pushFront (bslmf::MovableRef< TYPE > item) |
void | removeAll () |
void | removeAll (bsl::vector< TYPE > *buffer) |
void | removeAll (std::vector< TYPE > *buffer) |
int | timedPopBack (TYPE *item, const bsls::TimeInterval &timeout) |
int | timedPopFront (TYPE *item, const bsls::TimeInterval &timeout) |
int | timedPushBack (const TYPE &item, const bsls::TimeInterval &timeout) |
int | timedPushBack (bslmf::MovableRef< TYPE > item, const bsls::TimeInterval &timeout) |
int | timedPushFront (const TYPE &item, const bsls::TimeInterval &timeout) |
int | timedPushFront (bslmf::MovableRef< TYPE > item, const bsls::TimeInterval &timeout) |
int | tryPopBack (TYPE *item) |
void | tryPopBack (size_type maxNumItems) |
void | tryPopBack (size_type maxNumItems, bsl::vector< TYPE > *buffer) |
void | tryPopBack (size_type maxNumItems, std::vector< TYPE > *buffer) |
int | tryPopFront (TYPE *item) |
void | tryPopFront (size_type maxNumItems) |
void | tryPopFront (size_type maxNumItems, bsl::vector< TYPE > *buffer) |
void | tryPopFront (size_type maxNumItems, std::vector< TYPE > *buffer) |
int | tryPushBack (const TYPE &item) |
int | tryPushBack (bslmf::MovableRef< TYPE > item) |
template<class INPUT_ITER > | |
size_type | tryPushBack (INPUT_ITER begin, INPUT_ITER end) |
int | tryPushFront (const TYPE &item) |
int | tryPushFront (bslmf::MovableRef< TYPE > item) |
template<class INPUT_ITER > | |
size_type | tryPushFront (INPUT_ITER begin, INPUT_ITER end) |
bslma::Allocator * | allocator () const |
Return the allocator used by this container for allocating memory. | |
bsls::SystemClockType::Enum | clockType () const |
size_type | highWaterMark () const |
Return the high-water mark value for this container. | |
size_type | length () const |
template<class VECTOR > | |
void | tryPopBackImp (typename Deque< TYPE >::size_type maxNumItems, VECTOR *buffer) |
template<class VECTOR > | |
void | tryPopFrontImp (typename Deque< TYPE >::size_type maxNumItems, VECTOR *buffer) |
Static Public Member Functions | |
static size_type | maxSizeT () |
This class provides a fully thread-safe implementation of an efficient, in-place, indexable, double-ended queue of (template parameter) TYPE
values. Direct access to the underlying bsl::deque<TYPE>
object is provided through the nested Proctor
and ConstProctor
classes. While this class is not value-semantic, the underlying bsl::deque<TYPE>
class is.
See bdlcc_deque
typedef bsl::deque<TYPE> bdlcc::Deque< TYPE >::MonoDeque |
typedef MonoDeque::size_type bdlcc::Deque< TYPE >::size_type |
|
inlineexplicit |
|
inlineexplicit |
Create a container of objects of (template parameter) TYPE
, with no high water mark, and use the specified clockType
to indicate the epoch used for all time intervals (see {Supported Clock-Types} in the component documentation). If basicAllocator
is 0, the currently installed default allocator is used.
|
inlineexplicit |
|
inline |
Create a container of objects of (template parameter) TYPE
, with the specified highWaterMark
, and use the specified clockType
to indicate the epoch used for all time intervals (see {Supported Clock-Types} in the component documentation). Optionally specify a basicAllocator
used to supply memory. If basicAllocator
is 0, the currently installed default allocator is used. The behavior is undefined unless highWaterMark > 0
.
|
inline |
Create a container of objects of (template parameter) TYPE
containing the sequence of elements in the specified range [begin .. end)
, having no high water mark, and use the specified clockType
to indicate the epoch used for all time intervals (see {Supported Clock-Types} in the component documentation). Optionally specify a basicAllocator
used to supply memory. If basicAllocator
is 0, the currently installed default allocator is used. Note that the items in the range are treated as const
objects, copied without being modified.
|
inline |
|
inline |
Create a container of objects of (template parameter) TYPE
containing the sequence of TYPE
values in the specified range [begin .. end)
having the specified highWaterMark
, and use the specified clockType
to indicate the epoch used for all time intervals (see {Supported Clock-Types} in the component documentation). Optionally specify a basicAllocator
used to supply memory. If basicAllocator
is 0, the currently installed default allocator is used. The behavior is undefined unless highWaterMark > 0
. Note that if the number of elements in the range [begin, end)
exceeds highWaterMark
, the effect will be the same as if the extra elements were added by forced pushes. Also note that the items in the range are treated as const
objects, copied without being modified.
|
inline |
|
inline |
Create a container having the same value as the specified original
object. Optionally specify a basicAllocator
used to supply memory. If basicAllocator
is 0, the currently installed default allocator is used.
|
inline |
Destroy this container. The behavior is undefined unless all access or modification of the container has completed prior to the destruction of this object.
|
inline |
|
inline |
Return the system clock type used for timing timed*
operations on this object (see {Supported Clock-Types} in the component documentation).
|
inline |
Append the specified move-insertable item
to the back of this container without regard for the high-water mark. item
is left in a valid but unspecified state. Note that this method is provided to allow high priority items to be inserted when the container is full; pushFront
and pushBack
should be used for general use.
|
inline |
Append the specified item
to the back of this container without regard for the high-water mark. Note that this method is provided to allow high priority items to be inserted when the container is full; pushFront
and pushBack
should be used for general use.
|
inline |
Append the specified specified range [begin .. end)
of items to the back of this container without regard for the high-water mark. Note that the items in the range are treated as const
objects, copied without being modified.
|
inline |
Append the specified move-insertable item
to the front of this container without regard for the high-water mark. item
is left in a valid but unspecified state. Note that this method is provided to allow high priority items to be inserted when the container is full; pushFront
and pushBack
should be used for general use.
|
inline |
Append the specified item
to the front of this container without regard for the high-water mark. Note that this method is provided to allow high priority items to be inserted when the container is full; pushFront
and pushBack
should be used for general use.
|
inline |
Append the specified specified range [begin .. end)
of items to the front of this container without regard for the high-water mark. Note that pushed the items will be in the container in the reverse of the order in which they occur in the range. Also note that the items in the range are treated as const
objects, copied without being modified.
|
inline |
|
inline |
Return the number of elements contained in this container. Note that this method temporarily acquires the mutex, so that this method must not be called while a proctor in the same thread has this container locked, and the value returned is potentially obsolete before it is returned if any other threads are simultaneously modifying this container. To find the length while a proctor has the container locked, call proctor->size()
.
|
inlinestatic |
Return the maximum value that can be stored in a veriable of type size_type
. The high water mark defaults to having this value.
TYPE bdlcc::Deque< TYPE >::popBack | ( | ) |
Return the last item in this container and remove it. If this container is empty, block until an item is available.
void bdlcc::Deque< TYPE >::popBack | ( | TYPE * | item | ) |
Remove the last item in this container and load that item into the specified *item
. If this container is empty, block until an item is available.
TYPE bdlcc::Deque< TYPE >::popFront | ( | ) |
Return the first item in this container and remove it. If this container is empty, block until an item is available.
void bdlcc::Deque< TYPE >::popFront | ( | TYPE * | item | ) |
Remove the first item in this container and load that item into the specified *item
. If the container is empty, block until an item is available.
void bdlcc::Deque< TYPE >::pushBack | ( | bslmf::MovableRef< TYPE > | item | ) |
Block until space in this container becomes available (see {High-Water Mark
Feature}), then append the specified move-insertable item
to the back of this container. item
is left in a valid but unspecified state.
void bdlcc::Deque< TYPE >::pushBack | ( | const TYPE & | item | ) |
Block until space in this container becomes available (see {High-Water Mark
Feature}), then append the specified item
to the back of this container.
void bdlcc::Deque< TYPE >::pushFront | ( | bslmf::MovableRef< TYPE > | item | ) |
Block until space in this container becomes available (see {High-Water Mark
Feature}), then append the specified move-insertable item
to the front of this container. item
is left in a valid but unspecified state.
void bdlcc::Deque< TYPE >::pushFront | ( | const TYPE & | item | ) |
Block until space in this container becomes available (see {High-Water Mark
Feature}), then append the specified item
to the front of this container.
|
inline |
|
inline |
|
inline |
If the optionally specified buffer
is non-zero, append all the elements from this container to *buffer
in the same order, then, regardless of whether buffer
is zero, clear this container. Note that the previous contents of *buffer
are not discarded – the removed items are appended to it.
int bdlcc::Deque< TYPE >::timedPopBack | ( | TYPE * | item, |
const bsls::TimeInterval & | timeout | ||
) |
Remove the last item in this container and load that item value into the specified *item
. If this container is empty, block until an item is available or until the specified timeout
(expressed as the ABSOLUTE time from 00:00:00 UTC, January 1, 1970) expires. Return 0 on success, and a non-zero value if the call timed out before an item was available. Note that this method can block indefinitely if another thread has the mutex locked, particularly by a proctor object – there is no guarantee that this method will return after timeout
.
int bdlcc::Deque< TYPE >::timedPopFront | ( | TYPE * | item, |
const bsls::TimeInterval & | timeout | ||
) |
Remove the first item in this container and load that item value into the specified *item
. If this container is empty, block until an item is available or until the specified timeout
(expressed as the ABSOLUTE time from 00:00:00 UTC, January 1, 1970) expires. Return 0 on success, and a non-zero value if the call timed out before an item was available. Note that this method can block indefinitely if another thread has the mutex locked, particularly by a proctor object – there is no guarantee that this method will return after timeout
.
int bdlcc::Deque< TYPE >::timedPushBack | ( | bslmf::MovableRef< TYPE > | item, |
const bsls::TimeInterval & | timeout | ||
) |
Append the specified move-insertable item
to the back of this container if space is available, otherwise (if the container is full) block waiting for space to become available or until the specified timeout
(expressed as the ABSOLUTE time from 00:00:00 UTC, January 1, 1970) expires. If the container is modified, item
is left in a valid but unspecified state, otherwise item
is unchanged. Return 0 if space was or became available and this container was updated, and a non-zero value if the call timed out before space became available and this container was left unmodified. Note that this method can block indefinitely if another thread has the mutex locked, particularly by a proctor object – there is no guarantee that this method will return after timeout
.
int bdlcc::Deque< TYPE >::timedPushBack | ( | const TYPE & | item, |
const bsls::TimeInterval & | timeout | ||
) |
Append the specified item
to the back of this container if space is available, otherwise (if the container is full) block waiting for space to become available or until the specified timeout
(expressed as the ABSOLUTE time from 00:00:00 UTC, January 1, 1970) expires. Return 0 if space was or became available and this container was updated, and a non-zero value if the call timed out before space became available and this container was left unmodified. Note that this method can block indefinitely if another thread has the mutex locked, particularly by a proctor object – there is no guarantee that this method will return after timeout
.
int bdlcc::Deque< TYPE >::timedPushFront | ( | bslmf::MovableRef< TYPE > | item, |
const bsls::TimeInterval & | timeout | ||
) |
Append the specified move-insertable item
to the front of this container if space is available, otherwise (if the container is full) block waiting for space to become available or until the specified timeout
(expressed as the ABSOLUTE time from 00:00:00 UTC, January 1, 1970) expires. If the container is modified,item
is left in a valid but unspecified state, otherwise item
is left unchanged. Return 0 if space was or became available and this container was updated, and a non-zero value if the call timed out before space became available and this container was left unmodified. Note that this method can block indefinitely if another thread has the mutex locked, particularly by a proctor object – there is no guarantee that this method will return after timeout
.
int bdlcc::Deque< TYPE >::timedPushFront | ( | const TYPE & | item, |
const bsls::TimeInterval & | timeout | ||
) |
Append the specified item
to the front of this container if space is available, otherwise (if the container is full) block waiting for space to become available or until the specified timeout
(expressed as the ABSOLUTE time from 00:00:00 UTC, January 1, 1970) expires. Return 0 if space was or became available and this container was updated, and a non-zero value if the call timed out before space became available and this container was left unmodified. Note that this method can block indefinitely if another thread has the mutex locked, particularly by a proctor object – there is no guarantee that this method will return after timeout
.
void bdlcc::Deque< TYPE >::tryPopBack | ( | size_type | maxNumItems | ) |
Remove up to the specified maxNumItems
from the back of this container. Optionally specify a buffer
into which the items removed from the container are loaded. If buffer
is non-null, the removed items are appended to it as if by repeated application of buffer->push_back(popBack())
while the container is not empty and maxNumItems
have not yet been removed. Note that the ordering of the items in *buffer
after the call is the reverse of the ordering they had in the deque. Also note that *buffer
is not cleared – the popped items are appended after any pre-existing contents.
void bdlcc::Deque< TYPE >::tryPopBack | ( | size_type | maxNumItems, |
bsl::vector< TYPE > * | buffer | ||
) |
void bdlcc::Deque< TYPE >::tryPopBack | ( | size_type | maxNumItems, |
std::vector< TYPE > * | buffer | ||
) |
Also note that to transfer the entire contents of a Deque
d
to a vector v
, use d.removeAll(&v);
.
int bdlcc::Deque< TYPE >::tryPopBack | ( | TYPE * | item | ) |
If this container is non-empty, remove the last item, load that item into the specified *item
, and return 0 indicating success. If this container is empty, return a non-zero value with no effect on item
or the state of this container.
void bdlcc::Deque< TYPE >::tryPopBackImp | ( | typename Deque< TYPE >::size_type | maxNumItems, |
VECTOR * | buffer | ||
) |
void bdlcc::Deque< TYPE >::tryPopFront | ( | size_type | maxNumItems | ) |
Remove up to the specified maxNumItems
from the front of this container. Optionally specify a buffer
into which the items removed from the container are appended. If buffer
is non-null, the removed items are appended to it as if by repeated application of buffer->push_back(popFront())
while the const is not empty and maxNumItems
have not yet been removed. Note that *buffer
is not cleared – the popped items are appended after any pre-existing contents.
void bdlcc::Deque< TYPE >::tryPopFront | ( | size_type | maxNumItems, |
bsl::vector< TYPE > * | buffer | ||
) |
void bdlcc::Deque< TYPE >::tryPopFront | ( | size_type | maxNumItems, |
std::vector< TYPE > * | buffer | ||
) |
Also note that to transfer the entire contents of a Deque
d
to a vector v
, use d.removeAll(&v);
.
int bdlcc::Deque< TYPE >::tryPopFront | ( | TYPE * | item | ) |
If this container is non-empty, remove the first item, load that item into the specified *item
, and return 0 indicating success. If this container is empty, return a non-zero value with no effect on *item
or the state of this container.
void bdlcc::Deque< TYPE >::tryPopFrontImp | ( | typename Deque< TYPE >::size_type | maxNumItems, |
VECTOR * | buffer | ||
) |
int bdlcc::Deque< TYPE >::tryPushBack | ( | bslmf::MovableRef< TYPE > | item | ) |
If the container is not full (see {High-Water Mark
Feature}), append the specified move-insertable item
to the back of the container, otherwise leave the container unchanged. If the container is modified, item
is left in a valid but unspecified state, otherwise item
is unchanged. Return 0 if the container was updated and a non-zero value otherwise.
int bdlcc::Deque< TYPE >::tryPushBack | ( | const TYPE & | item | ) |
If the container is not full (see {High-Water Mark
Feature}), append the specified item
to the back of the container, otherwise leave the container unchanged. Return 0 if the container was updated and a non-zero value otherwise.
Deque< TYPE >::size_type bdlcc::Deque< TYPE >::tryPushBack | ( | INPUT_ITER | begin, |
INPUT_ITER | end | ||
) |
Push as many of the items in the specified range [begin .. end)
as there is space available for (see {High-Water Mark
Feature}) to the back of the container, stopping if the container high-water mark is reached. Return the number of items pushed. Note that the items in the range are treated as const
objects, copied without being modified.
int bdlcc::Deque< TYPE >::tryPushFront | ( | bslmf::MovableRef< TYPE > | item | ) |
If the container is not full (see {High-Water Mark
Feature}), append the specified move-insertable item
to the front of the container, otherwise leave the container unchanged. If the container is modified, item
is left in a valid but unspecified state, otherwise item
is unchanged. Return 0 if the container was updated and a non-zero value otherwise.
int bdlcc::Deque< TYPE >::tryPushFront | ( | const TYPE & | item | ) |
If the container is not full (see {High-Water Mark
Feature}), append the specified item
to the front of the container, otherwise leave the container unchanged. Return 0 if the container was updated and a non-zero value otherwise.
Deque< TYPE >::size_type bdlcc::Deque< TYPE >::tryPushFront | ( | INPUT_ITER | begin, |
INPUT_ITER | end | ||
) |
Push as many of the items in the specified range [begin .. end)
as there is space available for (see {High-Water Mark
Feature}) to the front of the container, stopping if the container high-water mark is reached. Return the number of items pushed. Note that the pushed items will be in the container in the reverse of the order in which they occur in the range. Also note that the items in the range are treated as const
objects, copied without being modified.