Quick Links:

bal | bbl | bdl | bsl

Namespaces

Component bslalg_dequeprimitives
[Package bslalg]

Provide primitive algorithms that operate on deques. More...

Namespaces

namespace  bslalg

Detailed Description

Outline
Purpose:
Provide primitive algorithms that operate on deques.
Classes:
bslalg::DequePrimitives namespace for deque algorithms
See also:
Component bslma_constructionutil, Component bslalg_arrayprimitives
Description:
This component provides utilities to initialize, destroy, move, and otherwise perform various primitive manipulations on deques with a uniform interface, but selecting a different implementation according to the various traits possessed by the underlying type, and selecting a simpler implementation when there is only one element per deque block. See the bslalg_dequeimputil and bslalg_dequeiterator components for a definition and visual depiction of the internal organization of a deque, and of the iterator type used to refer to elements in the deque.
The primitives provided by this component are exceptionally useful for implementing generic block-based components such as deques. A short synopsis is provided below describing the observable behavior and mentioning the relevant traits. See the full function-level contract for detailed description, including exception-safety guarantees. In the description below, Ar stands for bslalg::ArrayPrimitives. Note that some algorithms are explained in terms of previous algorithms.
  Algorithm                     Short description of observable behavior
  ----------------------------  ---------------------------------------------
  destruct                      Destroy each element in the target range.

  erase                         'destruct' for each element in the target
                                range, or 'no-op' if bitwise copyable, then
                                shift the remaining elements from either the
                                front or the back to fill hole.

  uninitializedFillNBack        'Ar::uninitializedFillN' for each block at
                                the end of the deque

  uninitializedFillNFront       'Ar::uninitializedFillN' for each block at
                                the front of the deque.

  valueInititalizeN             'Ar::defaultConstruct' for each block at the
                                end of the deque.

  insertAndMoveToBack           Copy construct each element in the target
                                range, or 'std::memmove' if type is bitwise
                                moveable, to the back of the deque to create
                                a hole, followed by copy construct of target
                                value or range to fill the hole.

  insertAndMoveToFront          Copy construct each element in the target
                                range, or 'std::memmove' if type is bitwise
                                moveable, to the front of the deque to create
                                a hole, followed by copy construct or
                                'std::memmove' of target value or range to
                                fill the hole.

  moveInsertAndMoveToBack       Move-construct or move-assign each element in
                                the target range (or 'std::memmove' if type
                                is bitwise moveable) to the back of the
                                deque to create a 1-slot hole, followed by
                                move-assign of the movable source value to
                                fill the hole.

  moveInsertAndMoveToFront      Move-construct or move-assign each element in
                                the target range (or 'std::memmove' if type
                                is bitwise moveable) to the front of the
                                deque to create a 1-slot hole, followed by
                                move-assign of the movable source value to
                                fill the hole.

  emplaceAndMoveToBack          Move-construct or move-assign each element in
                                the target range (or 'std::memmove' if type
                                is bitwise moveable) to the back of the
                                deque to create a 1-slot hole, followed by
                                in-place construction of the source value to
                                fill the hole.

  emplaceAndMoveToFront         Move-construct or move-assign each element in
                                the target range (or 'std::memmove' if type
                                is bitwise moveable) to the front of the
                                deque to create a 1-slot hole, followed by
                                in-place construction of the source value to
                                fill the hole.
The traits under consideration directly or indirectly by this component are:
  Trait                                         English description
  -----                                         -------------------
  bsl::is_trivially_copyable                    "TYPE has the bitwise
                                                copyable trait", or
                                                "TYPE is bitwise copyable"

  bslmf::IsBitwiseMoveable                      "TYPE has the bitwise
                                                moveable trait", or
                                                "TYPE is bitwise moveable"
Aliasing:
There are some aliasing concerns in this component, due to the presence of the reference const VALUE_TYPE& value argument, which may belong to a range that will be modified during the course of the operation. All such aliasing concerns are taken care of properly. Other aliasing concerns due to the copying of a range [first .. last) are not taken care of, since their intended use is for range assignments and insertions in standard containers, for which the standard explicitly says that first and last shall not be iterators into the container.
Usage:
This component is for use by the bslstl package. Other clients should use the STL deque (in header <deque>).