Partager via


hash_multiset (STL/CLR)

The template class describes an object that controls a varying-length sequence of elements that has bidirectional access. You use the container hash_multiset to manage a sequence of elements as a hash table, each table entry storing a bidirectional linked list of nodes, and each node storing one element. The value of each element is used as a key, for ordering the sequence.

In the description below, GValue is the same as GKey, which in turn is the same as Key unless the latter is a ref type, in which case it is Key^.

template<typename Key>
    ref class hash_multiset
        :   public
        System::ICloneable,
        System::Collections::IEnumerable,
        System::Collections::ICollection,
        System::Collections::Generic::IEnumerable<GValue>,
        System::Collections::Generic::ICollection<GValue>,
        System::Collections::Generic::IList<GValue>,
        Microsoft::VisualC::StlClr::IHash<Gkey, GValue>
    { ..... };

Paramètres

  • Clé
    Type du composant clé d'un élément dans la séquence contrôlée.

Membres

Type Definition

Description

hash_multiset : : const_iterator (STL/CLR)

Type d'un itérateur constant pour la séquence contrôlée.

hash_multiset : : const_reference (STL/CLR)

Type d'une référence constante à un élément.

hash_multiset : : const_reverse_iterator (STL/CLR)

The type of a constant reverse iterator for the controlled sequence.

hash_multiset : : difference_type (STL/CLR)

The type of a (possibly signed) distance between two elements.

hash_multiset : : generic_container (STL/CLR)

The type of the generic interface for the container.

hash_multiset : : generic_iterator (STL/CLR)

The type of an iterator for the generic interface for the container.

hash_multiset : : generic_reverse_iterator (STL/CLR)

The type of a reverse iterator for the generic interface for the container.

hash_multiset : : generic_value (STL/CLR)

The type of an element for the generic interface for the container.

hash_multiset : : hasher (STL/CLR)

The hashing delegate for a key.

hash_multiset : : itérateur (STL/CLR)

Type d'un itérateur pour la séquence contrôlée.

hash_multiset : : key_compare (STL/CLR)

The ordering delegate for two keys.

hash_multiset : : key_type (STL/CLR)

Type d'une clé de classement.

hash_multiset : : référence (STL/CLR)

Type d'une référence à un élément.

hash_multiset : : reverse_iterator (STL/CLR)

The type of a reverse iterator for the controlled sequence.

hash_multiset : : size_type (STL/CLR)

The type of a (non-negative) distance between two elements.

hash_multiset : : value_compare (STL/CLR)

The ordering delegate for two element values.

hash_multiset : : value_type (STL/CLR)

Le type d'un élément.

Member Function

Description

hash_multiset : : démarrez (STL/CLR)

Désigne le début de la séquence contrôlée.

hash_multiset : : bucket_count (STL/CLR)

Counts the number of buckets.

hash_multiset : : espace libre (STL/CLR)

Removes all elements.

hash_multiset : : nombre (STL/CLR)

Counts elements matching a specified key.

hash_multiset : : vide (STL/CLR)

Tests whether no elements are present.

hash_multiset : : fin (STL/CLR)

Désigne la fin de la séquence contrôlée.

hash_multiset : : equal_range (STL/CLR)

Finds range that matches a specified key.

hash_multiset : : effacement (STL/CLR)

Supprime les éléments placés aux positions spécifiées.

hash_multiset : : recherche (STL/CLR)

Recherche un élément qui correspond à une clé spécifiée.

hash_multiset : : hash_delegate (STL/CLR)

Copies the hashing delegate for a key.

hash_multiset : : hash_multiset (STL/CLR)

Construit un objet container.

hash_multiset : : insertion (STL/CLR)

Adds elements.

hash_multiset : : key_comp (STL/CLR)

Copies the ordering delegate for two keys.

hash_multiset : : load_factor (STL/CLR)

Counts the average elements per bucket.

hash_multiset : : lower_bound (STL/CLR)

Finds beginning of range that matches a specified key.

hash_multiset : : make_value (STL/CLR)

Constructs a value object.

hash_multiset : : max_load_factor (STL/CLR)

Gets or sets the maximum elements per bucket.

hash_multiset : : rbegin (STL/CLR)

Désigne le début de la séquence contrôlée inversée.

hash_multiset : : réchauffé (STL/CLR)

Régénère la table de hachage.

hash_multiset : : rend (STL/CLR)

Désigne la fin de la séquence contrôlée inversée.

hash_multiset : : taille (STL/CLR)

Compte le nombre d'éléments.

hash_multiset : : échange (STL/CLR)

Échange le contenu de deux conteneurs.

hash_multiset : : to_array (STL/CLR)

Copies the controlled sequence to a new array.

hash_multiset : : upper_bound (STL/CLR)

