A multimap is a generalization of a map or associative array abstract data type in which more than one value may be associated with and returned for a given key. Both map and multimap are particular cases of container (data structure) (see for example Standard Template Library#Containers). Often the multimap is implemented as a map with lists or sets as a values. An associative array (also map, hash, dictionary, finite map, lookup table, and in query-processing an index or index file) is an abstract data type composed of a collection of keys and a collection of values, where each key is associated with one value. ... In computing, an abstract data type (ADT) is a specification of a set of data and the set of operations that can be performed on the data. ... A container is a type of data structure. ... The Standard Template Library (STL) is a software library included in the C++ Standard Library. ... Look up list in Wiktionary, the free dictionary. ... In computer science, the set is a collection of certain values without any particular order. ...
Examples
In a student enrollment system, where students may be enrolled in multiple classes simultaneously, there might be an association for each enrollment of a student in a course, where the key is the student ID and the value is the course ID. If a student is enrolled in three courses, there will be three associations containing the same key.
The index of a book may report any number of references for a given index term, and thus may be coded as a multimap from index terms to any number of reference locations.
The member function returns an iterator that addresses an element in the multimap whose sort key is equivalent to the argument key under a binary predicate that induces an ordering based on a less than comparability relation.
The element of multimap m1 with a key of 2 is: 20.
The multimap m1 doesn't have an element with a key of 4.