17. Appendix C: STL Container Class Methods

All the STL container class methods listed apply to STL containers provided with Microsoft Visual C++ 4.2.

17.1 deque

Member Description
typedef A allocator_type deque::allocator_type describes the stored allocator object (same as the second template argument).
void assign(const_iterator first,const_iterator
. . . last)void assign(size_type n, const T& x = T())
The first version of deque::assign replaces the sequence controlled by *this with the sequence [first, last). The second version replaces the sequence controlled by *this with a repetition of n elements of value x.
const_reference at(size_type pos) constreference  . . . at(size_type pos) deque::at returns a reference to the element of the deque at position pos. If that position is invalid, the function throws an object of class out_of_range (throws an exception).
reference back()
const_reference back() const
deque::back returns a reference to the last element of the deque, which must be nonempty.
const_iterator begin() const
iterator begin()
deque::begin returns a random-access iterator that points at the first element of the sequence (or just beyond the end of an empty sequence).
void clear() const deque::clear calls erase( begin(), end()).
typedef A::const_iterator const_iterator deque::const_iterator describes an object that can serve as a constant random-access iterator for the deque. It is described here as a synonym for the const_iterator member of the allocator object.
Typedef A::const_reference const_reference deque::const_reference describes an object that can serve as a constant reference to an element of the deque.
typedef reverse_iterator<const_iterator,
    value_type,const_reference, A::const_pointer,
    difference_type> const_reverse_iterator
deque::const_reverse_iterator describes an object that can serve as a constant reverse iterator for the deque.
explicit deque(const A& al = A())
explicit deque(size_type n, const T& v = T(),
    const A& al = A())
deque(const deque& x)
deque(const_iterator first, const_iterator last,
    const A& al = A())
All constructors store the allocator object al (or, for the copy constructor, x.get_allocator()) in allocator and initialize the controlled sequence. The first constructor specifies an empty initial controlled sequence. The second constructor specifies a repetition of n elements of value x. The third constructor specifies a copy of the sequence controlled by x. The last constructor specifies the sequence[first, last).
typedef A::difference_type difference_type deque::difference_type is a signed integer type that describes an object that can represent the difference between the addresses of any two elements in the deque.
bool empty() const deque::empty returns true if the deque is empty.
const_iterator end() const
iterator end()
deque::end returns a random-access iterator that points just beyond the end of the sequence.
iterator erase(iterator it)
iterator erase(iterator first, iterator last)
The first version of deque::erase removes the element of the controlled sequence pointed to by it. The second version removes the elements of the controlled sequence in the range [first, last). Both return an iterator that designates the first element remaining beyond any elements removed, or end() if no such element exists.
Erasing N elements causes N destructor calls and an assignment (operator=) for each of the elements between the insertion point and the nearer end of the sequence. Removing an element at either end invalidates only iterators and references that designate the erased elements. Otherwise, erasing an element invalidates all iterators and references.
reference front()
const_reference front() const
deque::front returns a reference to the first element of the controlled sequence, which must be nonempty.
A get_allocator() const The member function returns allocator.
iterator insert(iterator it, const T& x = T())
void insert(iterator it, size_type n, const T& x)
void insert(iterator it, const_iterator first,
    const_iterator last)
Each version of deque::insert inserts, after the element pointed to by it in the controlled sequence, a sequence specified by the remaining operands. The first version inserts a single element with value x> and returns an iterator that points to the newly inserted element. The second version inserts a repetition of n elements of value x. The third version inserts the sequence [first, last).
When inserting a single element, the number of element copies is linear in the number of elements between the insertion point and the nearer end of the sequence. When inserting a single element at either end of the sequence, the amortized number of element copies is constant. When inserting N elements, the number of element copies is linear in N plus the number of elements between the insertion point and the nearer end of the sequence. Inserting an element at either end invalidates all iterators, but no references, that designate existing elements. Otherwise, inserting an element invalidates all iterators and references.
typedef A::pointer iterator Iterator describes an object that can serve as a random-access iterator for the controlled sequence. It is described here as a synonym for the pointer member of the allocator object.
size_type max_size() const deque::max_size returns the length of the longest sequence that the object can control.
const_reference operator[](size_type pos) const
reference operator[](size_type pos)
operator[] returns a reference to the element of the controlled sequence at position pos. If that position is invalid, the behavior is undefined.
void pop_back() deque::pop_back removes the last element of the controlled sequence, which must be nonempty. Removing the element invalidates only iterators and references that designate the erased element.
void pop_front() deque::pop_front removes the first element of the controlled sequence, which must be nonempty. Removing the element invalidates only iterators and references that designate the erased element.
void push_back(const T& x) deque::push_back inserts an element with value x at the end of the controlled sequence. Inserting the element invalidates all iterators, but no references, to existing elements.
void push_front(const T& x) deque::push_front inserts an element with value x at the beginning of the controlled sequence. Inserting the element invalidates all iterators, but no references, to existing elements.
const_reverse_iterator rbegin() const
reverse_iterator rbegin()
deque::rbegin returns a reverse iterator that points just beyond the end of the controlled sequence. Hence, it designates the beginning of the reverse sequence.
typedef A::reference reference deque::reference describes an object that can be used as a reference to an element of the controlled sequence. It is described here as a synonym for the reference member of the allocator object.
const_reverse_iterator rend() const
reverse_iterator rend()
deque::rend returns a reverse iterator that points at the first element of the sequence (or just beyond the end of an empty sequence). Hence, it designates the end of the reverse sequence.
void resize(size_type n, T x = T()) deque::resize ensures that size() henceforth returns n. If it must make the controlled sequence longer, it appends elements with value x.
typedef reverse_iterator<iterator, value_type,
    reference, A::types<T>::pointer,
    difference_type> reverse_iterator