Finds end of range that matches a specified key.

hash_multiset : : value_comp (STL/CLR)

Copies the ordering delegate for two element values.

Opérateur

Description

hash_multiset : : operator= (STL/CLR)

Replaces the controlled sequence.

Interfaces

Interface

Description

ICloneable

Duplicate an object.

IEnumerable

Sequence through elements.

ICollection

Maintain group of elements.

IEnumerable

Sequence through typed elements.

ICollection

Maintain group of typed elements.

IHash<Key, Value>

Maintain generic container.

Notes

The object allocates and frees storage for the sequence it controls as individual nodes in a bidirectional linked list. To speed access, the object also maintains a varying-length array of pointers into the list (the hash table), effectively managing the whole list as a sequence of sublists, or buckets. It inserts elements into a bucket that it keeps ordered by altering the links between nodes, never by copying the contents of one node to another. That means you can insert and remove elements freely without disturbing remaining elements.

The object orders each bucket it controls by calling a stored delegate object of type hash_set : : key_compare (STL/CLR). You can specify the stored delegate object when you construct the hash_set; if you specify no delegate object, the default is the comparison operator<=(key_type, key_type).

You access the stored delegate object by calling the member function hash_set : : key_comp (STL/CLR)(). Such a delegate object must define equivalent ordering between keys of type hash_set : : key_type (STL/CLR). That means, for any two keys X and Y:

key_comp()(X, Y) returns the same Boolean result on every call.

If key_comp()(X, Y) && key_comp()(Y, X) is true, then X and Y are said to have equivalent ordering.

Any ordering rule that behaves like operator<=(key_type, key_type), operator>=(key_type, key_type) or operator==(key_type, key_type) defines eqivalent ordering.

Note that the container ensures only that elements whose keys have equivalent ordering (and which hash to the same integer value) are adjacent within a bucket. Unlike template class hash_set (STL/CLR), an object of template class hash_multiset does not require that keys for all elements are unique. (Two or more keys can have equivalent ordering.)

The object determines which bucket should contain a given ordering key by calling a stored delegate object of type hash_set : : hasher (STL/CLR). You access this stored object by calling the member function hash_set : : hash_delegate (STL/CLR)() to obtain an integer value that depends on the key value. You can specify the stored delegate object when you construct the hash_set; if you specify no delegate object, the default is the function System::Object::hash_value(key_type). That means, for any keys X and Y:

hash_delegate()(X) returns the same integer result on every call.

If X and Y have equivalent ordering, then hash_delegate()(X) should return the same integer result as hash_delegate()(Y).

Each element serves as both a key and a value. The sequence is represented in a way that permits lookup, insertion, and removal of an arbitrary element with a number of operations that is independent of the number of elements in the sequence (constant time) -- at least in the best of cases. Moreover, inserting an element invalidates no iterators, and removing an element invalidates only those iterators which point at the removed element.

If hashed values are not uniformly distributed, however, a hash table can degenerate. In the extreme -- for a hash function that always returns the same value -- lookup, insertion, and removal are proportional to the number of elements in the sequence (linear time). The container endeavors to choose a reasonable hash function, mean bucket size, and hash-table size (total number of buckets), but you can override any or all of these choices. See, for example, the functions hash_set : : max_load_factor (STL/CLR) and hash_set : : réchauffé (STL/CLR).

A hash_multiset supports bidirectional iterators, which means you can step to adjacent elements given an iterator that designates an element in the controlled sequence. A special head node corresponds to the iterator returned by hash_multiset : : fin (STL/CLR)(). You can decrement this iterator to reach the last element in the controlled sequence, if present. You can increment a hash_multiset iterator to reach the head node, and it will then compare equal to end(). But you cannot dereference the iterator returned by end().

Note that you cannot refer to a hash_multiset element directly given its numerical position -- that requires a random-access iterator.

A hash_multiset iterator stores a handle to its associated hash_multiset node, which in turn stores a handle to its associated container. You can use iterators only with their associated container objects. A hash_multiset iterator remains valid so long as its associated hash_multiset node is associated with some hash_multiset. Moreover, a valid iterator is dereferencable -- you can use it to access or alter the element value it designates -- so long as it is not equal to end().

Erasing or removing an element calls the destructor for its stored value. Destroying the container erases all elements. Thus, a container whose element type is a ref class ensures that no elements outlive the container. Note, however, that a container of handles does not destroy its elements.

Configuration requise

Header: <cliext/hash_set>

Namespace: cliext

Voir aussi

Référence

hash_map (STL/CLR)

hash_multiset (STL/CLR)

hash_set (STL/CLR)

map (STL/CLR)

multiensemble (STL/CLR)

multiensemble (STL/CLR)

set (STL/CLR)

Autres ressources

Référence de bibliothèque STL/CLR