Name Expression Precondition Semantics Postcondition
Range constructor X(i, j) X a(i, j); [i,j) is a valid range. Creates an associative container that contains all elements in the range [i,j), using hasher() as the hash function and key_equal() as the key equality function. size() is equal to the distance from i to j. The bucket count is an unspecified default value. The hash function is hasher(), and the key equality function is key_equal() .
Range constructor with bucket count X(i, j, n) X a(i, j, n); [i,j) is a valid range. Creates an associative container that contains all elements in the range [i,j), using at least n buckets, and using hasher() as the hash function and key_equal() as the key equality function. size() is equal to the distance from i to j. The bucket count is greater than or equal to n. The hash function is hasher(), and the key equality function is key_equal().
Range constructor with hash function X(i, j, n, h) X a(i, j, n, h); [i,j) is a valid range. Creates an associative container that contains all elements in the range [i,j), using at least n buckets, and using h as the hash function and key_equal() as the key equality function. size() is equal to the distance from i to j. The bucket count is greater than or equal to n. The hash function is h, and the key equality function is key_equal() .
Range constructor with key equal X(i, j, n, h, k) X a(i, j, n, h, k); [i,j) is a valid range. Creates an associative container that contains all elements in the range [i,j) , using at least n buckets, and using h as the hash function and k as the key equality function. size() is equal to the distance from i to j. The bucket count is greater than or equal to n. The hash function is h , and the key equality function is k.
Complexity guarantees

The range constructor, range constructor with bucket count, range constructor with hash function, and range constructor with key equal, are all linear in j – i.

Models

• hash_multiset

• hash_multimap

Notes

[1] At present (early 1998), not all compilers support 'member templates'. If your compiler supports member templates then i and j may be of any type that conforms to the Input Iterator requirements. If your compiler does not yet support member templates, however, then i and j must be of type const T* or of type X::const_iterator.

See also

Associative Container, Hashed Associative Container, Unique Hashed Associative Container, Sorted Associative Container

Container classes

Sequences

vector<T, Alloc>

Category: containers

Component type: type

Description

A vector is a Sequence that supports random access to elements, constant time insertion and removal of elements at the end, and linear time insertion and removal of elements at the beginning or in the middle. The number of elements in a vector may vary dynamically; memory management is automatic. Vector is the simplest of the STL container classes, and in many cases the most efficient.

Example

vector<int> V;

V.insert(V.begin(), 3);

assert(V.size() == 1 && V.capacity() >= 1 && V[0] == 3);

Добавить отзыв
ВСЕ ОТЗЫВЫ О КНИГЕ В ИЗБРАННОЕ

0

Вы можете отметить интересные вам фрагменты текста, которые будут доступны по уникальной ссылке в адресной строке браузера.

Отметить Добавить цитату