The type describes an object that can serve as a reverse iterator for the controlled sequence.
size_type size() const deque::size returns the length of the controlled sequence.
typedef A::size_type size_type size_type is an unsigned integer type that describes an object that can represent the length of any controlled sequence.
void swap(deque& str) deque::swap swaps the controlled sequences between *this and str. If allocator == str.allocator, it does so in constant time. Otherwise, it performs a number of element assignments and constructor calls proportional to the number of elements in the two controlled sequences.
typedef A::types<T>::value_type value_type The type describes an element of the controlled sequence (same as the template parameter T).

17.2 list

Member Description
typedef A allocator_type list::allocator_type describes the stored allocator object (same as the second template argument).
void assign(const_iterator first,const_iterator last)
void assign(size_type n, const T& x = T())
The first version of list::assign replaces the sequence controlled by *this with the sequence [first, last). The second version replaces the sequence controlled by *this with a repetition of n elements of value x.
reference back()
const_reference back() const
list::back returns a reference to the last element of the list, which must be nonempty.
const_iterator begin() const
iterator begin()
list::begin returns a random-access iterator that points at the first element of the sequence (or just beyond the end of an empty sequence).
void clear() const list::clear calls erase( begin(), end()).
typedef A::const_iterator const_iterator list::const_iterator describes an object that can serve as a constant random-access iterator for the list. It is described here as a synonym for the const_iterator member of the allocator object.
typedef A::const_reference const_reference list::const_reference describes an object that can serve as a constant reference to an element of the list.
typedef reverse_iterator<const_iterator,
    value_type,const_reference, A::const_pointer,
    difference_type> const_reverse_iterator
list::const_reverse_iterator describes an object that can serve as a constant reverse iterator for the list.
typedef A::difference_type difference_type list::difference_type is a signed integer type that describes an object that can represent the difference between the addresses of any two elements in the list.
bool empty() const list::empty returns true if the list is empty
const_iterator end() const
iterator end()
list::end returns a random-access iterator that points just beyond the end of the sequence.
iterator erase(iterator it)
iterator erase(iterator first, iterator last)
The first version of list::erase removes the element of the controlled sequence pointed to by it. The second version removes the elements of the controlled sequence in the range [first, last). Both return an iterator that designates the first element remaining beyond any elements removed, or end() if no such element exists.
Erasing N elements causes N destructor calls. No reallocation occurs, so iterators and references become invalid only for the erased elements.
reference front()
const_reference front() const
list::front returns a reference to the first element of the controlled sequence, which must be nonempty.
A get_allocator() const The member function returns allocator.
iterator insert(iterator it, const T& x = T())
void insert(iterator it, size_type n,const T& x)
void insert(iterator it, const_iterator first,
    const_iterator last)
Each version of list::insert inserts, after the element pointed to by it in the controlled sequence, a sequence specified by the remaining operands. The first version inserts a single element with value x> and returns an iterator that points to the newly inserted element. The second version inserts a repetition of n elements of value x. The third version inserts the sequence [first, last).
Inserting N elements causes N copies. No reallocation occurs, so no iterators or references become invalid.
typedef A::pointer iterator Iterator describes an object that can serve as a random-access iterator for the controlled sequence. It is described here as a synonym for the pointer member of the allocator object.
explicit list(const A& al = A())
explicit list(size_type n, const T& v = T(),
    const A& al = A())
list(const list& x)
list(const_iterator first, const_iterator last,
    const A& al = A())
