Name | Expression | Precondition | Semantics | Postcondition |
Default constructor | X() X a; | | Creates an empty container, using hasher() as the hash function and key_equal() as the key equality function. | The size of the container is 0. The bucket count is an unspecified default value. The hash function is hasher(), and the key equality function is key_equal(). |
Constructor with bucket count | X(n) X a(n); | | Creates an empty container with at least n buckets, using hasher() as the hash function and key_equal() as the key equality function. | The size of the container is 0. The bucket count is greater than or equal to n. The hash function is hasher(), and the key equality function is key_equal(). |
Constructor with hash function | X(n, h) X a(n, h); | | Creates an empty container with at least n buckets, using h as the hash function and key_equal() as the key equality function. | The size of the container is 0. The bucket count is greater than or equal to n. The hash function is h, and the key equality function is key_equal(). |
Constructor with key equal | X(n, h, k) X a(n, h, k); | | Creates an empty container with at least n buckets, using h as the hash function and k as the key equality function. The size of the container is 0. | The bucket count is greater than or equal to n. The hash function is h, and the key equality function is k. |
Hash function | a.hash_funct() | | Returns the hash function used by a. | |
Key equal | a.key_eq() | | Returns the key equal function used by a. | |
Erase key | a.erase(k) | | Destroys all elements whose key is the same as k, and removes them from a. [2]The return value is the number of elements that were erased, i.e. the old value of a.count(k). | a.size() is decremented by a.count(k) . a contains no elements with key k. |
Erase element | a.erase(p) | p is a dereferenceable iterator in a. |