Quick Links: |
Provide an STL-compliant map class. More...
Classes | |
class | bsl::map< KEY, VALUE, COMPARATOR, ALLOCATOR > |
class | bsl::map< KEY, VALUE, COMPARATOR, ALLOCATOR >::DataWrapper |
class | bsl::map< KEY, VALUE, COMPARATOR, ALLOCATOR >::value_compare |
Typedefs | |
typedef KEY | bsl::map::key_type |
typedef VALUE | bsl::map::mapped_type |
typedef pair< const KEY, VALUE > | bsl::map::value_type |
typedef COMPARATOR | bsl::map::key_compare |
typedef ALLOCATOR | bsl::map::allocator_type |
typedef value_type & | bsl::map::reference |
typedef const value_type & | bsl::map::const_reference |
typedef AllocatorTraits::size_type | bsl::map::size_type |
typedef AllocatorTraits::difference_type | bsl::map::difference_type |
typedef AllocatorTraits::pointer | bsl::map::pointer |
typedef AllocatorTraits::const_pointer | bsl::map::const_pointer |
typedef BloombergLP::bslstl::TreeIterator < value_type, Node, difference_type > | bsl::map::iterator |
typedef BloombergLP::bslstl::TreeIterator < const value_type, Node, difference_type > | bsl::map::const_iterator |
typedef bsl::reverse_iterator < iterator > | bsl::map::reverse_iterator |
typedef bsl::reverse_iterator < const_iterator > | bsl::map::const_reverse_iterator |
typedef bool | bsl::map::value_compare::result_type |
typedef value_type | bsl::map::value_compare::first_argument_type |
typedef value_type | bsl::map::value_compare::second_argument_type |
Functions | |
bsl::map::DataWrapper::DataWrapper (const COMPARATOR &comparator, const ALLOCATOR &basicAllocator) | |
bsl::map::DataWrapper::DataWrapper (BloombergLP::bslmf::MovableRef< DataWrapper > original) | |
NodeFactory & | bsl::map::DataWrapper::nodeFactory () |
const NodeFactory & | bsl::map::DataWrapper::nodeFactory () const |
bsl::map::value_compare::value_compare (COMPARATOR comparator) | |
bsl::map::value_compare::value_compare (const value_compare &original) | |
bsl::map::value_compare::~value_compare () | |
value_compare & | bsl::map::value_compare::operator= (const value_compare &rhs) |
bool | bsl::map::value_compare::operator() (const value_type &x, const value_type &y) const |
bsl::map::map () | |
bsl::map::map (const COMPARATOR &comparator, const ALLOCATOR &basicAllocator=ALLOCATOR()) | |
bsl::map::map (const ALLOCATOR &basicAllocator) | |
bsl::map::map (const map &original) | |
bsl::map::map (BloombergLP::bslmf::MovableRef< map > original) | |
bsl::map::map (const map &original, const typename type_identity< ALLOCATOR >::type &basicAllocator) | |
bsl::map::map (BloombergLP::bslmf::MovableRef< map > original, const typename type_identity< ALLOCATOR >::type &basicAllocator) | |
template<class INPUT_ITERATOR > | |
bsl::map::map (INPUT_ITERATOR first, INPUT_ITERATOR last, const COMPARATOR &comparator=COMPARATOR(), const ALLOCATOR &basicAllocator=ALLOCATOR()) | |
template<class INPUT_ITERATOR > | |
bsl::map::map (INPUT_ITERATOR first, INPUT_ITERATOR last, const ALLOCATOR &basicAllocator) | |
bsl::map::map (std::initializer_list< value_type > values, const COMPARATOR &comparator=COMPARATOR(), const ALLOCATOR &basicAllocator=ALLOCATOR()) | |
bsl::map::map (std::initializer_list< value_type > values, const ALLOCATOR &basicAllocator) | |
bsl::map::~map () | |
map & | bsl::map::operator= (const map &rhs) |
map &operator=(BloombergLP::bslmf::MovableRef < map > rhs) BSLS_KEYWORD_NOEXCEPT_SPECIFICATION(AllocatorTraits map & | bsl::map::operator= (std::initializer_list< value_type > values) |
add_lvalue_reference< VALUE >::type | bsl::map::operator[] (const key_type &key) |
add_lvalue_reference< VALUE >::type | bsl::map::operator[] (BloombergLP::bslmf::MovableRef< key_type > key) |
add_lvalue_reference< VALUE >::type | bsl::map::at (const key_type &key) |
iterator | bsl::map::begin () BSLS_KEYWORD_NOEXCEPT |
iterator | bsl::map::end () BSLS_KEYWORD_NOEXCEPT |
reverse_iterator | bsl::map::rbegin () BSLS_KEYWORD_NOEXCEPT |
reverse_iterator | bsl::map::rend () BSLS_KEYWORD_NOEXCEPT |
pair< iterator, bool > | bsl::map::insert (const value_type &value) |
pair< iterator, bool > | bsl::map::insert (BloombergLP::bslmf::MovableRef< value_type > value) |
template<class ALT_VALUE_TYPE > | |
enable_if< is_convertible < ALT_VALUE_TYPE, value_type > ::value, pair< iterator, bool > >::type | bsl::map::insert (BSLS_COMPILERFEATURES_FORWARD_REF(ALT_VALUE_TYPE) value) |
iterator | bsl::map::insert (const_iterator hint, const value_type &value) |
iterator | bsl::map::insert (const_iterator hint, BloombergLP::bslmf::MovableRef< value_type > value) |
template<class ALT_VALUE_TYPE > | |
enable_if< is_convertible < ALT_VALUE_TYPE, value_type > ::value, iterator >::type | bsl::map::insert (const_iterator hint, BSLS_COMPILERFEATURES_FORWARD_REF(ALT_VALUE_TYPE) value) |
template<class INPUT_ITERATOR > | |
void | bsl::map::insert (INPUT_ITERATOR first, INPUT_ITERATOR last) |
void | bsl::map::insert (std::initializer_list< value_type > values) |
template<class BDE_OTHER_TYPE > | |
pair< iterator, bool > | bsl::map::insert_or_assign (const KEY &key, BDE_OTHER_TYPE &&obj) |
template<class BDE_OTHER_TYPE > | |
pair< iterator, bool > | bsl::map::insert_or_assign (BloombergLP::bslmf::MovableRef< KEY > key, BDE_OTHER_TYPE &&obj) |
template<class BDE_OTHER_TYPE > | |
iterator | bsl::map::insert_or_assign (const_iterator hint, const KEY &key, BDE_OTHER_TYPE &&obj) |
template<class BDE_OTHER_TYPE > | |
iterator | bsl::map::insert_or_assign (const_iterator hint, BloombergLP::bslmf::MovableRef< KEY > key, BDE_OTHER_TYPE &&obj) |
template<class... Args> | |
pair< iterator, bool > | bsl::map::emplace (Args &&...args) |
template<class... Args> | |
iterator | bsl::map::emplace_hint (const_iterator hint, Args &&...args) |
iterator | bsl::map::erase (const_iterator position) |
iterator | bsl::map::erase (iterator position) |
size_type | bsl::map::erase (const key_type &key) |
iterator | bsl::map::erase (const_iterator first, const_iterator last) |
template<class... Args> | |
pair< iterator, bool > | bsl::map::try_emplace (BloombergLP::bslmf::MovableRef< KEY > key, Args &&...args) |
template<class... Args> | |
iterator | bsl::map::try_emplace (const_iterator hint, const KEY &key, Args &&...args) |
template<class... Args> | |
iterator | bsl::map::try_emplace (const_iterator hint, BloombergLP::bslmf::MovableRef< KEY > key, Args &&...args) |
void | bsl::map::clear () BSLS_KEYWORD_NOEXCEPT |
iterator | bsl::map::find (const key_type &key) |
template<class LOOKUP_KEY > | |
bsl::enable_if < BloombergLP::bslmf::IsTransparentPredicate < COMPARATOR, LOOKUP_KEY > ::value, iterator >::type | bsl::map::find (const LOOKUP_KEY &key) |
iterator | bsl::map::lower_bound (const key_type &key) |
template<class LOOKUP_KEY > | |
bsl::enable_if < BloombergLP::bslmf::IsTransparentPredicate < COMPARATOR, LOOKUP_KEY > ::value, iterator >::type | bsl::map::lower_bound (const LOOKUP_KEY &key) |
iterator | bsl::map::upper_bound (const key_type &key) |
template<class LOOKUP_KEY > | |
bsl::enable_if < BloombergLP::bslmf::IsTransparentPredicate < COMPARATOR, LOOKUP_KEY > ::value, iterator >::type | bsl::map::upper_bound (const LOOKUP_KEY &key) |
pair< iterator, iterator > | bsl::map::equal_range (const key_type &key) |
template<class LOOKUP_KEY > | |
bsl::enable_if < BloombergLP::bslmf::IsTransparentPredicate < COMPARATOR, LOOKUP_KEY > ::value, pair< iterator, iterator > >::type | bsl::map::equal_range (const LOOKUP_KEY &key) |
allocator_type | bsl::map::get_allocator () const BSLS_KEYWORD_NOEXCEPT |
const_iterator | bsl::map::begin () const BSLS_KEYWORD_NOEXCEPT |
const_iterator | bsl::map::end () const BSLS_KEYWORD_NOEXCEPT |
const_reverse_iterator | bsl::map::rbegin () const BSLS_KEYWORD_NOEXCEPT |
const_reverse_iterator | bsl::map::rend () const BSLS_KEYWORD_NOEXCEPT |
const_iterator | bsl::map::cbegin () const BSLS_KEYWORD_NOEXCEPT |
const_iterator | bsl::map::cend () const BSLS_KEYWORD_NOEXCEPT |
const_reverse_iterator | bsl::map::crbegin () const BSLS_KEYWORD_NOEXCEPT |
const_reverse_iterator | bsl::map::crend () const BSLS_KEYWORD_NOEXCEPT |
bool | bsl::map::contains (const key_type &key) const |
template<class LOOKUP_KEY > | |
bsl::enable_if < BloombergLP::bslmf::IsTransparentPredicate < COMPARATOR, LOOKUP_KEY > ::value, bool >::type | bsl::map::contains (const LOOKUP_KEY &key) const |
bool | bsl::map::empty () const BSLS_KEYWORD_NOEXCEPT |
size_type | bsl::map::size () const BSLS_KEYWORD_NOEXCEPT |
size_type | bsl::map::max_size () const BSLS_KEYWORD_NOEXCEPT |
add_lvalue_reference< const VALUE >::type | bsl::map::at (const key_type &key) const |
key_compare | bsl::map::key_comp () const |
value_compare | bsl::map::value_comp () const |
const_iterator | bsl::map::find (const key_type &key) const |
template<class LOOKUP_KEY > | |
bsl::enable_if < BloombergLP::bslmf::IsTransparentPredicate < COMPARATOR, LOOKUP_KEY > ::value, const_iterator > ::type | bsl::map::find (const LOOKUP_KEY &key) const |
size_type | bsl::map::count (const key_type &key) const |
template<class LOOKUP_KEY > | |
bsl::enable_if < BloombergLP::bslmf::IsTransparentPredicate < COMPARATOR, LOOKUP_KEY > ::value, size_type >::type | bsl::map::count (const LOOKUP_KEY &key) const |
const_iterator | bsl::map::lower_bound (const key_type &key) const |
template<class LOOKUP_KEY > | |
bsl::enable_if < BloombergLP::bslmf::IsTransparentPredicate < COMPARATOR, LOOKUP_KEY > ::value, const_iterator > ::type | bsl::map::lower_bound (const LOOKUP_KEY &key) const |
const_iterator | bsl::map::upper_bound (const key_type &key) const |
template<class LOOKUP_KEY > | |
bsl::enable_if < BloombergLP::bslmf::IsTransparentPredicate < COMPARATOR, LOOKUP_KEY > ::value, const_iterator > ::type | bsl::map::upper_bound (const LOOKUP_KEY &key) const |
pair< const_iterator, const_iterator > | bsl::map::equal_range (const key_type &key) const |
template<class LOOKUP_KEY > | |
bsl::enable_if < BloombergLP::bslmf::IsTransparentPredicate < COMPARATOR, LOOKUP_KEY > ::value, pair< const_iterator, const_iterator > >::type | bsl::map::equal_range (const LOOKUP_KEY &key) const |
template<class KEY , class VALUE , class COMPARATOR , class ALLOCATOR > | |
bool | bsl::operator== (const map< KEY, VALUE, COMPARATOR, ALLOCATOR > &lhs, const map< KEY, VALUE, COMPARATOR, ALLOCATOR > &rhs) |
template<class KEY , class VALUE , class COMPARATOR , class ALLOCATOR > | |
bool | bsl::operator!= (const map< KEY, VALUE, COMPARATOR, ALLOCATOR > &lhs, const map< KEY, VALUE, COMPARATOR, ALLOCATOR > &rhs) |
template<class KEY , class VALUE , class COMPARATOR , class ALLOCATOR > | |
bool | bsl::operator< (const map< KEY, VALUE, COMPARATOR, ALLOCATOR > &lhs, const map< KEY, VALUE, COMPARATOR, ALLOCATOR > &rhs) |
template<class KEY , class VALUE , class COMPARATOR , class ALLOCATOR > | |
bool | bsl::operator> (const map< KEY, VALUE, COMPARATOR, ALLOCATOR > &lhs, const map< KEY, VALUE, COMPARATOR, ALLOCATOR > &rhs) |
template<class KEY , class VALUE , class COMPARATOR , class ALLOCATOR > | |
bool | bsl::operator<= (const map< KEY, VALUE, COMPARATOR, ALLOCATOR > &lhs, const map< KEY, VALUE, COMPARATOR, ALLOCATOR > &rhs) |
template<class KEY , class VALUE , class COMPARATOR , class ALLOCATOR > | |
bool | bsl::operator>= (const map< KEY, VALUE, COMPARATOR, ALLOCATOR > &lhs, const map< KEY, VALUE, COMPARATOR, ALLOCATOR > &rhs) |
template<class KEY , class VALUE , class COMPARATOR , class ALLOCATOR , class PREDICATE > | |
map< KEY, VALUE, COMPARATOR, ALLOCATOR >::size_type | bsl::erase_if (map< KEY, VALUE, COMPARATOR, ALLOCATOR > &m, PREDICATE predicate) |
template<class KEY , class VALUE , class COMPARATOR , class ALLOCATOR > | |
void | bsl::swap (map< KEY, VALUE, COMPARATOR, ALLOCATOR > &a, map< KEY, VALUE, COMPARATOR, ALLOCATOR > &b) BSLS_KEYWORD_NOEXCEPT_SPECIFICATION(false) |
Variables | |
COMPARATOR | bsl::map::value_compare::comp |
void swap(map &other) BSLS_KEYWORD_NOEXCEPT_SPECIFICATION(AllocatorTraits pair< iterator, bool > | bsl::map::try_emplace (const KEY &key, Args &&...args) |
bsl::map | STL-compliant map template |
bsl::map
, implementing the standard container holding an ordered sequence of key-value pairs (having unique keys), and presenting a mapping from the keys (of a template parameter type, KEY
) to their associated values (of another template parameter type, VALUE
). map
is an allocator-aware, value-semantic type whose salient attributes are its size (number of key-value pairs) and the ordered sequence of key-value pairs the map contains. If map
is instantiated with either a key type or mapped-value type that is not itself value-semantic, then it will not retain all of its value-semantic qualities. In particular, if either the key or value type cannot be tested for equality, then a map
containing that type cannot be tested for equality. It is even possible to instantiate map
with a key or mapped-value type that does not have a copy constructor, in which case the map
will not be copyable. map
implemented here adheres to the C++11 standard when compiled with a C++11 compiler, and makes the best approximation when compiled with a C++03 compiler. In particular, for C++03 we emulate move semantics, but limit forwarding (in emplace
) to const
lvalues, and make no effort to emulate noexcept
or initializer-lists. map
is a fully Value-Semantic Type (see bsldoc_glossary
) only if the supplied KEY
and VALUE
template parameters are themselves fully value-semantic. It is possible to instantiate a map
with KEY
and VALUE
parameter arguments that do not provide a full set of value-semantic operations, but then some methods of the container may not be instantiable. The following terminology, adopted from the C++11 standard, is used in the function documentation of map
to describe a function's requirements for the KEY
and VALUE
template parameters. These terms are also defined in sections [utility.arg.requirements] and [container.requirements.general] of the C++11 standard. Note that, in the context of a map
instantiation, the requirements apply specifically to the map's entry type, value_type
, which is an alias for bsl::pair<const KEY, VALUE>
. Legend ------ 'X' - denotes an allocator-aware container type (e.g., 'map') 'T' - 'value_type' associated with 'X' 'A' - type of the allocator used by 'X' 'm' - lvalue of type 'A' (allocator) 'p', - address ('T *') of uninitialized storage for a 'T' within an 'X' 'rv' - rvalue of type (non-'const') 'T' 'v' - rvalue or lvalue of type (possibly 'const') 'T' 'args' - 0 or more arguments
T
has a default constructor. More precisely, T
is default-insertable
into X
means that the following expression is well-formed: allocator_traits<A>construct(m, p)
T
provides a constructor that takes an rvalue of type (non-'const') T
. More precisely, T
is move-insertable
into X
means that the following expression is well-formed: allocator_traits<A>construct(m, p, rv)
T
provides a constructor that takes an lvalue or rvalue of type (possibly const
) T
. More precisely, T
is copy-insertable
into X
means that the following expression is well-formed: allocator_traits<A>construct(m, p, v)
T
provides an assignment operator that takes an rvalue of type (non-'const') T
.T
provides an assignment operator that takes an lvalue or rvalue of type (possibly const
) T
.T
is emplace-constructible
into X
from args
means that the following expression is well-formed: allocator_traits<A>construct(m, p, args)
T
provides a destructor. More precisely, T
is erasable
from X
means that the following expression is well-formed: allocator_traits<A>destroy(m, p)
COMPARATOR
template parameter determines how that map will order elements. In particular, the COMPARATOR
type must induce a strict weak ordering on objects of type KEY
. The COMPARATOR
parameter defaults to std::less<KEY>
when not supplied in an instantiation of map
. Note that the COMPARATOR
type must be copy-constructible. COMPARATOR
functors be const
-qualified. However, there is a suggestion for C++17 that this is an oversight in the standard, and that const
-qualification will be required in the future. Keep this in mind when opting to use an alternative to the default COMPARATOR
. ALLOCATOR
template parameter determines how that map will allocate memory. The map
template supports allocators meeting the requirements of the C++11 standard [allocator.requirements]. In addition, map
supports scoped-allocators derived from the bslma::Allocator
memory allocation protocol. Clients intending to use bslma
-style allocators should use the template's default ALLOCATOR
type: The default type for the ALLOCATOR
template parameter, bsl::allocator
, provides a C++11 standard-compatible adapter for a bslma::Allocator
object. ALLOCATOR
of a map
instantiation' is bsl::allocator
, then objects of that map type will conform to the standard behavior of a bslma
-allocator-enabled type. Such a map accepts an optional bslma::Allocator
argument at construction. If the address of a bslma::Allocator
object is explicitly supplied at construction, it is used to supply memory for the map throughout its lifetime; otherwise, the map will use the default allocator installed at the time of the map's construction (see bslma_default
). In addition to directly allocating memory from the indicated bslma::Allocator
, a map supplies that allocator's address to the constructors of contained objects of the (template parameter) type KEY
and VALUE
, if respectively, the types define the bslma::UsesBslmaAllocator
trait. map
: Legend ------ 'K' - (template parameter) type 'KEY' of the map 'V' - (template parameter) type 'VALUE' of the map 'a', 'b' - two distinct objects of type 'map<K, V>' 'rv' - modifiable rvalue of type 'map<K, V>' 'n', 'm' - number of elements in 'a' and 'b', respectively 'value_type' - 'pair<const K, V>' 'c' - comparator providing an ordering for objects of type 'K' 'al - STL-style memory allocator 'i1', 'i2' - two iterators defining a sequence of 'value_type' objects 'k' - object of type 'K' 'v' - object of type 'V' 'vt' - object of type 'value_type' 'rvt' - modifiable rvalue of type 'value_type' 'p1', 'p2' - two 'const_iterator's belonging to 'a' distance(i1,i2) - number of elements in the range '[i1 .. i2)' +----------------------------------------------------+--------------------+ | Operation | Complexity | +====================================================+====================+ | map<K, V> a; (default construction) | O[1] | | map<K, V> a(al); | | | map<K, V> a(c, al); | | +----------------------------------------------------+--------------------+ | map<K, V> a(rv); (move construction) | O[1] if 'a' and | | map<K, V> a(rv, al); | 'rv' use the same | | | allocator, | | | O[n] otherwise | +----------------------------------------------------+--------------------+ | map<K, V> a(b); (copy construction) | O[n] | | map<K, V> a(b, al); | | +----------------------------------------------------+--------------------+ | map<K, V> a(i1, i2); | O[N] if [i1 .. i2) | | map<K, V> a(i1, i2, al); | is sorted with | | map<K, V> a(i1, i2, c, al); | 'a.value_comp()', | | | O[N * log(N)] | | | otherwise, where N | | | is distance(i1,i2) | +----------------------------------------------------+--------------------+ | a.~map<K, V>(); (destruction) | O[n] | +----------------------------------------------------+--------------------+ | a = rv; (move assignment) | O[1] if 'a' and | | | 'rv' use the same | | | allocator, | | | O[n] otherwise | +----------------------------------------------------+--------------------+ | a = b; (copy assignment) | O[n] | +----------------------------------------------------+--------------------+ | a.begin(), a.end(), a.cbegin(), a.cend(), | O[1] | | a.rbegin(), a.rend(), a.crbegin(), a.crend() | | +----------------------------------------------------+--------------------+ | a == b, a != b | O[n] | +----------------------------------------------------+--------------------+ | a < b, a <= b, a > b, a >= b | O[n] | +----------------------------------------------------+--------------------+ | a.swap(b), swap(a, b) | O[1] if 'a' and | | | 'b' use the same | | | allocator, | | | O[n + m] otherwise | +----------------------------------------------------+--------------------+ | a.size() | O[1] | +----------------------------------------------------+--------------------+ | a.max_size() | O[1] | +----------------------------------------------------+--------------------+ | a.empty() | O[1] | +----------------------------------------------------+--------------------+ | get_allocator() | O[1] | +----------------------------------------------------+--------------------+ | a[k] | O[log(n)] | +----------------------------------------------------+--------------------+ | a.at(k) | O[log(n)] | +----------------------------------------------------+--------------------+ | a.insert(vt) | O[log(n)] | | a.insert(rvt) | | | a.emplace(Args&&...) | | +----------------------------------------------------+--------------------+ | a.insert(p1, vt) | amortized constant | | a.insert(p1, rvt) | if the value is | | a.emplace(p1, Args&&...) | inserted right | | | before p1, | | | O[log(n)] | | | otherwise | +----------------------------------------------------+--------------------+ | a.insert(i1, i2) | O[log(N) * | | | distance(i1,i2)] | | | | | | where N is | | | n + distance(i1,i2)| +----------------------------------------------------+--------------------+ | a.erase(p1) | amortized constant | +----------------------------------------------------+--------------------+ | a.erase(k) | O[log(n) + | | | a.count(k)] | +----------------------------------------------------+--------------------+ | a.erase(p1, p2) | O[log(n) + | | | distance(p1, p2)] | +----------------------------------------------------+--------------------+ | a.erase(p1, p2) | O[log(n) + | | | distance(p1, p2)] | +----------------------------------------------------+--------------------+ | a.clear() | O[n] | +----------------------------------------------------+--------------------+ | a.contains(k) | O[log(n)] | +----------------------------------------------------+--------------------+ | a.key_comp() | O[1] | +----------------------------------------------------+--------------------+ | a.value_comp() | O[1] | +----------------------------------------------------+--------------------+ | a.find(k) | O[log(n)] | +----------------------------------------------------+--------------------+ | a.count(k) | O[log(n) + | | | a.count(k)] | +----------------------------------------------------+--------------------+ | a.lower_bound(k) | O[log(n)] | +----------------------------------------------------+--------------------+ | a.upper_bound(k) | O[log(n)] | +----------------------------------------------------+--------------------+ | a.equal_range(k) | O[log(n)] | +----------------------------------------------------+--------------------+
bsl::map
to define and implement a class, TradeMatcher
, that provides a simple trade matching system for a single stock. The manipulators of TradeMatcher
will allow clients to place buy orders and sell orders, and the accessors of TradeMatcher
will allow clients to retrieve active orders and past executions. TradeMatcher
: class TradeMatcher { // This class provides a mechanism that characterizes a simple trade // matching system for one stock. An object of this class allows // clients to place orders and view the active orders.
SellOrdersMap
and BuyOrdersMap
, for two bsl::map
instantiations that maps the price of an order (type double
) to the quantity of the order (type int
). SellOrdersMap
uses the default bsl::less
comparator to store the sequence of sell orders in ascending price order. BuyOrdersMap
uses the bsl::greater
comparator to store the sequence of buy orders in descending price order. Also note that we use the default ALLOCATOR
template parameter for both aliases as we intend to provide memory with bslma
-style allocators: // PRIVATE TYPES typedef bsl::map<double, int> SellOrdersMap; // This 'typedef' is an alias for a mapping between the price and // quantity of an order in ascending price order. typedef bsl::map<double, int, std::greater<double> > BuyOrdersMap; // This 'typedef' is an alias for a mapping between the price and // quantity of an order in descending price order. // DATA SellOrdersMap d_sellOrders; // current sell orders BuyOrdersMap d_buyOrders; // current buy orders private: // NOT IMPLEMENTED TradeMatcher& operator=(const TradeMatcher&); TradeMatcher(const TradeMatcher&); public: // PUBLIC TYPES typedef SellOrdersMap::const_iterator SellOrdersConstIterator; // This 'typedef' provides an alias for the type of an iterator // providing non-modifiable access to sell orders in a // 'TradeMatcher'. typedef BuyOrdersMap::const_iterator BuyOrdersConstIterator; // This 'typedef' provides an alias for the type of an iterator // providing non-modifiable access to buy orders in a // 'TradeMatcher'. // CREATORS TradeMatcher(bslma::Allocator *basicAllocator = 0); // Create an empty 'TradeMatcher' object. Optionally specify a // 'basicAllocator' used to supply memory. If 'basicAllocator' is // 0, the currently installed default allocator is used. // Destroy this object. // MANIPULATORS void placeBuyOrder(double price, int numShares); // Place an order to buy the specified 'numShares' at the specified // 'price'. The placed buy order will (possibly partially) execute // when active sale orders exist in the system at or below 'price'. // The behavior is undefined unless '0 < price' and '0 < // numShares'. void placeSellOrder(double price, int numShares); // Place an order to sell the specified 'numShares' at the // specified 'price'. The placed sell order will (possibly // partially) execute when active buy orders exist in the system at // or above 'price'. The behavior is undefined unless '0 < price' // and '0 < numShares'. // ACCESSORS SellOrdersConstIterator beginSellOrders() const; // Return an iterator providing non-modifiable access to the active // sell order at the lowest price in the ordered sequence (from low // price to high price) of sell orders maintained by this object. SellOrdersConstIterator endSellOrders() const; // Return an iterator providing non-modifiable access to the // past-the-end sell order in the ordered sequence (from low price // to high price) of sell orders maintained by this object. BuyOrdersConstIterator beginBuyOrders() const; // Return an iterator providing non-modifiable access to the active // buy order at the highest price in the ordered sequence (from // high price to low price) of buy orders maintained by this // object. BuyOrdersConstIterator endBuyOrders() const; // Return an iterator providing non-modifiable access to the // past-the-end buy order in the ordered sequence (from high price // to low price) of buy orders maintained by this object. };
TradeMatcher
class: // CREATORS TradeMatcher::TradeMatcher(bslma::Allocator *basicAllocator) : d_sellOrders(basicAllocator) , d_buyOrders(basicAllocator) { }
bsl::map
objects the bsl::Allocator
supplied at construction'. // MANIPULATORS void TradeMatcher::placeBuyOrder(double price, int numShares) { BSLS_ASSERT(0 < price); BSLS_ASSERT(0 < numShares); // Buy shares from sellers from the one with the lowest price up to but // not including the first seller with a price greater than the // specified 'price'. SellOrdersMap::iterator itr = d_sellOrders.begin(); while (numShares && itr != d_sellOrders.upper_bound(price)) { if (itr->second > numShares) { itr->second -= numShares; numShares = 0; break; } itr = d_sellOrders.erase(itr); numShares -= itr->second; } if (numShares > 0) { d_buyOrders[price] += numShares; } } void TradeMatcher::placeSellOrder(double price, int numShares) { BSLS_ASSERT(0 < price); BSLS_ASSERT(0 < numShares); // Sell shares to buyers from the one with the highest price up to but // not including the first buyer with a price smaller than the // specified 'price'. BuyOrdersMap::iterator itr = d_buyOrders.begin(); while (numShares && itr != d_buyOrders.upper_bound(price)) { if (itr->second > numShares) { itr->second -= numShares; numShares = 0; break; } itr = d_buyOrders.erase(itr); numShares -= itr->second; } if (numShares > 0) { d_sellOrders[price] += numShares; } } // ACCESSORS TradeMatcher::SellOrdersConstIterator TradeMatcher::beginSellOrders() const { return d_sellOrders.begin(); } TradeMatcher::SellOrdersConstIterator TradeMatcher::endSellOrders() const { return d_sellOrders.end(); } TradeMatcher::BuyOrdersConstIterator TradeMatcher::beginBuyOrders() const { return d_buyOrders.begin(); } TradeMatcher::BuyOrdersConstIterator TradeMatcher::endBuyOrders() const { return d_buyOrders.end(); }
typedef KEY bsl::map< KEY, VALUE, COMPARATOR, ALLOCATOR >::key_type [inherited] |
typedef VALUE bsl::map< KEY, VALUE, COMPARATOR, ALLOCATOR >::mapped_type [inherited] |
typedef pair<const KEY, VALUE> bsl::map< KEY, VALUE, COMPARATOR, ALLOCATOR >::value_type [inherited] |
typedef COMPARATOR bsl::map< KEY, VALUE, COMPARATOR, ALLOCATOR >::key_compare [inherited] |
typedef ALLOCATOR bsl::map< KEY, VALUE, COMPARATOR, ALLOCATOR >::allocator_type [inherited] |
typedef value_type& bsl::map< KEY, VALUE, COMPARATOR, ALLOCATOR >::reference [inherited] |
typedef const value_type& bsl::map< KEY, VALUE, COMPARATOR, ALLOCATOR >::const_reference [inherited] |
typedef AllocatorTraits::size_type bsl::map< KEY, VALUE, COMPARATOR, ALLOCATOR >::size_type [inherited] |
typedef AllocatorTraits::difference_type bsl::map< KEY, VALUE, COMPARATOR, ALLOCATOR >::difference_type [inherited] |
typedef AllocatorTraits::pointer bsl::map< KEY, VALUE, COMPARATOR, ALLOCATOR >::pointer [inherited] |
typedef AllocatorTraits::const_pointer bsl::map< KEY, VALUE, COMPARATOR, ALLOCATOR >::const_pointer [inherited] |
typedef BloombergLP::bslstl::TreeIterator< value_type, Node, difference_type> bsl::map< KEY, VALUE, COMPARATOR, ALLOCATOR >::iterator [inherited] |
typedef BloombergLP::bslstl::TreeIterator< const value_type, Node, difference_type> bsl::map< KEY, VALUE, COMPARATOR, ALLOCATOR >::const_iterator [inherited] |
typedef bsl::reverse_iterator<iterator> bsl::map< KEY, VALUE, COMPARATOR, ALLOCATOR >::reverse_iterator [inherited] |
typedef bsl::reverse_iterator<const_iterator> bsl::map< KEY, VALUE, COMPARATOR, ALLOCATOR >::const_reverse_iterator [inherited] |
typedef bool bsl::map< KEY, VALUE, COMPARATOR, ALLOCATOR >::value_compare::result_type [inherited] |
typedef value_type bsl::map< KEY, VALUE, COMPARATOR, ALLOCATOR >::value_compare::first_argument_type [inherited] |
typedef value_type bsl::map< KEY, VALUE, COMPARATOR, ALLOCATOR >::value_compare::second_argument_type [inherited] |
bsl::map< KEY, VALUE, COMPARATOR, ALLOCATOR >::DataWrapper::DataWrapper | ( | const COMPARATOR & | comparator, | |
const ALLOCATOR & | basicAllocator | |||
) | [inherited] |
Create a data wrapper using a copy of the specified comparator
to order key-value pairs and a copy of the specified basicAllocator
to supply memory.
bsl::map< KEY, VALUE, COMPARATOR, ALLOCATOR >::DataWrapper::DataWrapper | ( | BloombergLP::bslmf::MovableRef< DataWrapper > | original | ) | [inherited] |
IMPLICIT: Create a data wrapper initialized to the contents of the pool
associated with the specified original
data wrapper. The comparator and allocator associated with original
are propagated to the new data wrapper. original
is left in a valid but unspecified state.
NodeFactory& bsl::map< KEY, VALUE, COMPARATOR, ALLOCATOR >::DataWrapper::nodeFactory | ( | ) | [inherited] |
Return a reference providing modifiable access to the node factory associated with this data wrapper.
const NodeFactory& bsl::map< KEY, VALUE, COMPARATOR, ALLOCATOR >::DataWrapper::nodeFactory | ( | ) | const [inherited] |
Return a reference providing non-modifiable access to the node factory associated with this data wrapper.
bsl::map< KEY, VALUE, COMPARATOR, ALLOCATOR >::value_compare::value_compare | ( | COMPARATOR | comparator | ) | [protected, inherited] |
IMPLICIT: Create a value_compare
object that uses the specified comparator
.
bsl::map< KEY, VALUE, COMPARATOR, ALLOCATOR >::value_compare::value_compare | ( | const value_compare & | original | ) | [inherited] |
Create a value_compare
object having the same value as the specified original
object.
bsl::map< KEY, VALUE, COMPARATOR, ALLOCATOR >::value_compare::~value_compare | ( | ) | [inherited] |
Destroy this object.
value_compare& bsl::map< KEY, VALUE, COMPARATOR, ALLOCATOR >::value_compare::operator= | ( | const value_compare & | rhs | ) | [inherited] |
Assign to this object the value of the specified rhs
object, and return a reference providing modifiable access to this object.
bool bsl::map< KEY, VALUE, COMPARATOR, ALLOCATOR >::value_compare::operator() | ( | const value_type & | x, | |
const value_type & | y | |||
) | const [inherited] |
Return true
if the specified x
object is ordered before the specified y
object, as determined by the comparator supplied at construction, and false
otherwise.
bsl::map< KEY, VALUE, COMPARATOR, ALLOCATOR >::map | ( | ) | [inherited] |
bsl::map< KEY, VALUE, COMPARATOR, ALLOCATOR >::map | ( | const COMPARATOR & | comparator, | |
const ALLOCATOR & | basicAllocator = ALLOCATOR() | |||
) | [inline, explicit, inherited] |
basicAllocator | Create an empty map. Optionally specify a comparator used to order key-value pairs contained in this object. If comparator is not supplied, a default-constructed object of the (template parameter) type COMPARATOR is used. Optionally specify a basicAllocator used to supply memory. If basicAllocator is not supplied, a default-constructed object of the (template parameter) type ALLOCATOR is used. If the type ALLOCATOR is bsl::allocator (the default), then basicAllocator , if supplied, shall be convertible to bslma::Allocator * . If the type ALLOCATOR is bsl::allocator and basicAllocator is not supplied, the currently installed default allocator is used. |
bsl::map< KEY, VALUE, COMPARATOR, ALLOCATOR >::map | ( | const ALLOCATOR & | basicAllocator | ) | [explicit, inherited] |
Create an empty map that uses the specified basicAllocator
to supply memory. Use a default-constructed object of the (template parameter) type COMPARATOR
to order the key-value pairs contained in this map. Note that a bslma::Allocator *
can be supplied for basicAllocator
if the (template parameter) ALLOCATOR
is bsl::allocator
(the default).
bsl::map< KEY, VALUE, COMPARATOR, ALLOCATOR >::map | ( | const map< KEY, VALUE, COMPARATOR, ALLOCATOR > & | original | ) | [inherited] |
Create a map having the same value as the specified original
object. Use a copy of original.key_comp()
to order the key-value pairs contained in this map. Use the allocator returned by 'bslallocator_traits<ALLOCATOR>:: select_on_container_copy_construction(original.get_allocator())' to allocate memory. If the (template parameter) type ALLOCATOR
is bsl::allocator
(the default), the currently installed default allocator is used. This method requires that the (template parameter) types KEY
and VALUE
both be copy-insertable
into this map (see Requirements on KEY
and VALUE
).
bsl::map< KEY, VALUE, COMPARATOR, ALLOCATOR >::map | ( | BloombergLP::bslmf::MovableRef< map< KEY, VALUE, COMPARATOR, ALLOCATOR > > | original | ) | [inherited] |
IMPLICIT: Create a map having the same value as the specified original
object by moving (in constant time) the contents of original
to the new map. Use a copy of original.key_comp()
to order the key-value pairs contained in this map. The allocator associated with original
is propagated for use in the newly-created map. original
is left in a valid but unspecified state.
bsl::map< KEY, VALUE, COMPARATOR, ALLOCATOR >::map | ( | const map< KEY, VALUE, COMPARATOR, ALLOCATOR > & | original, | |
const typename type_identity< ALLOCATOR >::type & | basicAllocator | |||
) | [inherited] |
Create a map having the same value as the specified original
object that uses the specified basicAllocator
to supply memory. Use a copy of original.key_comp()
to order the key-value pairs contained in this map. This method requires that the (template parameter) types KEY
and VALUE
both be copy-insertable
into this map (see Requirements on KEY
and VALUE
). Note that a bslma::Allocator *
can be supplied for basicAllocator
if the (template parameter) ALLOCATOR
is bsl::allocator
(the default).
bsl::map< KEY, VALUE, COMPARATOR, ALLOCATOR >::map | ( | BloombergLP::bslmf::MovableRef< map< KEY, VALUE, COMPARATOR, ALLOCATOR > > | original, | |
const typename type_identity< ALLOCATOR >::type & | basicAllocator | |||
) | [inherited] |
Create a map having the same value as the specified original
object that uses the specified basicAllocator
to supply memory. The contents of original
are moved (in constant time) to the new map if basicAllocator == original.get_allocator()
, and are move- inserted (in linear time) using basicAllocator
otherwise. original
is left in a valid but unspecified state. Use a copy of original.key_comp()
to order the key-value pairs contained in this map. This method requires that the (template parameter) types KEY
and VALUE
both be move-insertable
into this map (see Requirements on KEY
and VALUE
). Note that a bslma::Allocator *
can be supplied for basicAllocator
if the (template parameter) ALLOCATOR
is bsl::allocator
(the default).
bsl::map< KEY, VALUE, COMPARATOR, ALLOCATOR >::map | ( | INPUT_ITERATOR | first, | |
INPUT_ITERATOR | last, | |||
const COMPARATOR & | comparator = COMPARATOR() , |
|||
const ALLOCATOR & | basicAllocator = ALLOCATOR() | |||
) | [inherited] |
bsl::map< KEY, VALUE, COMPARATOR, ALLOCATOR >::map | ( | INPUT_ITERATOR | first, | |
INPUT_ITERATOR | last, | |||
const ALLOCATOR & | basicAllocator | |||
) | [inherited] |
Create a map, and insert each value_type
object in the sequence starting at the specified first
element, and ending immediately before the specified last
element, ignoring those objects having a key equivalent to that which appears earlier in the sequence. Optionally specify a comparator
used to order key-value pairs contained in this object. If comparator
is not supplied, a default-constructed object of the (template parameter) type COMPARATOR
is used. Optionally specify a basicAllocator
used to supply memory. If basicAllocator
is not supplied, a default-constructed object of the (template parameter) type ALLOCATOR
is used. If the type ALLOCATOR
is bsl::allocator
(the default), then basicAllocator
, if supplied, shall be convertible to bslma::Allocator *
. If the type ALLOCATOR
is bsl::allocator
and basicAllocator
is not supplied, the currently installed default allocator is used. If the sequence first
to last
is ordered according to comparator
, then this operation has O[N]
complexity, where N
is the number of elements between first
and last
; otherwise, this operation has O[N * log(N)]
complexity. The (template parameter) type INPUT_ITERATOR
shall meet the requirements of an input iterator defined in the C++11 standard [input.iterators] providing access to values of a type convertible to value_type
, and value_type
must be emplace-constructible
from *i
into this map, where i
is a dereferenceable iterator in the range [first .. last)
(see Requirements on KEY
and VALUE
). The behavior is undefined unless first
and last
refer to a sequence of valid values where first
is at a position at or before last
.
bsl::map< KEY, VALUE, COMPARATOR, ALLOCATOR >::map | ( | std::initializer_list< value_type > | values, | |
const COMPARATOR & | comparator = COMPARATOR() , |
|||
const ALLOCATOR & | basicAllocator = ALLOCATOR() | |||
) | [inherited] |
bsl::map< KEY, VALUE, COMPARATOR, ALLOCATOR >::map | ( | std::initializer_list< value_type > | values, | |
const ALLOCATOR & | basicAllocator | |||
) | [inherited] |
Create a map and insert each value_type
object in the specified values
initializer list, ignoring those objects having a key equivalent to that which appears earlier in the list. Optionally specify a comparator
used to order keys contained in this object. If comparator
is not supplied, a default-constructed object of the (template parameter) type COMPARATOR
is used. Optionally specify a basicAllocator
used to supply memory. If basicAllocator
is not supplied, a default-constructed object of the (template parameter) type ALLOCATOR
is used. If the type ALLOCATOR
is bsl::allocator
(the default), then basicAllocator
, if supplied, shall be convertible to bslma::Allocator *
. If the type ALLOCATOR
is bsl::allocator
and basicAllocator
is not supplied, the currently installed default allocator is used. If values
is ordered according to comparator
, then this operation has O[N]
complexity, where N
is the number of elements in values
; otherwise, this operation has O[N * log(N)]
complexity. This method requires that the (template parameter) types KEY
and VALUE
both be copy-insertable
into this map (see Requirements on KEY
and VALUE
).
bsl::map< KEY, VALUE, COMPARATOR, ALLOCATOR >::~map | ( | ) | [inherited] |
Destroy this object.
map& bsl::map< KEY, VALUE, COMPARATOR, ALLOCATOR >::operator= | ( | const map< KEY, VALUE, COMPARATOR, ALLOCATOR > & | rhs | ) | [inherited] |
Assign to this object the value and comparator of the specified rhs
object, propagate to this object the allocator of rhs
if the ALLOCATOR
type has trait propagate_on_container_copy_assignment
, and return a reference providing modifiable access to this object. If an exception is thrown, *this
is left in a valid but unspecified state. This method requires that the (template parameter) types KEY
and VALUE
both be copy-assignable
and copy-insertable
into this map (see Requirements on KEY
and VALUE
).
map& operator= (BloombergLP::bslmf::MovableRef<map> rhs) BSLS_KEYWORD_NOEXCEPT_SPECIFICATION( AllocatorTraits map& bsl::map< KEY, VALUE, COMPARATOR, ALLOCATOR >::operator= | ( | std::initializer_list< value_type > | values | ) | [inherited] |
< Assign to this object the value and comparator of the specified rhs
object, propagate to this object the allocator of rhs
if the ALLOCATOR
type has trait propagate_on_container_move_assignment
, and return a reference providing modifiable access to this object. The contents of rhs
are moved (in constant time) to this map if get_allocator() == rhs.get_allocator()
(after accounting for the aforementioned trait); otherwise, all elements in this map are either destroyed or move-assigned to and each additional element in rhs
is move-inserted into this map. rhs
is left in a valid but unspecified state, and if an exception is thrown, *this
is left in a valid but unspecified state. This method requires that the (template parameter) types KEY
and VALUE
both be move-assignable
and move-insertable
into this map (see Requirements on KEY
and VALUE
). Assign to this object the value resulting from first clearing this map and then inserting each value_type
object in the specified values
initializer list, ignoring those objects having a key equivalent to that which appears earlier in the list; return a reference providing modifiable access to this object. This method requires that the (template parameter) types KEY
and VALUE
both be copy-insertable
into this map (see Requirements on KEY
and VALUE
).
add_lvalue_reference<VALUE>::type bsl::map< KEY, VALUE, COMPARATOR, ALLOCATOR >::operator[] | ( | const key_type & | key | ) | [inherited] |
Return a reference providing modifiable access to the mapped-value associated with the specified key
; if this map
does not already contain a value_type
object having an equivalent key, first insert a new value_type
object having key
and a default-constructed VALUE
object, and return a reference to the newly mapped (default) value. This method requires that the (template parameter) type KEY
be copy-insertable
into this map and the (template parameter) type VALUE
be default-insertable
into this map (see Requirements on KEY
and VALUE
).
add_lvalue_reference<VALUE>::type bsl::map< KEY, VALUE, COMPARATOR, ALLOCATOR >::operator[] | ( | BloombergLP::bslmf::MovableRef< key_type > | key | ) | [inherited] |
Return a reference providing modifiable access to the mapped-value associated with the specified key
; if this map
does not already contain a value_type
object having an equivalent key, first insert a new value_type
object having the move-inserted key
and a default-constructed VALUE
object, and return a reference to the newly mapped (default) value. This method requires that the (template parameter) type KEY
be move-insertable
into this map and the (template parameter) type VALUE
be default-insertable
into this map (see Requirements on KEY
and VALUE
).
add_lvalue_reference<VALUE>::type bsl::map< KEY, VALUE, COMPARATOR, ALLOCATOR >::at | ( | const key_type & | key | ) | [inherited] |
Return a reference providing modifiable access to the mapped-value associated with the specified key
, if such an entry exists; otherwise, throw a std::out_of_range
exception. Note that this method may also throw a different kind of exception if the (user-supplied) comparator throws.
iterator bsl::map< KEY, VALUE, COMPARATOR, ALLOCATOR >::begin | ( | ) | [inherited] |
Return an iterator providing modifiable access to the first value_type
object in the ordered sequence of value_type
objects maintained by this map, or the end
iterator if this map is empty.
iterator bsl::map< KEY, VALUE, COMPARATOR, ALLOCATOR >::end | ( | ) | [inherited] |
Return an iterator providing modifiable access to the past-the-end element in the ordered sequence of value_type
objects maintained by this map.
Referenced by bsl::map< bsl::string, ControlManager_Entry, CaselessLessThan >::contains(), bsl::map< bsl::string, ControlManager_Entry, CaselessLessThan >::count(), and bsl::map< bsl::string, ControlManager_Entry, CaselessLessThan >::equal_range().
reverse_iterator bsl::map< KEY, VALUE, COMPARATOR, ALLOCATOR >::rbegin | ( | ) | [inherited] |
Return a reverse iterator providing modifiable access to the last value_type
object in the ordered sequence of value_type
objects maintained by this map, or rend
if this map is empty.
reverse_iterator bsl::map< KEY, VALUE, COMPARATOR, ALLOCATOR >::rend | ( | ) | [inherited] |
Return a reverse iterator providing modifiable access to the prior-to-the-beginning element in the ordered sequence of value_type
objects maintained by this map.
pair<iterator, bool> bsl::map< KEY, VALUE, COMPARATOR, ALLOCATOR >::insert | ( | const value_type & | value | ) | [inherited] |
Insert the specified value
into this map if a key (the first
element) equivalent to that of value
does not already exist in this map; otherwise, if a value_type
object whose key is equivalent to that of value
already exists in this map, this method has no effect. Return a pair whose first
member is an iterator referring to the (possibly newly inserted) value_type
object in this map whose key is equivalent to that of value
, and whose second
member is true
if a new value was inserted, and false
if the key was already present. This method requires that the (template parameter) types KEY
and VALUE
both be copy-insertable
into this map (see Requirements on KEY
and VALUE
).
pair<iterator, bool> bsl::map< KEY, VALUE, COMPARATOR, ALLOCATOR >::insert | ( | BloombergLP::bslmf::MovableRef< value_type > | value | ) | [inherited] |
Insert into this map the specified value
if a key (the first
element) equivalent to that of value
does not already exist in this map; otherwise, this method has no effect. Return a pair whose first
member is an iterator referring to the (possibly newly inserted) value_type
object in this map whose key is equivalent to that of value
, and whose second
member is true
if a new value was inserted and false
if the key was already present. This method requires that the (template parameter) types KEY
and VALUE
both be move-insertable
into this map (see Requirements on KEY
and VALUE
).
enable_if<is_convertible<ALT_VALUE_TYPE, value_type>::value, pair<iterator, bool> >::type bsl::map< KEY, VALUE, COMPARATOR, ALLOCATOR >::insert | ( | BSLS_COMPILERFEATURES_FORWARD_REF(ALT_VALUE_TYPE) | value | ) | [inline, inherited] |
value | Insert into this map a value_type object created from the specified value if a key (the first element) equivalent to that of such an object does not already exist in this map; otherwise, this method has no effect (other than possibly creating a temporary value_type object). Return a pair whose first member is an iterator referring to the (possibly newly inserted) value_type object in this map whose key is equivalent to that of the object created from value , and whose second member is true if a new value was inserted and false if the key was already present. This method requires that the (template parameter) types KEY and VALUE both be move-insertable into this map (see Requirements on KEY and VALUE ), and the value_type be constructible from the (template parameter) ALT_VALUE_TYPE . |
iterator bsl::map< KEY, VALUE, COMPARATOR, ALLOCATOR >::insert | ( | const_iterator | hint, | |
const value_type & | value | |||
) | [inherited] |
Insert the specified value
into this map (in amortized constant time if the specified hint
is a valid immediate successor to the key of value
) if a key (the first
element) equivalent to that of value
does not already exist in this map; otherwise, if a value_type
object whose key is equivalent to that of value
already exists in this map, this method has no effect. Return an iterator referring to the (possibly newly inserted) value_type
object in this map whose key is equivalent to that of value
. If hint
is not a valid immediate successor to the key of value
, this operation has O[log(N)]
complexity, where N
is the size of this map. This method requires that the (template parameter) types KEY
and VALUE
both be copy-insertable
into this map (see Requirements on KEY
and VALUE
). The behavior is undefined unless hint
is an iterator in the range [begin() .. end()]
(both endpoints included).
iterator bsl::map< KEY, VALUE, COMPARATOR, ALLOCATOR >::insert | ( | const_iterator | hint, | |
BloombergLP::bslmf::MovableRef< value_type > | value | |||
) | [inherited] |
Insert into this map the specified value
(in amortized constant time if the specified hint
is a valid immediate successor to value
) if a key (the first
element) equivalent to that of value
does not already exist in this map; otherwise, this method has no effect. Return an iterator referring to the (possibly newly inserted) value_type
object in this map whose key is equivalent to that of value
. If hint
is not a valid immediate successor to value
, this operation has O[log(N)]
complexity, where N
is the size of this map. This method requires that the (template parameter) types KEY
and VALUE
both be move-insertable
into this map (see Requirements on KEY
and VALUE
). The behavior is undefined unless hint
is an iterator in the range [begin() .. end()]
(both endpoints included).
enable_if<is_convertible<ALT_VALUE_TYPE, value_type>::value, iterator>::type bsl::map< KEY, VALUE, COMPARATOR, ALLOCATOR >::insert | ( | const_iterator | hint, | |
BSLS_COMPILERFEATURES_FORWARD_REF(ALT_VALUE_TYPE) | value | |||
) | [inline, inherited] |
value | Insert into this map a value_type object created from the specified value (in amortized constant time if the specified hint is a valid immediate successor to the object created from value ) if a key (the first element) equivalent to such an object does not already exist in this map; otherwise, this method has no effect (other than possibly creating a temporary value_type object). Return an iterator referring to the (possibly newly inserted) value_type object in this map whose key is equivalent to that of the object created from value . If hint is not a valid immediate successor to the object created from value , this operation has O[log(N)] complexity, where N is the size of this map. This method requires that the (template parameter) types KEY and VALUE both be move-insertable into this map (see Requirements on KEY and VALUE ), and the value_type be constructible from the (template parameter) ALT_VALUE_TYPE . The behavior is undefined unless hint is an iterator in the range [begin() .. end()] (both endpoints included). |
void bsl::map< KEY, VALUE, COMPARATOR, ALLOCATOR >::insert | ( | INPUT_ITERATOR | first, | |
INPUT_ITERATOR | last | |||
) | [inherited] |
Insert into this map the value of each value_type
object in the range starting at the specified first
iterator and ending immediately before the specified last
iterator, if a key equivalent to that of the object is not already contained in this map. The (template parameter) type INPUT_ITERATOR
shall meet the requirements of an input iterator defined in the C++11 standard [input.iterators] providing access to values of a type convertible to value_type
, and value_type
must be emplace-constructible
from *i
into this map, where i
is a dereferenceable iterator in the range [first .. last)
(see Requirements on KEY
and VALUE
). The behavior is undefined unless first
and last
refer to a sequence of valid values where first
is at a position at or before last
.
void bsl::map< KEY, VALUE, COMPARATOR, ALLOCATOR >::insert | ( | std::initializer_list< value_type > | values | ) | [inherited] |
Insert into this map the value of each value_type
object in the specified values
initializer list if a key equivalent to that of the object is not already contained in this map. This method requires that the (template parameter) types KEY
and VALUE
both be copy-insertable
into this map (see Requirements on KEY
and VALUE
).
pair<iterator, bool> bsl::map< KEY, VALUE, COMPARATOR, ALLOCATOR >::insert_or_assign | ( | const KEY & | key, | |
BDE_OTHER_TYPE && | obj | |||
) | [inherited] |
If a key equivalent to the specified key
already exists in this map, assign the specified obj
to the value associated with that key, and return a pair containing an iterator referring to the existing item and false
. Otherwise, insert into this map a newly-created value_type
object, constructed from (key, std::forward<BDE_OTHER_TYPE>(obj)...))
, and return a pair containing an iterator referring to the newly-created entry and true
.
pair<iterator, bool> bsl::map< KEY, VALUE, COMPARATOR, ALLOCATOR >::insert_or_assign | ( | BloombergLP::bslmf::MovableRef< KEY > | key, | |
BDE_OTHER_TYPE && | obj | |||
) | [inherited] |
If a key equivalent to the specified key
already exists in this map, assign the specified obj
to the value associated with that key, and return a pair containing an iterator referring to the existing item and false
. Otherwise, insert into this map a newly-created value_type
object, constructed from (std::forward<KEY>(key), std::forward<BDE_OTHER_TYPE>(obj)...))
, and return a pair containing an iterator referring to the newly-created entry and true
.
iterator bsl::map< KEY, VALUE, COMPARATOR, ALLOCATOR >::insert_or_assign | ( | const_iterator | hint, | |
const KEY & | key, | |||
BDE_OTHER_TYPE && | obj | |||
) | [inherited] |
If a key equivalent to the specified key
already exists in this map, assign the specified obj
to the value associated with that key, and return an iterator referring to the existing item. Otherwise, insert into this map a newly-created value_type
object, constructed from (key, std::forward<BDE_OTHER_TYPE>(obj)...))
, and return an iterator referring to the newly-created entry. Use the specified hint
as a starting point for checking to see if the key is already in the map.
iterator bsl::map< KEY, VALUE, COMPARATOR, ALLOCATOR >::insert_or_assign | ( | const_iterator | hint, | |
BloombergLP::bslmf::MovableRef< KEY > | key, | |||
BDE_OTHER_TYPE && | obj | |||
) | [inherited] |
If a key equivalent to the specified key
already exists in this _map, assign the specified obj
to the value associated with that key, and return an iterator referring to the existing item. Otherwise, insert into this map a newly-created value_type
object constructed from (std::forward<KEY>(key), std::forward<BDE_OTHER_TYPE>(obj)...))
, and return an iterator referring to the newly-created entry. Use the specified hint
as a starting point for checking to see if the key already in the map.
pair<iterator, bool> bsl::map< KEY, VALUE, COMPARATOR, ALLOCATOR >::emplace | ( | Args &&... | args | ) | [inherited] |
Insert into this map 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
, if a key equivalent to such a value does not already exist in this map; otherwise, this method has no effect (other than possibly creating a temporary value_type
object). Return a pair whose first
member is an iterator referring to the (possibly newly created and inserted) object in this map whose key is equivalent to that of an object constructed from args
, and whose second
member is true
if a new value was inserted, and false
if an equivalent key was already present. This method requires that the (template parameter) types KEY
and VALUE
both be emplace-constructible
from args
(see Requirements on KEY
and VALUE
).
Referenced by bsl::map< bsl::string, ControlManager_Entry, CaselessLessThan >::insert().
iterator bsl::map< KEY, VALUE, COMPARATOR, ALLOCATOR >::emplace_hint | ( | const_iterator | hint, | |
Args &&... | args | |||
) | [inherited] |
Insert into this map 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
(in amortized constant time if the specified hint
is a valid immediate successor to the value_type
object constructed from args
), if a key equivalent to such a value does not already exist in this map; otherwise, this method has no effect (other than possibly creating a temporary value_type
object). Return an iterator referring to the (possibly newly created and inserted) object in this map whose key is equivalent to that of an object constructed from args
. If hint
is not a valid immediate successor to the value_type
object implied by args
, this operation has O[log(N)]
complexity where N
is the size of this map. This method requires that the (template parameter) types KEY
and VALUE
both be emplace-constructible
from args
(see Requirements on KEY
and VALUE
). The behavior is undefined unless hint
is an iterator in the range [begin() .. end()]
(both endpoints included).
Referenced by bsl::map< bsl::string, ControlManager_Entry, CaselessLessThan >::insert().
iterator bsl::map< KEY, VALUE, COMPARATOR, ALLOCATOR >::erase | ( | const_iterator | position | ) | [inherited] |
iterator bsl::map< KEY, VALUE, COMPARATOR, ALLOCATOR >::erase | ( | iterator | position | ) | [inherited] |
Remove from this map the value_type
object at the specified position
, and return an iterator referring to the element immediately following the removed element, or to the past-the-end position if the removed element was the last element in the sequence of elements maintained by this map. This method invalidates only iterators and references to the removed element and previously saved values of the end()
iterator. The behavior is undefined unless position
refers to a value_type
object in this map.
size_type bsl::map< KEY, VALUE, COMPARATOR, ALLOCATOR >::erase | ( | const key_type & | key | ) | [inherited] |
Remove from this map the value_type
object whose key is equivalent the specified key
, if such an entry exists, and return 1; otherwise, if there is no value_type
object having an equivalent key, return 0 with no other effect. This method invalidates only iterators and references to the removed element and previously saved values of the end()
iterator.
iterator bsl::map< KEY, VALUE, COMPARATOR, ALLOCATOR >::erase | ( | const_iterator | first, | |
const_iterator | last | |||
) | [inherited] |
Remove from this map the value_type
objects starting at the specified first
position up to, but including the specified last
position, and return last
. This method invalidates only iterators and references to the removed element and previously saved values of the end()
iterator. The behavior is undefined unless first
and last
either refer to elements in this map or are the end
iterator, and the first
position is at or before the last
position in the ordered sequence provided by this container.
pair<iterator, bool> bsl::map< KEY, VALUE, COMPARATOR, ALLOCATOR >::try_emplace | ( | BloombergLP::bslmf::MovableRef< KEY > | key, | |
Args &&... | args | |||
) | [inherited] |
If a key equivalent to the specified key
already exists in this map, return a pair containing an iterator referring to the existing item and false
. Otherwise, insert into this map a newly-created entry constructed from key
and the specified args
, and return a pair containing an iterator referring to the newly-created entry and true
. This method requires that the (template parameter) types KEY
and VALUE
are emplace-constructible
from key
and args
respectively. For C++03, VALUE
must also be copy-constructible
.
iterator bsl::map< KEY, VALUE, COMPARATOR, ALLOCATOR >::try_emplace | ( | const_iterator | hint, | |
const KEY & | key, | |||
Args &&... | args | |||
) | [inherited] |
iterator bsl::map< KEY, VALUE, COMPARATOR, ALLOCATOR >::try_emplace | ( | const_iterator | hint, | |
BloombergLP::bslmf::MovableRef< KEY > | key, | |||
Args &&... | args | |||
) | [inherited] |
If a key equivalent to the specified key
already exists in this map, return an iterator referring to the existing item. Otherwise, insert into this map a newly-created value_type
object, constructed from from key
and the specified args
, and return an iterator referring to the newly-created entry. Use the specified hint
as a starting point for checking to see if the key already in the map. This method requires that the (template parameter) types KEY
and VALUE
are emplace-constructible
from key
and args
respectively. For C++03, VALUE
must also be copy-constructible
.
void bsl::map< KEY, VALUE, COMPARATOR, ALLOCATOR >::clear | ( | ) | [inherited] |
Remove all entries from this map. Note that the map is empty after this call, but allocated memory may be retained for future use.
iterator bsl::map< KEY, VALUE, COMPARATOR, ALLOCATOR >::find | ( | const key_type & | key | ) | [inline, inherited] |
key | Return an iterator providing modifiable access to the value_type object in this map whose key is equivalent to the specified key , if such an entry exists, and the past-the-end (end ) iterator otherwise. |
Note: implemented inline due to Sun CC compilation error.
Referenced by bsl::map< bsl::string, ControlManager_Entry, CaselessLessThan >::contains(), and bsl::map< bsl::string, ControlManager_Entry, CaselessLessThan >::count().
bsl::enable_if< BloombergLP::bslmf::IsTransparentPredicate<COMPARATOR, LOOKUP_KEY>::value, iterator>::type bsl::map< KEY, VALUE, COMPARATOR, ALLOCATOR >::find | ( | const LOOKUP_KEY & | key | ) | [inline, inherited] |
key | Return an iterator providing modifiable access to the value_type object in this map whose key is equivalent to the specified key , if such an entry exists, and the past-the-end (end ) iterator otherwise. |
Note: implemented inline due to Sun CC compilation error.
iterator bsl::map< KEY, VALUE, COMPARATOR, ALLOCATOR >::lower_bound | ( | const key_type & | key | ) | [inline, inherited] |
key | Return an iterator providing modifiable access to the first (i.e., ordered least) value_type object in this map whose key is greater-than or equal-to the specified key , and the past-the-end iterator if this map does not contain a value_type object whose key is greater-than or equal-to key . Note that this function returns the first position before which a value_type object having an equivalent key could be inserted into the ordered sequence maintained by this map, while preserving its ordering. |
Note: implemented inline due to Sun CC compilation error.
Referenced by bsl::map< bsl::string, ControlManager_Entry, CaselessLessThan >::count(), and bsl::map< bsl::string, ControlManager_Entry, CaselessLessThan >::equal_range().
bsl::enable_if< BloombergLP::bslmf::IsTransparentPredicate<COMPARATOR, LOOKUP_KEY>::value, iterator>::type bsl::map< KEY, VALUE, COMPARATOR, ALLOCATOR >::lower_bound | ( | const LOOKUP_KEY & | key | ) | [inline, inherited] |
key | Return an iterator providing modifiable access to the first (i.e., ordered least) value_type object in this map whose key is greater-than or equal-to the specified key , and the past-the-end iterator if this map does not contain a value_type object whose key is greater-than or equal-to key . Note that this function returns the first position before which a value_type object having an equivalent key could be inserted into the ordered sequence maintained by this map, while preserving its ordering. |
Note: implemented inline due to Sun CC compilation error.
iterator bsl::map< KEY, VALUE, COMPARATOR, ALLOCATOR >::upper_bound | ( | const key_type & | key | ) | [inline, inherited] |
key | Return an iterator providing modifiable access to the first (i.e., ordered least) value_type object in this map whose key is greater than the specified key , and the past-the-end iterator if this map does not contain a value_type object whose key is greater-than key . Note that this function returns the last position before which a value_type object having an equivalent key could be inserted into the ordered sequence maintained by this map, while preserving its ordering. |
Note: implemented inline due to Sun CC compilation error.
Referenced by bsl::map< bsl::string, ControlManager_Entry, CaselessLessThan >::equal_range().
bsl::enable_if< BloombergLP::bslmf::IsTransparentPredicate<COMPARATOR, LOOKUP_KEY>::value, iterator>::type bsl::map< KEY, VALUE, COMPARATOR, ALLOCATOR >::upper_bound | ( | const LOOKUP_KEY & | key | ) | [inline, inherited] |
key | Return an iterator providing modifiable access to the first (i.e., ordered least) value_type object in this map whose key is greater than the specified key , and the past-the-end iterator if this map does not contain a value_type object whose key is greater-than key . Note that this function returns the last position before which a value_type object having an equivalent key could be inserted into the ordered sequence maintained by this map, while preserving its ordering. |
Note: implemented inline due to Sun CC compilation error.
pair<iterator, iterator> bsl::map< KEY, VALUE, COMPARATOR, ALLOCATOR >::equal_range | ( | const key_type & | key | ) | [inline, inherited] |
key | Return a pair of iterators providing modifiable access to the sequence of value_type objects in this map whose keys are equivalent to the specified key , where the first iterator is positioned at the start of the sequence and the second is positioned one past the end of the sequence. The first returned iterator will be lower_bound(key) , the second returned iterator will be upper_bound(key) , and, if this map contains no value_type objects with an equivalent key, then the two returned iterators will have the same value. Note that since a map maintains unique keys, the range will contain at most one element. |
Note: implemented inline due to Sun CC compilation error.
bsl::enable_if< BloombergLP::bslmf::IsTransparentPredicate<COMPARATOR, LOOKUP_KEY>::value, pair<iterator, iterator> >::type bsl::map< KEY, VALUE, COMPARATOR, ALLOCATOR >::equal_range | ( | const LOOKUP_KEY & | key | ) | [inline, inherited] |
key | Return a pair of iterators providing modifiable access to the sequence of value_type objects in this map whose keys are equivalent to the specified key , where the first iterator is positioned at the start of the sequence and the second is positioned one past the end of the sequence. The first returned iterator will be lower_bound(key) , the second returned iterator will be upper_bound(key) , and, if this map contains no value_type objects with an equivalent key, then the two returned iterators will have the same value. Note that although a map maintains unique keys, the range may contain more than one element, because a transparent comparator may have been supplied that provides a different (but compatible) partitioning of keys for LOOKUP_KEY as the comparisons used to order the keys in the map. |
Note: implemented inline due to Sun CC compilation error.
allocator_type bsl::map< KEY, VALUE, COMPARATOR, ALLOCATOR >::get_allocator | ( | ) | const [inherited] |
Return (a copy of) the allocator used for memory allocation by this map.
const_iterator bsl::map< KEY, VALUE, COMPARATOR, ALLOCATOR >::begin | ( | ) | const [inherited] |
Return an iterator providing non-modifiable access to the first value_type
object in the ordered sequence of value_type
objects maintained by this map, or the end
iterator if this map is empty.
const_iterator bsl::map< KEY, VALUE, COMPARATOR, ALLOCATOR >::end | ( | ) | const [inherited] |
Return an iterator providing non-modifiable access to the past-the-end element in the ordered sequence of value_type
objects maintained by this map.
const_reverse_iterator bsl::map< KEY, VALUE, COMPARATOR, ALLOCATOR >::rbegin | ( | ) | const [inherited] |
Return a reverse iterator providing non-modifiable access to the last value_type
object in the ordered sequence of value_type
objects maintained by this map, or rend
if this map is empty.
const_reverse_iterator bsl::map< KEY, VALUE, COMPARATOR, ALLOCATOR >::rend | ( | ) | const [inherited] |
Return a reverse iterator providing non-modifiable access to the prior-to-the-beginning element in the ordered sequence of value_type
objects maintained by this map.
const_iterator bsl::map< KEY, VALUE, COMPARATOR, ALLOCATOR >::cbegin | ( | ) | const [inherited] |
Return an iterator providing non-modifiable access to the first value_type
object in the ordered sequence of value_type
objects maintained by this map, or the cend
iterator if this map is empty.
const_iterator bsl::map< KEY, VALUE, COMPARATOR, ALLOCATOR >::cend | ( | ) | const [inherited] |
Return an iterator providing non-modifiable access to the past-the-end element in the ordered sequence of value_type
objects maintained by this map.
const_reverse_iterator bsl::map< KEY, VALUE, COMPARATOR, ALLOCATOR >::crbegin | ( | ) | const [inherited] |
Return a reverse iterator providing non-modifiable access to the last value_type
object in the ordered sequence of value_type
objects maintained by this map, or crend
if this map is empty.
const_reverse_iterator bsl::map< KEY, VALUE, COMPARATOR, ALLOCATOR >::crend | ( | ) | const [inherited] |
Return a reverse iterator providing non-modifiable access to the prior-to-the-beginning element in the ordered sequence of value_type
objects maintained by this map.
bool bsl::map< KEY, VALUE, COMPARATOR, ALLOCATOR >::contains | ( | const key_type & | key | ) | const [inherited] |
Return true
if this map contains an element whose key is equivalent to the specified key
.
bsl::enable_if< BloombergLP::bslmf::IsTransparentPredicate<COMPARATOR, LOOKUP_KEY>::value, bool>::type bsl::map< KEY, VALUE, COMPARATOR, ALLOCATOR >::contains | ( | const LOOKUP_KEY & | key | ) | const [inline, inherited] |
< Return true
if this map contains an element whose key is equivalent to the specified key
.
Note: implemented inline due to Sun CC compilation error
bool bsl::map< KEY, VALUE, COMPARATOR, ALLOCATOR >::empty | ( | ) | const [inherited] |
Return true
if this map contains no elements, and false
otherwise.
size_type bsl::map< KEY, VALUE, COMPARATOR, ALLOCATOR >::size | ( | ) | const [inherited] |
Return the number of elements in this map.
size_type bsl::map< KEY, VALUE, COMPARATOR, ALLOCATOR >::max_size | ( | ) | const [inherited] |
Return a theoretical upper bound on the largest number of elements that this map could possibly hold. Note that there is no guarantee that the map can successfully grow to the returned size, or even close to that size without running out of resources.
add_lvalue_reference<const VALUE>::type bsl::map< KEY, VALUE, COMPARATOR, ALLOCATOR >::at | ( | const key_type & | key | ) | const [inherited] |
Return a reference providing non-modifiable access to the mapped-value associated with a key that is equivalent to the specified key
, if such an entry exists; otherwise, throw a std::out_of_range
exception. Note that this method may also throw a different kind of exception if the (user-supplied) comparator throws.
key_compare bsl::map< KEY, VALUE, COMPARATOR, ALLOCATOR >::key_comp | ( | ) | const [inherited] |
Return the key-comparison functor (or function pointer) used by this map; if a comparator was supplied at construction, return its value; otherwise, return a default constructed key_compare
object. Note that this comparator compares objects of type KEY
, which is the key part of the value_type
objects contained in this map.
value_compare bsl::map< KEY, VALUE, COMPARATOR, ALLOCATOR >::value_comp | ( | ) | const [inherited] |
Return a functor for comparing two value_type
objects by comparing their respective keys using key_comp()
. Note that this comparator compares objects of type value_type
(i.e., bsl::pair<const KEY, VALUE>
).
const_iterator bsl::map< KEY, VALUE, COMPARATOR, ALLOCATOR >::find | ( | const key_type & | key | ) | const [inline, inherited] |
< Return an iterator providing non-modifiable access to the value_type
object in this map whose key is equivalent to the specified key
, if such an entry exists, and the past-the-end (end
) iterator otherwise.
Note: implemented inline due to Sun CC compilation error.
bsl::enable_if< BloombergLP::bslmf::IsTransparentPredicate<COMPARATOR, LOOKUP_KEY>::value, const_iterator>::type bsl::map< KEY, VALUE, COMPARATOR, ALLOCATOR >::find | ( | const LOOKUP_KEY & | key | ) | const [inline, inherited] |
< Return an iterator providing non-modifiable access to the value_type
object in this map whose key is equivalent to the specified key
, if such an entry exists, and the past-the-end (end
) iterator otherwise.
Note: implemented inline due to Sun CC compilation error.
size_type bsl::map< KEY, VALUE, COMPARATOR, ALLOCATOR >::count | ( | const key_type & | key | ) | const [inline, inherited] |
< Return the number of value_type
objects within this map whose keys are equivalent to the specified key
. Note that since a map maintains unique keys, the returned value will be either 0 or 1.
Note: implemented inline due to Sun CC compilation error.
Referenced by bsl::map< bsl::string, ControlManager_Entry, CaselessLessThan >::count().
bsl::enable_if< BloombergLP::bslmf::IsTransparentPredicate<COMPARATOR, LOOKUP_KEY>::value, size_type>::type bsl::map< KEY, VALUE, COMPARATOR, ALLOCATOR >::count | ( | const LOOKUP_KEY & | key | ) | const [inline, inherited] |
< Return the number of value_type
objects within this map whose keys are equivalent to the specified key
. Note that although a map maintains unique keys, the returned value can be other than 0 or 1, because a transparent comparator may have been supplied that provides a different (but compatible) partitioning of keys for LOOKUP_KEY
as the comparisons used to order the keys in the map.
Note: implemented inline due to Sun CC compilation error.
const_iterator bsl::map< KEY, VALUE, COMPARATOR, ALLOCATOR >::lower_bound | ( | const key_type & | key | ) | const [inline, inherited] |
< Return an iterator providing non-modifiable access to the first (i.e., ordered least) value_type
object in this map whose key is greater-than or equal-to the specified key
, and the past-the-end iterator if this map does not contain a value_type
object whose key is greater-than or equal-to key
. Note that this function returns the first position before which a value_type
object having an equivalent key could be inserted into the ordered sequence maintained by this map, while preserving its ordering.
Note: implemented inline due to Sun CC compilation error.
bsl::enable_if< BloombergLP::bslmf::IsTransparentPredicate<COMPARATOR, LOOKUP_KEY>::value, const_iterator>::type bsl::map< KEY, VALUE, COMPARATOR, ALLOCATOR >::lower_bound | ( | const LOOKUP_KEY & | key | ) | const [inline, inherited] |
< Return an iterator providing non-modifiable access to the first (i.e., ordered least) value_type
object in this map whose key is greater-than or equal-to the specified key
, and the past-the-end iterator if this map does not contain a value_type
object whose key is greater-than or equal-to key
. Note that this function returns the first position before which a value_type
object having an equivalent key could be inserted into the ordered sequence maintained by this map, while preserving its ordering.
Note: implemented inline due to Sun CC compilation error.
const_iterator bsl::map< KEY, VALUE, COMPARATOR, ALLOCATOR >::upper_bound | ( | const key_type & | key | ) | const [inline, inherited] |
< Return an iterator providing non-modifiable access to the first (i.e., ordered least) value_type
object in this map whose key is greater than the specified key
, and the past-the-end iterator if this map does not contain a value_type
object whose key is greater-than key
. Note that this function returns the last position before which a value_type
object having an equivalent key could be inserted into the ordered sequence maintained by this map, while preserving its ordering.
Note: implemented inline due to Sun CC compilation error.
bsl::enable_if< BloombergLP::bslmf::IsTransparentPredicate<COMPARATOR, LOOKUP_KEY>::value, const_iterator>::type bsl::map< KEY, VALUE, COMPARATOR, ALLOCATOR >::upper_bound | ( | const LOOKUP_KEY & | key | ) | const [inline, inherited] |
< Return an iterator providing non-modifiable access to the first (i.e., ordered least) value_type
object in this map whose key is greater than the specified key
, and the past-the-end iterator if this map does not contain a value_type
object whose key is greater-than key
. Note that this function returns the last position before which a value_type
object having an equivalent key could be inserted into the ordered sequence maintained by this map, while preserving its ordering.
Note: implemented inline due to Sun CC compilation error.
pair<const_iterator, const_iterator> bsl::map< KEY, VALUE, COMPARATOR, ALLOCATOR >::equal_range | ( | const key_type & | key | ) | const [inline, inherited] |
< Return a pair of iterators providing non-modifiable access to the sequence of value_type
objects in this map whose keys are equivalent to the specified key
, where the first iterator is positioned at the start of the sequence and the second iterator is positioned one past the end of the sequence. The first returned iterator will be lower_bound(key)
, the second returned iterator will be upper_bound(key)
, and, if this map contains no value_type
objects having keys equivalent to key
, then the two returned iterators will have the same value. Note that since a map maintains unique keys, the range will contain at most one element.
Note: implemented inline due to Sun CC compilation error.
bsl::enable_if< BloombergLP::bslmf::IsTransparentPredicate<COMPARATOR, LOOKUP_KEY>::value, pair<const_iterator, const_iterator> >::type bsl::map< KEY, VALUE, COMPARATOR, ALLOCATOR >::equal_range | ( | const LOOKUP_KEY & | key | ) | const [inline, inherited] |
< Return a pair of iterators providing non-modifiable access to the sequence of value_type
objects in this map whose keys are equivalent to the specified key
, where the first iterator is positioned at the start of the sequence and the second iterator is positioned one past the end of the sequence. The first returned iterator will be lower_bound(key)
, the second returned iterator will be upper_bound(key)
, and, if this map contains no value_type
objects having keys equivalent to key
, then the two returned iterators will have the same value. Note that although a map maintains unique keys, the range may contain more than one element, because a transparent comparator may have been supplied that provides a different (but compatible) partitioning of keys for LOOKUP_KEY
as the comparisons used to order the keys in the map.
Note: implemented inline due to Sun CC compilation error.
bool bsl::operator== | ( | const map< KEY, VALUE, COMPARATOR, ALLOCATOR > & | lhs, | |
const map< KEY, VALUE, COMPARATOR, ALLOCATOR > & | rhs | |||
) |
Return true
if the specified lhs
and rhs
objects have the same value, and false
otherwise. Two map
objects lhs
and rhs
have the same value if they have the same number of key-value pairs, and each element in the ordered sequence of key-value pairs of lhs
has the same value as the corresponding element in the ordered sequence of key-value pairs of rhs
. This method requires that the (template parameter) types KEY
and VALUE
both be equality-comparable
(see Requirements on KEY
and VALUE
).
bool bsl::operator!= | ( | const map< KEY, VALUE, COMPARATOR, ALLOCATOR > & | lhs, | |
const map< KEY, VALUE, COMPARATOR, ALLOCATOR > & | rhs | |||
) |
Return true
if the specified lhs
and rhs
objects do not have the same value, and false
otherwise. Two map
objects lhs
and rhs
do not have the same value if they do not have the same number of key-value pairs, or some element in the ordered sequence of key-value pairs of lhs
does not have the same value as the corresponding element in the ordered sequence of key-value pairs of rhs
. This method requires that the (template parameter) types KEY
and VALUE
both be equality-comparable
(see Requirements on KEY
and VALUE
).
bool bsl::operator< | ( | const map< KEY, VALUE, COMPARATOR, ALLOCATOR > & | lhs, | |
const map< KEY, VALUE, COMPARATOR, ALLOCATOR > & | rhs | |||
) |
Return true
if the value of the specified lhs
map is lexicographically less than that of the specified rhs
map, and false
otherwise. Given iterators i
and j
over the respective sequences [lhs.begin() .. lhs.end())
and [rhs.begin() .. rhs.end())
, the value of map lhs
is lexicographically less than that of map rhs
if true == *i < *j
for the first pair of corresponding iterator positions where *i < *j
and *j < *i
are not both false
. If no such corresponding iterator position exists, the value of lhs
is lexicographically less than that of rhs
if lhs.size() < rhs.size()
. This method requires that operator<
, inducing a total order, be defined for value_type
.
bool bsl::operator> | ( | const map< KEY, VALUE, COMPARATOR, ALLOCATOR > & | lhs, | |
const map< KEY, VALUE, COMPARATOR, ALLOCATOR > & | rhs | |||
) |
Return true
if the value of the specified lhs
map is lexicographically greater than that of the specified rhs
map, and false
otherwise. The value of map lhs
is lexicographically greater than that of map rhs
if rhs
is lexicographically less than lhs
(see operator<
). This method requires that operator<
, inducing a total order, be defined for value_type
. Note that this operator returns rhs < lhs
.
bool bsl::operator<= | ( | const map< KEY, VALUE, COMPARATOR, ALLOCATOR > & | lhs, | |
const map< KEY, VALUE, COMPARATOR, ALLOCATOR > & | rhs | |||
) |
Return true
if the value of the specified lhs
map is lexicographically less than or equal to that of the specified rhs
map, and false
otherwise. The value of map lhs
is lexicographically less than or equal to that of map rhs
if rhs
is not lexicographically less than lhs
(see operator<
). This method requires that operator<
, inducing a total order, be defined for value_type
. Note that this operator returns !(rhs < lhs)
.
bool bsl::operator>= | ( | const map< KEY, VALUE, COMPARATOR, ALLOCATOR > & | lhs, | |
const map< KEY, VALUE, COMPARATOR, ALLOCATOR > & | rhs | |||
) |
Return true
if the value of the specified lhs
map is lexicographically greater than or equal to that of the specified rhs
map, and false
otherwise. The value of map lhs
is lexicographically greater than or equal to that of map rhs
if lhs
is not lexicographically less than rhs
(see operator<
). This method requires that operator<
, inducing a total order, be defined for value_type
. Note that this operator returns !(lhs < rhs)
.
map<KEY, VALUE, COMPARATOR, ALLOCATOR>::size_type bsl::erase_if | ( | map< KEY, VALUE, COMPARATOR, ALLOCATOR > & | m, | |
PREDICATE | predicate | |||
) |
Erase all the elements in the specified map m
that satisfy the specified predicate predicate
. Return the number of elements erased.
void bsl::swap | ( | map< KEY, VALUE, COMPARATOR, ALLOCATOR > & | a, | |
map< KEY, VALUE, COMPARATOR, ALLOCATOR > & | b | |||
) |
Exchange the value and comparator of the specified a
object with those of the specified b
object; also exchange the allocator of a
with that of b
if the (template parameter) type ALLOCATOR
has the propagate_on_container_swap
trait, and do not modify either allocator otherwise. This function provides the no-throw exception-safety guarantee if and only if the (template parameter) type COMPARATOR
provides a no-throw swap operation, and provides the basic exception-safety guarantee otherwise; if an exception is thrown, both objects are left in valid but unspecified states. This operation has O[1]
complexity if either a
was created with the same allocator as b
or ALLOCATOR
has the propagate_on_container_swap
trait; otherwise, it has O[n + m]
complexity, where n
and m
are the number of elements in a
and b
, respectively. Note that this function's support for swapping objects created with different allocators when ALLOCATOR
does not have the propagate_on_container_swap
trait is a departure from the C++ Standard.
COMPARATOR bsl::map< KEY, VALUE, COMPARATOR, ALLOCATOR >::value_compare::comp [protected, inherited] |
we would not have elected to make this data
void swap (map& other) BSLS_KEYWORD_NOEXCEPT_SPECIFICATION( AllocatorTraits pair<iterator, bool> bsl::map< KEY, VALUE, COMPARATOR, ALLOCATOR >::try_emplace(const KEY &key, Args &&...args) [inherited] |
< Exchange the value and comparator of this object with those of the specified other
object; also exchange the allocator of this object with that of other
if the (template parameter) type ALLOCATOR
has the propagate_on_container_swap
trait, and do not modify either allocator otherwise. This method provides the no-throw exception-safety guarantee if and only if the (template parameter) type COMPARATOR
provides a no-throw swap operation, and provides the basic exception-safety guarantee otherwise; if an exception is thrown, both objects are left in valid but unspecified states. This operation has O[1]
complexity if either this object was created with the same allocator as other
or ALLOCATOR
has the propagate_on_container_swap
trait; otherwise, it has O[n + m]
complexity, where n
and m
are the number of elements in this object and other
, respectively. Note that this method's support for swapping objects created with different allocators when ALLOCATOR
does not have the propagate_on_container_swap
trait is a departure from the C++ Standard.