All constructors store the allocator object al (or, for the copy constructor, x.get_allocator()) in allocator and initialize the controlled sequence. The first constructor specifies an empty initial controlled sequence. The second constructor specifies a repetition of n elements of value x. The third constructor specifies a copy of the sequence controlled by x. The last constructor specifies the sequence [first, last). None of the constructors perform any interim reallocations.
size_type max_size() const list::max_size returns the length of the longest sequence that the object can control.
void merge(list& x)
void merge(list& x, greater<TYPE> pr)
Both versions of list::merge remove all elements from the sequence controlled by x and insert them in the controlled sequence. Both sequences must be ordered by the same predicate, described below. The resulting sequence is also ordered by that predicate. For the iterators Pi and Pj designating elements at positions i and j, the first member function imposes the order !(*Pj < *Pi) whenever i < j. The second version imposes the order !pr(*Pj, *Pi) whenever i < j. No pairs of elements in the original controlled sequence are reversed in the resulting controlled sequence. If a pair of elements in the resulting controlled sequence compares equal (!(*Pi < *Pj) && !(*Pj < *Pi)), an element from the original controlled sequence appears before an element from the sequence controlled by x.
void pop_back() list::pop_back removes the last element of the controlled sequence, which must be nonempty.
void pop_front() list::pop_front removes the first element of the controlled sequence, which must be nonempty.
void push_back(const T& x) list::push_back inserts an element with value x at the end of the controlled sequence.
void push_front(const T& x) list::push_front inserts an element with value x at the beginning of the controlled sequence.
const_reverse_iterator rbegin() const
reverse_iterator rbegin()
list::rbegin returns a reverse iterator that points just beyond the end of the controlled sequence. Hence, it designates the beginning of the reverse sequence.
typedef A::reference reference list::reference describes an object that can be used as a reference to an element of the controlled sequence. It is described here as a synonym for the reference member of the allocator object.
void remove(const T& x) list::remove removes from the controlled sequence all elements, designated by the iterator P, for which *P == x.
void remove_if(
    binder2nd<not_equal_to<TYPE> > pr)
list::remove_if removes from the controlled sequence all elements, designated by the iterator P, for which pr(*P) is true.
const_reverse_iterator rend() const
reverse_iterator rend()
list::rend returns a reverse iterator that points at the first element of the sequence (or just beyond the end of an empty sequence). Hence, it designates the end of the reverse sequence.
void resize(size_type n, T x = T()) list::resize ensures that size() henceforth returns n. If it must make the controlled sequence longer, it appends elements with value x.
void reverse() list::reverse reverses the order in which elements appear in the controlled sequence.
typedef reverse_iterator<iterator, value_type,
    reference, A::types<T>::pointer,
    difference_type> reverse_iterator
The type describes an object that can serve as a reverse iterator for the controlled sequence.
size_type size() const list::size returns the length of the controlled sequence.
typedef A::size_type size_type size_type is an unsigned integer type that describes an object that can represent the length of any controlled sequence.
void sort()
void sort(greater<TYPE> pr)
Both versions of list::sort order the elements in the controlled sequence by a predicate. For the iterators Pi and Pj designating elements at positions i and j, the first member function imposes the order !(*Pj < *Pi) whenever i < j. The second version imposes the order !pr(*Pj, *Pi) whenever i < j. No pairs of elements in the original controlled sequence are reversed in the resulting controlled sequence. "void splice(iterator it, list& x)"
void splice(iterator it, list& x, iterator first)
void splice(iterator it,iterator first,iterator last)
The first version of list::splice inserts the sequence controlled by x after the element in the controlled sequence pointed to by it. It also removes all elements from x. (&x must not equal this). The second version removes the element pointed to by the first in the sequence controlled by x and inserts it after the element in the controlled sequence pointed to by it. (If it == first || it == ++first, no change occurs). The third version function inserts the subrange designated by [first, last) from the sequence controlled by x after the element in the controlled sequence pointed to by it. It also removes the original subrange from the sequence controlled by x. (If &x == this, the range [first, last) must not include the element pointed to by it). If the third version inserts N elements, and &x != this, an object of class iterator is incremented N times. In no case do any copies or destructor calls occur for any elements.
void swap(list& str) list::swap swaps the controlled sequences between *this and str. If allocator == str.allocator, it does so in constant time. Otherwise, it performs a number of element assignments and constructor calls proportional to the number of elements in the two controlled sequences.
void unique()
void unique(not_equal_to<TYPE>pr)
The first version of list::unique removes from the controlled sequence every element that compares equal to its preceding element. For the iterators Pi and Pj designating elements at positions i and j, the second version removes every element for which i + 1 == j && pr(*Pi, *Pj). For a list of length N (> 0), the predicate pr(*Pi, *Pj) is evaluated N - 1 times.
typedef A::types<T>::value_type value_type The type describes an element of the controlled sequence (same as the template parameter T).

17.3 map and multimap

Each element listed here is a member of both map and multimap, with exceptions noted explicitly.

References to map::[symbol] imply the existence of multimap::[symbol] with similar behavior.

Member: Description
typedef A allocator_type map::allocator_type describes the stored allocator object (same as the fourth template argument).
const_iterator begin() const
iterator begin()
map::begin returns a bidirectional iterator that points at the first element of the sequence (or just beyond the end of an empty sequence).
void clear() const map::clear calls erase( begin(), end()).
typedef A::const_iterator const_iterator map::const_iterator describes an object that can serve as a constant bidirectional iterator for the map. It is described here as a synonym for the const_iterator member of the allocator object.
typedef A::const_reference
    const_reference
map::const_reference describes an object that can serve as a constant reference to an element of the map.
typedef reverse_iterator<const_iterator,     
    value_type, const_reference,
    A::const_pointer, difference_type>
    const_reverse_iterator
