Expression | Return type | Assertion/note | Complexity | |
pre-/post-condition | ||||
Key | compile time | |||
T | compile time | |||
Key | Preconditions: value_type is Cpp17Erasable from X | compile time | ||
X::value_type (map and multimap only) | pair<const Key, T> | Preconditions: value_type is Cpp17Erasable from X | compile time | |
Compare | Preconditions: key_compare is Cpp17CopyConstructible. | compile time | ||
a binary predicate type | is the same as key_compare for set and
multiset; is an ordering relation on pairs induced by the
first component (i.e., Key) for map and multimap. | compile time | ||
A specialization of a node-handle
class template, such that the public nested types are
the same types as the corresponding types in X. | see [container.node] | compile time | ||
constant | ||||
X() X u; | constant | |||
X(i,j,c) X u(i,j,c); | in general, where N has the value distance(i, j);
linear if [i, j) is sorted with value_comp() | |||
X(i,j) X u(i,j); | same as above | |||
X(il) | same as X(il.begin(), il.end()) | same as X(il.begin(), il.end()) | ||
X(il,c) | same as X(il.begin(), il.end(), c) | same as X(il.begin(), il.end(), c) | ||
a = il | X& | in general, where N has the value il.size() + a.size();
linear if [il.begin(), il.end()) is sorted with value_comp() | ||
X::key_compare | Returns: the comparison object out of which b was constructed. | constant | ||
X::value_compare | Returns: an object of value_compare constructed out of the comparison object | constant | ||
pair<iterator, bool> | Effects: Inserts a value_type object t constructed with std::forward<Args>(args)... if and only if there is no element in the container with key equivalent to the key of t. The bool component of the returned
pair is true if and only if the insertion takes place, and the iterator
component of the pair points to the element with key equivalent to the
key of t. | logarithmic | ||
a_eq.emplace(args) | iterator | logarithmic | ||
iterator | logarithmic in general, but amortized constant if the element
is inserted right before p | |||
pair<iterator, bool> | Preconditions: If t is a non-const rvalue, value_type is
Cpp17MoveInsertable into X; otherwise, value_type is
Cpp17CopyInsertable into X. Effects: Inserts t if and only if there is no element in the container with key equivalent to the key of t. The bool component of
the returned pair is true if and only if the insertion
takes place, and the iterator
component of the pair points to the element with key
equivalent to the key of t. | logarithmic | ||
a_eq.insert(t) | iterator | logarithmic | ||
a.insert(p, t) | iterator | Preconditions: If t is a non-const rvalue, value_type is
Cpp17MoveInsertable into X; otherwise, value_type is
Cpp17CopyInsertable into X. Effects: Inserts t if and only if there is no element with key equivalent to the key of t in containers with unique keys; always inserts t in containers with equivalent keys. Always
returns the iterator pointing to the element with key equivalent to
the key of t. | ||
a.insert(i, j) | void | Effects: Inserts each element from the range [i, j) if and only if there is no element with key equivalent to the key of that element in containers with unique keys; always inserts that element in containers with equivalent keys. | , where N has the value distance(i, j) | |
a.insert(il) | void | Effects: Equivalent to a.insert(il.begin(), il.end()) | ||
a_uniq.insert(nh) | insert_return_type | Otherwise, inserts the
element owned by nh if and only if there is no element in the
container with a key equivalent to nh.key(). Otherwise if the insertion took place, inserted is true,
position points to the inserted element, and node is empty;
if the insertion failed, inserted is false,
node has the previous value of nh, and position
points to an element with a key equivalent to nh.key(). | logarithmic | |
a_eq.insert(nh) | iterator | logarithmic | ||
a.insert(p, nh) | iterator | Otherwise, inserts the element owned by nh if and only if there
is no element with key equivalent to nh.key() in containers with
unique keys; always inserts the element owned by nh in containers
with equivalent keys. Always returns the iterator pointing to the element
with key equivalent to nh.key(). The element is inserted as close
as possible to the position just prior to p. | logarithmic in general, but amortized constant if the element is inserted right
before p. | |
node_type | ||||
a.extract(q) | node_type | amortized constant | ||
void | Preconditions: a.get_allocator() == a2.get_allocator(). Effects: Attempts to extract each element in a2 and insert it into a using the comparison object of a. In containers with unique keys,
if there is an element in a with key equivalent to the key of an
element from a2, then that element is not extracted from a2. Postconditions: Pointers and references to the transferred elements of a2 refer to those same elements but as members of a. Iterators referring
to the transferred elements will continue to refer to their elements, but
they now behave as iterators into a, not into a2. Throws: Nothing unless the comparison object throws. | |||
size_type | ||||
a.erase(q) | iterator | amortized constant | ||
a.erase(r) | iterator | amortized constant | ||
a.erase( q1, q2) | iterator | |||
void | linear in a.size(). | |||
Returns: An iterator pointing to an element with the key equivalent
to k, or b.end() if such an element is not found. | logarithmic | |||
a_tran. find(ke) | Returns: An iterator pointing to an element with key r such that
!c(r, ke) && !c(ke, r), or a_tran.end() if such an element
is not found. | logarithmic | ||
size_type | Returns: The number of elements with key equivalent to k. | |||
a_tran. count(ke) | size_type | Returns: The number of elements with key r such that
!c(r, ke) && !c(ke, r) | ||
bool | Effects: Equivalent to: return b.find(k) != b.end(); | logarithmic | ||
a_tran. contains(ke) | bool | Effects: Equivalent to: return a_tran.find(ke) != a_tran.end(); | logarithmic | |
Returns: An iterator pointing to the first element with
key not less than k,
or b.end() if such an element is not found. | logarithmic | |||
a_tran. lower_bound(kl) | Returns: An iterator pointing to the first element with
key r such that !c(r, kl),
or a_tran.end() if such an element is not found. | logarithmic | ||
Returns: An iterator pointing to the first element with
key greater than k,
or b.end() if such an element is not found. | logarithmic | |||
a_tran. upper_bound(ku) | Returns: An iterator pointing to the first element with
key r such that c(ku, r),
or a_tran.end() if such an element is not found. | logarithmic | ||
Effects: Equivalent to: return make_pair(b.lower_bound(k), b.upper_bound(k)); | logarithmic | |||
a_tran. equal_range(ke) | Effects: Equivalent to: return make_pair( a_tran.lower_bound(ke), a_tran.upper_bound(ke)); | logarithmic |