Partager via


map (STL/CLR)

The template class describes an object that controls a varying-length sequence of elements that has bidirectional access. You use the container map to manage a sequence of elements as a (nearly) balanced ordered tree of nodes, each storing one element. An element consists of a key, for ordering the sequence, and a mapped value, which goes along for the ride.

In the description below, GValue is the same as:

Microsoft::VisualC::StlClr::GenericPair<GKey, GMapped>

où :

GKey is the same as Key unless the latter is a ref type, in which case it is Key^

GMapped is the same as Mapped unless the latter is a ref type, in which case it is Mapped^

template<typename Key,
    typename Mapped>
    ref class map
        :   public
        System::ICloneable,
        System::Collections::IEnumerable,
        System::Collections::ICollection,
        System::Collections::Generic::IEnumerable<GValue>,
        System::Collections::Generic::ICollection<GValue>,
        System::Collections::Generic::IList<GValue>,
        System::Collections::Generic::IDictionary<Gkey, GMapped>,
        Microsoft::VisualC::StlClr::ITree<Gkey, GValue>
    { ..... };

Paramètres

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

  • Mapped
    The type of the additional component of an element in the controlled sequence.

Membres

Type Definition

Description

mappage : : const_iterator (STL/CLR)

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

mappage : : const_reference (STL/CLR)

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

mappage : : const_reverse_iterator (STL/CLR)

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

mappage : : difference_type (STL/CLR)

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

mappage : : generic_container (STL/CLR)

The type of the generic interface for the container.

mappage : : generic_iterator (STL/CLR)

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

mappage : : generic_reverse_iterator (STL/CLR)

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

mappage : : generic_value (STL/CLR)

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

mappage : : itérateur (STL/CLR)

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

mappage : : key_compare (STL/CLR)

The ordering delegate for two keys.

mappage : : key_type (STL/CLR)

Type d'une clé de classement.

mappage : : mapped_type (STL/CLR)

The type of the mapped value associated with each key.

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

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

mappage : : reverse_iterator (STL/CLR)

The type of a reverse iterator for the controlled sequence.

mappage : : size_type (STL/CLR)

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

mappage : : value_compare (STL/CLR)

The ordering delegate for two element values.

mappage : : value_type (STL/CLR)

Le type d'un élément.

Member Function

Description

mappage : : démarrez (STL/CLR)

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

mappage : : espace libre (STL/CLR)

Removes all elements.

mappage : : nombre (STL/CLR)

Counts elements matching a specified key.

mappage : : vide (STL/CLR)

Tests whether no elements are present.

mappage : : fin (STL/CLR)

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

mappage : : equal_range (STL/CLR)

Finds range that matches a specified key.

mappage : : effacement (STL/CLR)

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

mappage : : recherche (STL/CLR)

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

mappage : : insertion (STL/CLR)

Adds elements.

mappage : : key_comp (STL/CLR)

Copies the ordering delegate for two keys.

mappage : : lower_bound (STL/CLR)

Finds beginning of range that matches a specified key.

mappage : : make_value (STL/CLR)

Constructs a value object.

mappage : : mappage (STL/CLR)

Construit un objet container.

mappage : : rbegin (STL/CLR)

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

mappage : : rend (STL/CLR)

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

mappage : : taille (STL/CLR)

Compte le nombre d'éléments.

mappage : : échange (STL/CLR)

Échange le contenu de deux conteneurs.

mappage : : to_array (STL/CLR)

Copies the controlled sequence to a new array.

mappage : : upper_bound (STL/CLR)

Finds end of range that matches a specified key.

mappage : : value_comp (STL/CLR)

Copies the ordering delegate for two element values.

Opérateur

Description

mappage : : operator= (STL/CLR)

Replaces the controlled sequence.

mappage : : operator [] (STL/CLR)

Maps a key to its associated mapped value.

opérateur ! = (mappage) (STL/CLR)

Determines if a map object is not equal to another map object.

operator< (mappage) (STL/CLR)

Determines if a map object is less than another map object.

operator<= (mappage) (STL/CLR)

Determines if a map object is less than or equal to another map object.

operator== (mappage) (STL/CLR)

Determines if a map object is equal to another map object.

operator> (mappage) (STL/CLR)

Determines if a map object is greater than another map object.

operator>= (mappage) (STL/CLR)

Determines if a map object is greater than or equal to another map object.

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.

IDictionary

Maintain group of {key, value} pairs.

ITree<Key, Value>

Maintain generic container.

Notes

The object allocates and frees storage for the sequence it controls as individual nodes. It inserts elements into a (nearly) balanced tree 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 the sequence it controls by calling a stored delegate object of type mappage : : key_compare (STL/CLR). You can specify the stored delegate object when you construct the map; if you specify no delegate object, the default is the comparison operator<(key_type, key_type). You access this stored object by calling the member function mappage : : key_comp (STL/CLR)().

Such a delegate object must impose a strict weak ordering on keys of type mappage : : 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) is true, then key_comp()(Y, X) must be false.

If key_comp()(X, Y) is true, then X is said to be ordered before Y.

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

For any element X that precedes Y in the controlled sequence, key_comp()(Y, X) is false. (For the default delegate object, keys never decrease in value.) Unlike template class map (STL/CLR), an object of template class map does not require that keys for all elements are unique. (Two or more keys can have equivalent ordering.)

Each element contains a separate key and a mapped value. The sequence is represented in a way that permits lookup, insertion, and removal of an arbitrary element with a number of operations proportional to the logarithm of the number of elements in the sequence (logarithmic time). Moreover, inserting an element invalidates no iterators, and removing an element invalidates only those iterators which point at the removed element.

A map 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 mappage : : fin (STL/CLR)(). You can decrement this iterator to reach the last element in the controlled sequence, if present. You can increment a map 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 map element directly given its numerical position -- that requires a random-access iterator.

A map iterator stores a handle to its associated map node, which in turn stores a handle to its associated container. You can use iterators only with their associated container objects. A map iterator remains valid so long as its associated map node is associated with some map. 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/map>

Namespace: cliext

Voir aussi

Référence

hash_map (STL/CLR)

hash_map (STL/CLR)

hash_multiset (STL/CLR)

hash_set (STL/CLR)

map (STL/CLR)

multiensemble (STL/CLR)

set (STL/CLR)

Autres ressources

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