map::const_reverse_iterator describes an object that can serve as a constant reverse bidirectional iterator for the map.
size_type count(const Key& key) const map::count returns the number of elements x in the range [lower_bound(key), upper_bound(key)).
typedef A::difference_type difference_type map::difference_type is a signed integer type that describes an object that can represent the difference between the addresses of any two elements in the map. Note that such differences are not meaningful within the context of the map.
bool empty() const map::empty returns true if the map is empty.
const_iterator end() const
iterator end()
map::end returns a bidirectional iterator that points just beyond the end of the sequence.
pair<const_iterator, const_iterator>
    equal_range(const Key& key) const
map::equal_range returns a pair of iterators x such that x.first == lower_bound(key) and x.second == upper_bound(key).
iterator erase(iterator it)
iterator erase(iterator first, iterator last)
size_type erase(const Key& key)
The first version of map::erase removes the element of the controlled sequence pointed to by it. The second version removes the elements in the range [first, last). Both return an iterator that designates the first element remaining beyond any elements removed, or end() if no such element exists. The third version removes the elements with sort keys in the range [lower_bound(key), upper_bound(key)), and returns the number of elements it removes.
const_iterator find(const Key& key) const map::find returns an iterator that designates the earliest element in the controlled sequence whose sort key equals key. If no such element exists, the iterator equals end().
A get_allocator() const The member function returns allocator.
pair<iterator, bool>
    insert(const value_type& x)
iterator insert(iterator obptr,
    const value_type& x)
void insert(const value_type *first,
    const value_type *last)
The first version of map::insert determines whether an element y exists in the sequence whose key matches that of x. (The keys match if ! key_comp()(x, y) && !key_comp()(y, x).) If not, it creates such an element y and initializes it with x. The function then determines the iterator obptr that designates y. If an insertion occurred, the function returns pair(obptr, true). Otherwise, it returns pair(obptr, false). The second version returns insert(x), using obptr as a starting place within the controlled sequence to search for the insertion point. (Insertion can occur in amortized constant time, instead of logarithmic time, if the insertion point immediately follows obptr.) The third version inserts the sequence of element values in the range [first, last).
typedef A::pointer iterator Iterator describes an object that can serve as a bidirectional iterator for the controlled sequence. It is described here as a synonym for the pointer member of the allocator object.
key_compare key_comp() const map::key_comp returns the stored function object that determines the order of elements in the controlled sequence. The stored object defines the member function bool operator(const Key& x, const Key& y) which returns true if x strictly precedes y in the sort order.
typedef Pred key_compare map::key_compare describes a function object that can compare two sort keys to determine the relative order of any two elements in the controlled sequence. It is described here in terms of the user-defined comparator object (second template parameter).
typedef Key key_type map::key_type describes the sort key object stored in each element of the map.
const_iterator lower_bound
    (const Key& key) const
map::lower_bound returns an iterator that designates the earliest element x in the controlled sequence for which key_comp()(x, key) is False. If no such element exists, the function returns end().
explicit map(const Pred& comp = Pred(),
    const A& al=A())
map(const map& x)
map(const value_type *first,const value_type *last,
    const Pred& comp=Pred(), const A& al=A())
The constructors with an argument named comp store the function object so that it can be later returned by calling key_comp(). All constructors also store the allocator object al (or, for the copy constructor, x. get_allocator()) in allocator and initialize the controlled sequence. The first constructor specifies an empty initial controlled sequence. The second constructor specifies a copy of the sequence controlled by x. The third constructor specifies the sequence of element values [first, last).
This method is a member of map only.
typedef TYPE mapped_type map::mapped_type describes the value object stored in each element of the map. It is described here in terms of the second template parameter.
size_type max_size() const map::max_size returns the length of the longest sequence that the object can control.
explicit multimap(const Pred& comp = Pred(),
     const A& al=A())
multimap(const multimap& x)
multimap(const value_type *first,
    const value_type *last,
    const Pred& comp=Pred(), const A& al=A())
The constructors with an argument named comp store the function object so that it can be later returned by calling key_comp(). All constructors also store the allocator object al (or, for the copy constructor, x. get_allocator()) in allocator and initialize the controlled sequence. The first constructor specifies an empty initial controlled sequence. The second constructor specifies a copy of the sequence controlled by x. The third constructor specifies the sequence of element values [first, last).
This method is a member of multimap only.
A::types<TYPE>::reference
    operator[](const Key& key);
map::operator[] determines the iterator it as the return value of insert( value_type(key, T()). (It inserts an element with the specified key if no such element exists.) It then returns a reference to (*it). second.
This method is a member of map only.
const_reverse_iterator rbegin() const
reverse_iterator rbegin()
map::rbegin returns a reverse iterator that points just beyond the end of the controlled sequence. Hence, it designates the beginning of the reverse sequence.
typedef A::reference reference map::reference describes an object that can be used as a reference to an element of the controlled sequence. It is described here as a synonym for the reference member of the allocator object.
const_reverse_iterator rend() const
reverse_iterator rend()
map::rend returns a reverse iterator that points at the first element of the sequence (or just beyond the end of an empty sequence). Hence, it designates the end of the reverse sequence.
typedef reverse_bidirectional_iterator
    <iterator, value_type,  reference,
    A::types<Key>::pointer,  
    difference_type> reverse_iterator
map::reverse_iterator describes an object that can serve as a reverse bidirectional iterator for the controlled sequence.
explicit map(const Pred& comp=Pred(),
    const A& al=A())
map(const map& x)
map(const value_type *first,const value_type *last,
    const Pred& comp = Pred(), const A& al = A())
The constructors with an argument named comp store the function object so that it can be later returned by calling key_comp(). All constructors also store the allocator object al (or, for the copy constructor, x.get_allocator()) in allocator and initialize the controlled sequence. The first constructor specifies an empty initial controlled sequence. The second constructor specifies a copy of the sequence controlled by x. The third constructor specifies the sequence of element values [first, last).
This method is a member of map only.
size_type size() const map::size returns the length of the controlled sequence.
typedef A::size_type size_type size_type is an unsigned integer type that describes an object that can represent the length of any controlled sequence.
void swap(map& str) map::swap swaps the controlled sequences between *this and str. If allocator == str.allocator, it does so in constant time. Otherwise, it performs a number of element assignments and constructor calls proportional to the number of elements in the two controlled sequences.
const_iterator upper_bound(const Key& key) const map::upper_bound returns an iterator that designates the earliest element x in the controlled sequence for which key_comp()(key, x) is true. If no such element exists, the function returns end().
value_compare value_comp() const map::valuecomp returns a function object that determines the order of elements in the controlled sequence.
class value_compare
   : public binary_function<value_type, value_type, bool> {
   friend class map;
public:
   bool operator()(const value_type& x, const value_type& y)
       {return (comp(x.first, x.second)); }
protected:
   value_compare(key_compare pr)
       : comp(pr) {}
   key_compare comp;
   };
map::value_compare describes a function object that can compare the sort keys in two elements to determine their relative order in the controlled sequence. The function object stores an object comp of type key_type. The member function operator() uses this object to compare the sort-key components of two elements.
typedef pair<const Key, T> value_type; The type describes an element of the controlled sequence (a key/data pair).

17.4 set and multiset

Each element listed here is a member of both set and multiset, with exceptions noted explicitly. References to set::[symbol] imply the existence of multiset::[symbol] with similar behavior.

Member Function
typedef A allocator_type set::allocator_type describes the stored allocator object (same as the second template argument).
const_iterator begin() const
iterator begin()
set::begin returns a bidirectional iterator that points at the first element of the sequence (or just beyond the end of an empty sequence).
void clear() const set::clear calls erase( begin(), end()).
typedef A::const_iterator const_iterator set::const_iterator describes an object that can serve as a constant bidirectional iterator for the set. It is described here as a synonym for the const_iterator member of the allocator object.
typedef A::const_reference const_reference set::const_reference describes an object that can serve as a constant reference to an element of the set.
typedef reverse_iterator<const_iterator,
     value_type,const_reference, A::const_pointer,
     difference_type> const_reverse_iterator
set::const_reverse_iterator describes an object that can serve as a constant reverse bidirectional iterator for the set.
size_type count(const Key& key) const set::count returns the number of elements x in the range [lower_bound(key), upper_bound(key)).
typedef A::difference_type difference_type set::difference_type is a signed integer type that describes an object that can represent the difference between the addresses of any two elements in the set. Note that such differences are not meaningful within the context of the set.
bool empty() const set::empty returns true if the set is empty
const_iterator end() const
iterator end()
set::end returns a bidirectional iterator that points just beyond the end of the sequence.
pair<const_iterator, const_iterator>
    equal_range(const Key& key) const
set::equal_range returns a pair of iterators x such that x.first == lower_bound(key) and x.second == upper_bound(key).
iterator erase(iterator it)
iterator erase(iterator first, iterator last)
size_type erase(const Key& key)
The first version of set::erase removes the element of the controlled sequence pointed to by it. The second version removes the elements in the range [first, last). Both return an iterator that designates the first element remaining beyond any elements removed, or end() if no such element exists. The third version removes the elements with sort keys in the range [lower_bound(key), upper_bound(key)), and returns the number of elements it removes.
const_iterator find(const Key& key) const set::find returns an iterator that designates the earliest element in the controlled sequence whose sort key equals key. If no such element exists, the iterator equals end().
A get_allocator() const The member function returns allocator.
pair<iterator, bool>
    insert(const value_type& x)
iterator insert(iterator obptr, const value_type& x)
void insert(const value_type *first,
    const value_type *last)
The first version of set::insert determines whether an element y exists in the sequence whose key matches that of x. (The keys match if ! key_comp()(x, y) && !key_comp()(y, x).) If not, it creates such an element y and initializes it with x. The function then determines the iterator obptr that designates y. If an insertion occurred, the function returns pair(obptr, true). Otherwise, it returns pair(obptr, false). The second version returns insert(x), using obptr as a starting place within the controlled sequence to search for the insertion point. (Insertion can occur in amortized constant time, instead of logarithmic time, if the insertion point immediately follows obptr.) The third version inserts the sequence of element values in the range [first, last).
typedef A::pointer iterator Iterator describes an object that can serve as a bidirectional iterator for the controlled sequence. It is described here as a synonym for the pointer member of the allocator object.
key_compare key_comp() const map::key_comp returns the stored function object that determines the order of elements in the controlled sequence. The stored object defines the member function bool operator(const Key& x, const Key& y), which returns true if x strictly precedes y in the sort order.
typedef Pred key_compare map::key_compare describes a function object that can compare two sort keys to determine the relative order of any two elements in the controlled sequence. It is described here in terms of the user-defined comparator object (second template parameter).
typedef Key key_type map::key_type describes the sort key object that constitutes each element of the controlled sequence. It is described here in terms of the data type of the objects the set contains (first template parameter).
const_iterator lower_bound(const Key& key)
    const
set::lower_bound returns an iterator that designates the earliest element x in the controlled sequence for which key_comp()(x, key) is False. If no such element exists, the function returns end().
size_type max_size() const set::max_size returns the length of the longest sequence that the object can control.
explicit multiset(const Pred& comp = Pred(),
    const A& al=A())
multiset(const multiset& x)
multiset(const value_type *first,
    const value_type *last,
    const Pred& comp=Pred(), const A& al=A())
The constructors with an argument named comp store the function object so that it can be later returned by calling key_comp(). All constructors also store the allocator object al (or, for the copy constructor, x. get_allocator()) in allocator and initialize the controlled sequence. The first constructor specifies an empty initial controlled sequence. The second constructor specifies a copy of the sequence controlled by x. The third constructor specifies the sequence of element values [first, last).
This method is a member of multiset only
const_reverse_iterator rbegin() const
reverse_iterator rbegin()
set::rbegin returns a reverse iterator that points just beyond the end of the controlled sequence. Hence, it designates the beginning of the reverse sequence.
typedef A::reference reference set::reference describes an object that can be used as a reference to an element of the controlled sequence. It is described here as a synonym for the reference member of the allocator object.
const_reverse_iterator rend() const
reverse_iterator rend()
set::rend returns a reverse iterator that points at the first element of the sequence (or just beyond the end of an empty sequence). Hence, it designates the end of the reverse sequence.
typedef reverse_bidirectional_iterator<iterator,
    value_type, reference, A::types<Key>::pointer,
    difference_type> reverse_iterator
set::reverse_iterator describes an object that can serve as a reverse bidirectional iterator for the controlled sequence.
explicit set(const Pred& comp=Pred(),
    const A& al=A())
set(const set& x)
set(const value_type *first, const value_type *last,
    const Pred& comp = Pred(),
    const A& al = A())
The constructors with an argument named comp store the function object so that it can be later returned by calling key_comp(). All constructors also store the allocator object al (or, for the copy constructor, x.get_allocator()) in allocator and initialize the controlled sequence. The first constructor specifies an empty initial controlled sequence. The second constructor specifies a copy of the sequence controlled by x. The third constructor specifies the sequence of element values [first, last).
This method is a member of set only.
size_type size() const set::size returns the length of the controlled sequence.
typedef A::size_type size_type size_type is an unsigned integer type that describes an object that can represent the length of any controlled sequence.
void swap(set& str) set::swap swaps the controlled sequences between *this and str. If allocator == str.allocator, it does so in constant time. Otherwise, it performs a number of element assignments and constructor calls proportional to the number of elements in the two controlled sequences.
const_iterator upper_bound(const Key& key) const set::upper_bound returns an iterator that designates the earliest element x in the controlled sequence for which key_comp()(key, x) is true. If no such element exists, the function returns end().
value_compare value_comp() const set::valuecomp returns a function object that determines the order of elements in the controlled sequence.
typedef Pred value_compare set::value_compare describes a function object that can compare two elements as sort keys to determine their relative order in the controlled sequence. It is described herein as the user-defined comparator object (second template parameter).
typedef A::types<T>::value_type value_type The type describes an element of the controlled sequence (same as the template parameter T).

17.5 vector

Member Description
typedef A allocator_type vector::allocator_type describes the stored allocator object (same as the second template argument).
void assign(const_iterator first, const_iterator last)
void assign(size_type n, const T& x = T())
The first version of vector::assign replaces the sequence controlled by *this with the sequence [first, last). The second version replaces the sequence controlled by *this with a repetition of n elements of value x.
const_reference at(size_type pos) const
reference at(size_type pos)
vector::at returns a reference to the element of the vector at position pos. If that position is invalid, the function throws an object of class out_of_range (throws an exception).
reference back()
const_reference back() const
vector::back returns a reference to the last element of the vector, which must be nonempty.
const_iterator begin() const
iterator begin()
vector::begin returns a random-access iterator that points at the first element of the sequence (or just beyond the end of an empty sequence).
size_type capacity() const vector::capacity returns the storage currently allocated to hold the vector, a value at least as large as vector::size().
void clear() const vector::clear calls erase( begin(), end()).
typedef A::const_iterator const_iterator vector::const_iterator describes an object that can serve as a constant random-access iterator for the vector. It is described here as a synonym for the const_iterator member of the allocator object.
typedef A::const_reference const_reference vector::const_reference describes an object that can serve as a constant reference to an element of the vector.
typedef reverse_iterator<const_iterator,
    value_type, const_reference,  A::const_pointer,
    difference_type> const_reverse_iterator
vector::const_reverse_iterator describes an object that can serve as a constant reverse iterator for the vector.
typedef A::difference_type difference_type vector::difference_type is a signed integer type that describes an object that can represent the difference between the addresses of any two elements in the vector.
bool empty() const vector::empty returns true if the vector is empty
const_iterator end() const
iterator end()
vector::end returns a random-access iterator that points just beyond the end of the sequence.
iterator erase(iterator it)
iterator erase(iterator first, iterator last)
The first version of vector::erase removes the element of the controlled sequence pointed to by it. The second version removes the elements of the controlled sequence in the range [first, last). Both return an iterator that designates the first element remaining beyond any elements removed, or end() if no such element exists.
Erasing N elements causes N destructor calls and an assignment (operator=) for each of the elements between the insertion point and the end of the sequence. No reallocation occurs, so iterators and references become invalid only from the first element erased through the end of the sequence.
reference front()
const_reference front() const
vector::front returns a reference to the first element of the controlled sequence, which must be nonempty.
A get_allocator() const The member function returns allocator.
iterator insert(iterator it, const T& x = T())
void insert(iterator it, size_type n, const T& x)
void insert(iterator it, const_iterator first,
    const_iterator last)
Each version of vector::insert inserts, after the element pointed to by it in the controlled sequence, a sequence specified by the remaining operands. The first version inserts a single element with value x> and returns an iterator that points to the newly inserted element. The second version inserts a repetition of n elements of value x. The third version inserts the sequence [first, last).
When inserting a single element, the number of element copies is linear in the number of elements between the insertion point and the end of the sequence. When inserting a single element at the end of the sequence, the amortized number of element copies is constant. When inserting N elements, the number of element copies is linear in N plus the number of elements between the insertion point and the end of the sequence.
If reallocation occurs, the size of the controlled sequence at least doubles, and all iterators and references become invalid. If no reallocation occurs, iterators become invalid only from the point of insertion through the end of the sequence.
typedef A::pointer iterator Iterator describes an object that can serve as a random-access iterator for the controlled sequence. It is described here as a synonym for the pointer member of the allocator object.
size_type max_size() const vector::max_size returns the length of the longest sequence that the object can control.
const_reference operator[](size_type pos) const
reference operator[](size_type pos)
operator[] returns a reference to the element of the controlled sequence at position pos. If that position is invalid, the behavior is undefined.
void pop_back() vector::pop_back removes the last element of the controlled sequence, which must be nonempty.
void push_back(const T& x) vector::push_back inserts an element with value x at the end of the controlled sequence.
const_reverse_iterator rbegin() const
reverse_iterator rbegin()
vector::rbegin returns a reverse iterator that points just beyond the end of the controlled sequence. Hence, it designates the beginning of the reverse sequence.
typedef A::reference reference vector::reference describes an object that can be used as a reference to an element of the controlled sequence. It is described here as a synonym for the reference member of the allocator object.
const_reverse_iterator rend() const
reverse_iterator rend()
vector::rend returns a reverse iterator that points at the first element of the sequence (or just beyond the end of an empty sequence). Hence, it designates the end of the reverse sequence.
void reserve(size_type n) vector::reserve ensures that capacity() henceforth returns at least n.
void resize(size_type n, T x = T()) vector::resize ensures that size() henceforth returns n. If it must make the controlled sequence longer, it appends elements with value x.
typedef reverse_iterator<iterator, value_type,

      reference, A::types<T>::pointer,
     difference_type> reverse_iterator

The type describes an object that can serve as a reverse iterator for the controlled sequence.
size_type size() const vector::size returns the length of the controlled sequence.
typedef A::size_type size_type size_type is an unsigned integer type that describes an object that can represent the length of any controlled sequence.
void swap(vector& str) vector::swap swaps the controlled sequences between *this and str. If allocator == str.allocator, it does so in constant time. Otherwise, it performs a number of element assignments and constructor calls proportional to the number of elements in the two controlled sequences.
typedef A::types<T>::value_type value_type The type describes an element of the controlled sequence (same as the template parameter T).
explicit vector(const A& al = A())
explicit vector(size_type n, const T& v = T(),
    const A& al = A())
vector(const vector& x)
vector(const_iterator first, const_iterator last,
    const A& al = A())
All constructors store the allocator object al (or, for the copy constructor, x.get_allocator()) in allocator and initialize the controlled sequence. The first constructor specifies an empty initial controlled sequence. The second constructor specifies a repetition of n elements of value x. The third constructor specifies a copy of the sequence controlled by x. The last constructor specifies the sequence [first, last).
Constructors copy N elements and perform no interim reallocation.

17.6 priority_queue

Member Description
typedef A allocator_type priority_queue::allocator describes the allocator object used to construct the stored container object (specified by the second template parameter). The allocator is specified by the third template parameter.
bool empty() const priority_queue::empty returns true if the priority_queue is empty. Returns C.empty(), where C is the stored container object specified by priority_queue’s second template parameter.
A get_allocator() const; priority_queue::get_allocator returns C.get_allocator(), where C is the stored container object specified by priority_queue’s second template parameter.
void pop(); priority_queue::pop removes the first element of the controlled sequence, which must be nonempty, then reorders it.
explicit priority_queue(const Pred& pr=Pred(),
        const A& al = A());
priority_queue(const value_type *first,
        const value_type *last, const Pred& pr =
        Pred(), const A& al = A());
Both constructors store pr in comp and effectively initialize the stored object with c(al), to specify an empty initial controlled sequence. The second constructor then calls push(x) where x is an iterator of class InIt in the range [first, last).
void push(const T& x); priority_queue::push inserts an element with value x at the end of the controlled sequence, then reorders it.
size_type size() const; priority_queue::size returns the number of items on the priority_queue. Calls C.size, where C is the stored container object specified by priority_queue’s second template parameter.
typedef C::size_type size_type; priority_queue::size_type describes an unsigned integer type describes an object that can represent the length of any controlled sequence. It is defined here in terms of the size_type defined for the stored container object specified by priority_queue’s second template parameter.
value_type& top();
const value_type& top() const;
priority_queue::top returns a reference to the last element of the priority_queue, which must be nonempty. Calls C.back(), where C is the stored container object specified by the second template parameter.
typedef Cont::value_type value_type; priority_queue::value_type describes an element of the controlled sequence. In this context, it is the same as priority_queue’s first template parameter.

17.7 queue

Member Description
typedef A allocator_type queue::allocator describes the allocator object used to construct the stored container object (specified by the second template parameter). The allocator is specified by the third template parameter.
bool empty() const queue::empty returns true if the queue is empty. Returns C.empty(), where C is the stored container object specified by queue’s second template parameter.
value_type& front();
const value_type& front() const;
queue::front returns a reference to the first element of the queue, which must be nonempty. Calls C.back(), where C is the stored container object specified by the second template parameter. (see note at the bottom of this table)
A get_allocator() const; queue::get_allocator returns C.get_allocator(), where C is the stored container object specified by queue’s second template parameter.
void pop(); queue::pop removes the first element from the queue, which must be nonempty. Calls C.pop_front, where C is the stored container object specified by queue’s second template parameter.
void push(const T& x); queue::push(x) pushes an item with value x onto the queue. Calls C.push_back(x), where C is the stored container object specified by queue’s second template parameter.
explicit queue(const A& al = A()); The constructor initializes the stored container object C, by calling C.C(al), to specify an empty initial controlled sequence.
size_type size() const; queue::size returns the number of items on the queue. Calls C.size, where C is the stored container object specified by queue’s second template parameter.
typedef C::size_type size_type; queue::size_type describes an unsigned integer type that describes an object that can represent the length of any controlled sequence. It is defined here in terms of the size_type defined for the stored container object specified by queue’s second template parameter.
typedef Cont::value_type value_type; queue::value_type describes an element of the controlled sequence. In this context, it is the same as queue’s first template parameter.

Note   Books online for Visual C++ 4.2 says that the queue class has a top member function (like a stack). This is an error in books online. The ANSII working papers specify that queue has a front (and not a top) member function.

17.8 stack

Member Description
typedef A allocator_type stack::allocator describes the allocator object used to construct the stored container object (specified by the second template parameter). The allocator is specified by the third template parameter.
bool empty() const stack::empty returns true if the stack is empty. Returns C.empty(), where C is the stored container object specified by stack’s second template parameter.
A get_allocator() const; stack::get_allocator returns C.get_allocator(), where C is the stored container object specified by stack’s second template parameter.
void pop(); stack::pop removes the last element pushed onto the stack, which must be nonempty. Calls C.pop_back, where C is the stored container object specified by stack’s second template parameter.
void push(const T& x); stack::push(x) pushes an item with value x onto the stack. Calls C.push_back(x), where C is the stored container object specified by stack’s second template parameter.
size_type size() const; stack::size returns the number of items on the stack. Calls C.size, where C is the stored container object specified by stack’s second template parameter.
typedef C::size_type size_type; stack::size_type describes an unsigned integer type that describes an object that can represent the length of any controlled sequence. It is defined here in terms of the size_type defined for the stored container object specified by stack’s second template parameter.
explicit stack(const A& al = A()); The constructor initializes the stored container object C, by calling C.C(al), to specify an empty initial controlled sequence.
value_type& top();
const value_type& top() const;
stack::top returns a reference to the last element of the stack, which must be nonempty. Calls C.back(), where C is the stored container object specified by the second template parameter.
typedef Cont::value_type value_type; stack::value_type describes an element of the controlled sequence. In this context, it is the same as stack’s first template parameter.