Chemical Data Processing Library C++ API - Version 1.2.0
Public Types | Public Member Functions | Protected Member Functions | List of all members
CDPL::Util::MultiMap< Key, Value, AllowDefValues, KeyCompFunc > Class Template Reference

A multiple sorted associative container that maps keys to values. More...

#include <MultiMap.hpp>

+ Inheritance diagram for CDPL::Util::MultiMap< Key, Value, AllowDefValues, KeyCompFunc >:

Public Types

typedef std::shared_ptr< MultiMapSharedPointer
 A reference-counted smart pointer [SHPTR] for dynamically allocated MultiMap instances. More...
 
typedef Key KeyType
 The type of the map's keys. More...
 
typedef Value ValueType
 The type of the mapped values. More...
 
typedef StorageType::value_type Entry
 The type of the key/value pairs stored in the map. More...
 
typedef StorageType::const_iterator ConstEntryIterator
 A constant iterator used to iterate over the entries of the map. More...
 
typedef StorageType::const_reverse_iterator ConstReverseEntryIterator
 A constant iterator used to iterate backwards over the entries of the map. More...
 
typedef StorageType::iterator EntryIterator
 A mutable iterator used to iterate over the entries of the map. More...
 
typedef StorageType::reverse_iterator ReverseEntryIterator
 A mutable iterator used to iterate backwards over the entries of the map. More...
 
typedef std::pair< EntryIterator, EntryIteratorEntryIteratorRange
 A pair of mutable iterators used to specify the start and end of a range of entries. More...
 
typedef std::pair< ConstEntryIterator, ConstEntryIteratorConstEntryIteratorRange
 A pair of constant iterators used to specify the start and end of a range of entries. More...
 

Public Member Functions

 MultiMap ()
 Creates an empty map. More...
 
 MultiMap (const KeyCompFunc &func)
 Creates an empty map and uses func as key compare function. More...
 
template<typename InputIter >
 MultiMap (const InputIter &first, const InputIter &last)
 Creates and initializes the map with copies of the key value pairs in the range [first, last). More...
 
template<typename InputIter >
 MultiMap (const InputIter &first, const InputIter &last, const KeyCompFunc &func)
 Creates and initializes the map with copies of the key value pairs in the range [first, last) and uses func as key compare function. More...
 
virtual ~MultiMap ()
 Virtual destructor. More...
 
StorageType & getData ()
 
const StorageType & getData () const
 
std::size_t getSize () const
 Returns the size (number of entries) of the map. More...
 
bool isEmpty () const
 Tells whether the map is empty (getSize() == 0). More...
 
void clear ()
 Erases all entries. More...
 
void swap (MultiMap &map)
 Swaps the contents with map. More...
 
KeyCompFunc getKeyCompareFunction () const
 Returns the key compare function used by the map. More...
 
std::size_t getNumEntries (const Key &key) const
 Returns the number of entries with the specified key. More...
 
EntryIteratorRange getEntries (const Key &key)
 Returns the bounds of a range that includes all entries with a key that compares equal to the specified key. More...
 
ConstEntryIteratorRange getEntries (const Key &key) const
 Returns the bounds of a range that includes all entries with a key that compares equal to the specified key. More...
 
EntryIterator getEntry (const Key &key)
 Returns a mutable iterator pointing to the first entry with the specified key. More...
 
ConstEntryIterator getEntry (const Key &key) const
 Returns a constant iterator pointing to the first entry with the specified key. More...
 
Value & getValue (const Key &key)
 Returns a non-const reference to the first value associated with the specified key. More...
 
Value & getValue (const Key &key, Value &def_value)
 Returns a non-const reference to the first value associated with the specified key, or the value given by the second argument if an entry with the given key does not exist. More...
 
const Value & getValue (const Key &key) const
 Returns a const reference to the first value associated with the specified key. More...
 
const Value & getValue (const Key &key, const Value &def_value) const
 Returns a const reference to the first value associated with the specified key, or the value given by the second argument if an entry with the given key does not exist. More...
 
Value & operator[] (const Key &key)
 Returns a non-const reference to the first value associated with the specified key. More...
 
const Value & operator[] (const Key &key) const
 Returns a const reference to the first value associated with the specified key. More...
 
void removeEntry (const EntryIterator &it)
 Removes the entry pointed to by the iterator it from the map. More...
 
bool removeEntry (const Key &key)
 Removes the first entry with the specified key from the map. More...
 
void removeEntries (const EntryIterator &first, const EntryIterator &last)
 Removes all entries pointed to by the iterators in the range [first, last) from the map. More...
 
std::size_t removeEntries (const Key &key)
 Removes all entries with the specified key from the map. More...
 
EntryIterator insertEntry (const Entry &item)
 Inserts the key/value pair item into the map. More...
 
EntryIterator insertEntry (const Key &key, const Value &value)
 Inserts a new entry with specified key and value into the map. More...
 
EntryIterator insertEntry (const EntryIterator &it, const Entry &item)
 Inserts the key/value pair item into the map and uses the iterator it as a hint for the insertion location. More...
 
EntryIterator insertEntry (const EntryIterator &it, const Key &key, const Value &value)
 Inserts a new entry with the specified key and value into the map and uses the iterator it as a hint for the insertion location. More...
 
EntryIterator setEntry (const Entry &item)
 Replaces all entries with a key equivalent to that of item with a single entry specified by item. More...
 
EntryIterator setEntry (const Key &key, const Value &value)
 Replaces all entries with a key equivalent to key with a single copy of the key/value pair (key, value). More...
 
template<typename InputIter >
void insertEntries (const InputIter &first, const InputIter &last)
 Inserts the key/value pairs in the range [first, last) into the map. More...
 
template<typename InputIter >
void setEntries (const InputIter &first, const InputIter &last)
 Inserts new entries or updates the value of existing entries using the key/value pairs in the range [first, last). More...
 
EntryIterator getLowerBound (const Key &key)
 Returns a mutable iterator pointing to the first entry whose key is not less than the specified key. More...
 
ConstEntryIterator getLowerBound (const Key &key) const
 Returns a constant iterator pointing to the first entry whose key is not less than the specified key. More...
 
EntryIterator getUpperBound (const Key &key)
 Returns a mutable iterator pointing to the first entry whose key is greater than the specified key. More...
 
ConstEntryIterator getUpperBound (const Key &key) const
 Returns a constant iterator pointing to the first entry whose key is greater than the specified key. More...
 
ConstEntryIterator getEntriesBegin () const
 Returns a constant iterator pointing to the beginning of the map. More...
 
EntryIterator getEntriesBegin ()
 Returns a mutable iterator pointing to the beginning of the map. More...
 
ConstEntryIterator getEntriesEnd () const
 Returns a constant iterator pointing to the end of the map. More...
 
EntryIterator getEntriesEnd ()
 Returns a mutable iterator pointing to the end of the map. More...
 
ConstEntryIterator begin () const
 Returns a constant iterator pointing to the beginning of the map. More...
 
EntryIterator begin ()
 Returns a mutable iterator pointing to the beginning of the map. More...
 
ConstEntryIterator end () const
 Returns a constant iterator pointing to the end of the map. More...
 
EntryIterator end ()
 Returns a mutable iterator pointing to the end of the map. More...
 
ConstReverseEntryIterator getEntriesReverseBegin () const
 Returns a constant iterator pointing to the beginning of the reversed map. More...
 
ReverseEntryIterator getEntriesReverseBegin ()
 Returns a mutable iterator pointing to the beginning of the reversed map. More...
 
ConstReverseEntryIterator getEntriesReverseEnd () const
 Returns a constant iterator pointing to the end of the reversed map. More...
 
ReverseEntryIterator getEntriesReverseEnd ()
 Returns a mutable iterator pointing to the end of the reversed map. More...
 

Protected Member Functions

virtual const char * getClassName () const
 Returns the name of the (derived) Map class. More...
 

Detailed Description

template<typename Key, typename Value, bool AllowDefValues = false, typename KeyCompFunc = std::less<Key>>
class CDPL::Util::MultiMap< Key, Value, AllowDefValues, KeyCompFunc >

A multiple sorted associative container that maps keys to values.

Since MultiMap is a sorted associative container, it uses an ordering relation on its keys. Two keys are considered to be equivalent if neither one is less than the other. MultiMap guarantees that the complexity for most operations is never worse than logarithmic, and the entries are always sorted in ascending order by key. It is also a multiple associative container, meaning that there is no limit on the number of entries with the same key. MultiMap has the important property that inserting a new entry does not invalidate iterators that point to existing entries. Erasing an entry also does not invalidate any iterators, except, of course, for iterators that actually point to the entry that is being erased.

Template Parameters
KeyThe type of the map's keys.
ValueThe type of the mapped values.
AllowDefValuesWhether to return a default value or to throw an exception if a key/value entry is not present in the map.
KeyCompFuncThe type of a functor class used to establish the strictly weak ordering on the map's keys. The functor has to return true if the first argument is less than the second one, and false otherwise.

Member Typedef Documentation

◆ SharedPointer

template<typename Key , typename Value , bool AllowDefValues = false, typename KeyCompFunc = std::less<Key>>
typedef std::shared_ptr<MultiMap> CDPL::Util::MultiMap< Key, Value, AllowDefValues, KeyCompFunc >::SharedPointer

A reference-counted smart pointer [SHPTR] for dynamically allocated MultiMap instances.

◆ KeyType

template<typename Key , typename Value , bool AllowDefValues = false, typename KeyCompFunc = std::less<Key>>
typedef Key CDPL::Util::MultiMap< Key, Value, AllowDefValues, KeyCompFunc >::KeyType

The type of the map's keys.

◆ ValueType

template<typename Key , typename Value , bool AllowDefValues = false, typename KeyCompFunc = std::less<Key>>
typedef Value CDPL::Util::MultiMap< Key, Value, AllowDefValues, KeyCompFunc >::ValueType

The type of the mapped values.

◆ Entry

template<typename Key , typename Value , bool AllowDefValues = false, typename KeyCompFunc = std::less<Key>>
typedef StorageType::value_type CDPL::Util::MultiMap< Key, Value, AllowDefValues, KeyCompFunc >::Entry

The type of the key/value pairs stored in the map.

The member Entry::first is the const key object of type Key and the member Entry::second is the associated value object of type Value.

◆ ConstEntryIterator

template<typename Key , typename Value , bool AllowDefValues = false, typename KeyCompFunc = std::less<Key>>
typedef StorageType::const_iterator CDPL::Util::MultiMap< Key, Value, AllowDefValues, KeyCompFunc >::ConstEntryIterator

A constant iterator used to iterate over the entries of the map.

◆ ConstReverseEntryIterator

template<typename Key , typename Value , bool AllowDefValues = false, typename KeyCompFunc = std::less<Key>>
typedef StorageType::const_reverse_iterator CDPL::Util::MultiMap< Key, Value, AllowDefValues, KeyCompFunc >::ConstReverseEntryIterator

A constant iterator used to iterate backwards over the entries of the map.

◆ EntryIterator

template<typename Key , typename Value , bool AllowDefValues = false, typename KeyCompFunc = std::less<Key>>
typedef StorageType::iterator CDPL::Util::MultiMap< Key, Value, AllowDefValues, KeyCompFunc >::EntryIterator

A mutable iterator used to iterate over the entries of the map.

◆ ReverseEntryIterator

template<typename Key , typename Value , bool AllowDefValues = false, typename KeyCompFunc = std::less<Key>>
typedef StorageType::reverse_iterator CDPL::Util::MultiMap< Key, Value, AllowDefValues, KeyCompFunc >::ReverseEntryIterator

A mutable iterator used to iterate backwards over the entries of the map.

◆ EntryIteratorRange

template<typename Key , typename Value , bool AllowDefValues = false, typename KeyCompFunc = std::less<Key>>
typedef std::pair<EntryIterator, EntryIterator> CDPL::Util::MultiMap< Key, Value, AllowDefValues, KeyCompFunc >::EntryIteratorRange

A pair of mutable iterators used to specify the start and end of a range of entries.

◆ ConstEntryIteratorRange

template<typename Key , typename Value , bool AllowDefValues = false, typename KeyCompFunc = std::less<Key>>
typedef std::pair<ConstEntryIterator, ConstEntryIterator> CDPL::Util::MultiMap< Key, Value, AllowDefValues, KeyCompFunc >::ConstEntryIteratorRange

A pair of constant iterators used to specify the start and end of a range of entries.

Constructor & Destructor Documentation

◆ MultiMap() [1/4]

template<typename Key , typename Value , bool AllowDefValues = false, typename KeyCompFunc = std::less<Key>>
CDPL::Util::MultiMap< Key, Value, AllowDefValues, KeyCompFunc >::MultiMap ( )
inline

Creates an empty map.

◆ MultiMap() [2/4]

template<typename Key , typename Value , bool AllowDefValues = false, typename KeyCompFunc = std::less<Key>>
CDPL::Util::MultiMap< Key, Value, AllowDefValues, KeyCompFunc >::MultiMap ( const KeyCompFunc &  func)
inline

Creates an empty map and uses func as key compare function.

Parameters
funcThe key compare function to use.

◆ MultiMap() [3/4]

template<typename Key , typename Value , bool AllowDefValues = false, typename KeyCompFunc = std::less<Key>>
template<typename InputIter >
CDPL::Util::MultiMap< Key, Value, AllowDefValues, KeyCompFunc >::MultiMap ( const InputIter &  first,
const InputIter &  last 
)
inline

Creates and initializes the map with copies of the key value pairs in the range [first, last).

Parameters
firstThe start of the range.
lastThe end of the range.

◆ MultiMap() [4/4]

template<typename Key , typename Value , bool AllowDefValues = false, typename KeyCompFunc = std::less<Key>>
template<typename InputIter >
CDPL::Util::MultiMap< Key, Value, AllowDefValues, KeyCompFunc >::MultiMap ( const InputIter &  first,
const InputIter &  last,
const KeyCompFunc &  func 
)
inline

Creates and initializes the map with copies of the key value pairs in the range [first, last) and uses func as key compare function.

Parameters
firstThe start of the range.
lastThe end of the range.
funcThe key compare function to use.

◆ ~MultiMap()

template<typename Key , typename Value , bool AllowDefValues = false, typename KeyCompFunc = std::less<Key>>
virtual CDPL::Util::MultiMap< Key, Value, AllowDefValues, KeyCompFunc >::~MultiMap ( )
inlinevirtual

Virtual destructor.

Member Function Documentation

◆ getData() [1/2]

template<typename Key , typename Value , bool AllowDefValues, typename KeyCompFunc >
CDPL::Util::MultiMap< Key, Value, AllowDefValues, KeyCompFunc >::StorageType & CDPL::Util::MultiMap< Key, Value, AllowDefValues, KeyCompFunc >::getData

◆ getData() [2/2]

template<typename Key , typename Value , bool AllowDefValues, typename KeyCompFunc >
const CDPL::Util::MultiMap< Key, Value, AllowDefValues, KeyCompFunc >::StorageType & CDPL::Util::MultiMap< Key, Value, AllowDefValues, KeyCompFunc >::getData

◆ getSize()

template<typename Key , typename Value , bool AllowDefValues, typename KeyCompFunc >
std::size_t CDPL::Util::MultiMap< Key, Value, AllowDefValues, KeyCompFunc >::getSize

Returns the size (number of entries) of the map.

Returns
The size of the map.

◆ isEmpty()

template<typename Key , typename Value , bool AllowDefValues, typename KeyCompFunc >
bool CDPL::Util::MultiMap< Key, Value, AllowDefValues, KeyCompFunc >::isEmpty

Tells whether the map is empty (getSize() == 0).

Returns
true if the map is empty, and false otherwise.

◆ clear()

template<typename Key , typename Value , bool AllowDefValues, typename KeyCompFunc >
void CDPL::Util::MultiMap< Key, Value, AllowDefValues, KeyCompFunc >::clear

Erases all entries.

◆ swap()

template<typename Key , typename Value , bool AllowDefValues, typename KeyCompFunc >
void CDPL::Util::MultiMap< Key, Value, AllowDefValues, KeyCompFunc >::swap ( MultiMap< Key, Value, AllowDefValues, KeyCompFunc > &  map)

Swaps the contents with map.

Parameters
mapThe other map with which the contents will be exchanged.

◆ getKeyCompareFunction()

template<typename Key , typename Value , bool AllowDefValues, typename KeyCompFunc >
KeyCompFunc CDPL::Util::MultiMap< Key, Value, AllowDefValues, KeyCompFunc >::getKeyCompareFunction

Returns the key compare function used by the map.

Returns
The key compare function.

◆ getNumEntries()

template<typename Key , typename Value , bool AllowDefValues, typename KeyCompFunc >
std::size_t CDPL::Util::MultiMap< Key, Value, AllowDefValues, KeyCompFunc >::getNumEntries ( const Key &  key) const

Returns the number of entries with the specified key.

Parameters
keyThe key of the entries to count.
Returns
The number of entries with the specified key.

◆ getEntries() [1/2]

template<typename Key , typename Value , bool AllowDefValues, typename KeyCompFunc >
CDPL::Util::MultiMap< Key, Value, AllowDefValues, KeyCompFunc >::EntryIteratorRange CDPL::Util::MultiMap< Key, Value, AllowDefValues, KeyCompFunc >::getEntries ( const Key &  key)

Returns the bounds of a range that includes all entries with a key that compares equal to the specified key.

If key does not match any key in the container, the range returned has a length of zero, with both iterators pointing to the entry with the nearest key greater than key, if any, or to getEntriesEnd() if key is greater than all the keys in the map.

Parameters
keyThe key specifying the entries.
Returns
A pair of mutable iterators specifying the start and end of the sequence of entries with the specified key.

◆ getEntries() [2/2]

template<typename Key , typename Value , bool AllowDefValues, typename KeyCompFunc >
CDPL::Util::MultiMap< Key, Value, AllowDefValues, KeyCompFunc >::ConstEntryIteratorRange CDPL::Util::MultiMap< Key, Value, AllowDefValues, KeyCompFunc >::getEntries ( const Key &  key) const

Returns the bounds of a range that includes all entries with a key that compares equal to the specified key.

If key does not match any key in the container, the range returned has a length of zero, with both iterators pointing to the entry with the nearest key greater than the specified key, if any, or to getEntriesEnd() if key is greater than all the keys in the map.

Parameters
keyThe key specifying the entries.
Returns
A pair of constant iterators specifying the start and end of the sequence of entries with the specified key.

◆ getEntry() [1/2]

template<typename Key , typename Value , bool AllowDefValues, typename KeyCompFunc >
CDPL::Util::MultiMap< Key, Value, AllowDefValues, KeyCompFunc >::EntryIterator CDPL::Util::MultiMap< Key, Value, AllowDefValues, KeyCompFunc >::getEntry ( const Key &  key)

Returns a mutable iterator pointing to the first entry with the specified key.

If the map does not contain an entry with the specified key, an iterator pointing one past the last entry of the map (== getEntriesEnd()) is returned.

Parameters
keyThe key specifying the entry.
Returns
A mutable iterator pointing the first entry with the specified key, or getEntriesEnd() if the map contains no such entry.

◆ getEntry() [2/2]

template<typename Key , typename Value , bool AllowDefValues, typename KeyCompFunc >
CDPL::Util::MultiMap< Key, Value, AllowDefValues, KeyCompFunc >::ConstEntryIterator CDPL::Util::MultiMap< Key, Value, AllowDefValues, KeyCompFunc >::getEntry ( const Key &  key) const

Returns a constant iterator pointing to the first entry with the specified key.

If the map does not contain an entry with the specified key, an iterator pointing one past the last entry of the map (== getEntriesEnd()) is returned.

Parameters
keyThe key specifying the entry.
Returns
A constant iterator pointing the first entry with the specified key, or getEntriesEnd() if the map contains no such entry.

◆ getValue() [1/4]

template<typename Key , typename Value , bool AllowDefValues, typename KeyCompFunc >
Value & CDPL::Util::MultiMap< Key, Value, AllowDefValues, KeyCompFunc >::getValue ( const Key &  key)

Returns a non-const reference to the first value associated with the specified key.

If the map contains an entry with the specified key, a reference to the associated value is returned. If the map does not contain the entry and default values are enabled (that is, the template parameter AllowDefValues is true), a new map entry is created which associates key with the default constructed value object. Otherwise, Base::ItemNotFound is thrown to indicate the error.

Parameters
keyThe key associated with the requested value.
Returns
A non-const reference to the requested value.
Exceptions
Base::ItemNotFoundif AllowDefValues is false and the map does not contain an entry with the specified key.

◆ getValue() [2/4]

template<typename Key , typename Value , bool AllowDefValues, typename KeyCompFunc >
Value & CDPL::Util::MultiMap< Key, Value, AllowDefValues, KeyCompFunc >::getValue ( const Key &  key,
Value &  def_value 
)

Returns a non-const reference to the first value associated with the specified key, or the value given by the second argument if an entry with the given key does not exist.

If the map contains an entry with the specified key, a reference to the associated value is returned. If the map does not contain the entry, the second argument def_value is returned.

Parameters
keyThe key associated with the requested value.
def_valueThe value which is returned if the specified entry does not exist.
Returns
A non-const reference to the requested or default value.

◆ getValue() [3/4]

template<typename Key , typename Value , bool AllowDefValues, typename KeyCompFunc >
const Value & CDPL::Util::MultiMap< Key, Value, AllowDefValues, KeyCompFunc >::getValue ( const Key &  key) const

Returns a const reference to the first value associated with the specified key.

If the map contains the specified entry, a reference to the associated value is returned. If the map does not contain the entry and default values are enabled (that is, the template parameter AllowDefValues is true), a const reference to a default constructed value object is returned. Otherwise, Base::ItemNotFound is thrown to indicate the error.

Parameters
keyThe key associated with the requested value.
Returns
A const reference to the requested value.
Exceptions
Base::ItemNotFoundif AllowDefValues is false and the map does not contain an entry with the specified key.
See also
getValue(const Key&) const

◆ getValue() [4/4]

template<typename Key , typename Value , bool AllowDefValues, typename KeyCompFunc >
const Value & CDPL::Util::MultiMap< Key, Value, AllowDefValues, KeyCompFunc >::getValue ( const Key &  key,
const Value &  def_value 
) const

Returns a const reference to the first value associated with the specified key, or the value given by the second argument if an entry with the given key does not exist.

If the map contains an entry with the specified key, a reference to the associated value is returned. If the map does not contain the entry, the second argument def_value is returned.

Parameters
keyThe key associated with the requested value.
def_valueThe value which is returned if the specified entry does not exist.
Returns
A const reference to the requested or default value.

◆ operator[]() [1/2]

template<typename Key , typename Value , bool AllowDefValues, typename KeyCompFunc >
Value & CDPL::Util::MultiMap< Key, Value, AllowDefValues, KeyCompFunc >::operator[] ( const Key &  key)

Returns a non-const reference to the first value associated with the specified key.

The method is equivalent to getValue(const Key&).

Parameters
keyThe key associated with the requested value.
Returns
A non-const reference to the requested value.
Exceptions
Base::ItemNotFoundif AllowDefValues is false and the map does not contain an entry with the specified key.
See also
getValue(const Key&)

◆ operator[]() [2/2]

template<typename Key , typename Value , bool AllowDefValues, typename KeyCompFunc >
const Value & CDPL::Util::MultiMap< Key, Value, AllowDefValues, KeyCompFunc >::operator[] ( const Key &  key) const

Returns a const reference to the first value associated with the specified key.

The method is equivalent to getValue(const Key&) const.

Parameters
keyThe key associated with the requested value.
Returns
A const reference to the requested value.
Exceptions
Base::ItemNotFoundif AllowDefValues is false and the map does not contain an entry with the specified key.
See also
getValue(const Key&) const

◆ removeEntry() [1/2]

template<typename Key , typename Value , bool AllowDefValues, typename KeyCompFunc >
void CDPL::Util::MultiMap< Key, Value, AllowDefValues, KeyCompFunc >::removeEntry ( const EntryIterator it)

Removes the entry pointed to by the iterator it from the map.

Parameters
itThe iterator pointing to the entry to remove.

◆ removeEntry() [2/2]

template<typename Key , typename Value , bool AllowDefValues, typename KeyCompFunc >
bool CDPL::Util::MultiMap< Key, Value, AllowDefValues, KeyCompFunc >::removeEntry ( const Key &  key)

Removes the first entry with the specified key from the map.

Parameters
keyThe key specifying the entry to remove.

◆ removeEntries() [1/2]

template<typename Key , typename Value , bool AllowDefValues, typename KeyCompFunc >
void CDPL::Util::MultiMap< Key, Value, AllowDefValues, KeyCompFunc >::removeEntries ( const EntryIterator first,
const EntryIterator last 
)

Removes all entries pointed to by the iterators in the range [first, last) from the map.

Parameters
firstThe start of the range.
lastThe end of the range.

◆ removeEntries() [2/2]

template<typename Key , typename Value , bool AllowDefValues, typename KeyCompFunc >
std::size_t CDPL::Util::MultiMap< Key, Value, AllowDefValues, KeyCompFunc >::removeEntries ( const Key &  key)

Removes all entries with the specified key from the map.

Parameters
keyThe key specifying the entries to remove.
Returns
The number of removed entries.

◆ insertEntry() [1/4]

template<typename Key , typename Value , bool AllowDefValues, typename KeyCompFunc >
CDPL::Util::MultiMap< Key, Value, AllowDefValues, KeyCompFunc >::EntryIterator CDPL::Util::MultiMap< Key, Value, AllowDefValues, KeyCompFunc >::insertEntry ( const Entry item)

Inserts the key/value pair item into the map.

Parameters
itemThe key/value pair to insert.
Returns
An iterator pointing to the inserted entry.

◆ insertEntry() [2/4]

template<typename Key , typename Value , bool AllowDefValues, typename KeyCompFunc >
CDPL::Util::MultiMap< Key, Value, AllowDefValues, KeyCompFunc >::EntryIterator CDPL::Util::MultiMap< Key, Value, AllowDefValues, KeyCompFunc >::insertEntry ( const Key &  key,
const Value &  value 
)

Inserts a new entry with specified key and value into the map.

Parameters
keyThe key of the entry to insert.
valueThe value associated with key
Returns
An iterator pointing to the inserted entry.

◆ insertEntry() [3/4]

template<typename Key , typename Value , bool AllowDefValues, typename KeyCompFunc >
CDPL::Util::MultiMap< Key, Value, AllowDefValues, KeyCompFunc >::EntryIterator CDPL::Util::MultiMap< Key, Value, AllowDefValues, KeyCompFunc >::insertEntry ( const EntryIterator it,
const Entry item 
)

Inserts the key/value pair item into the map and uses the iterator it as a hint for the insertion location.

The return value is a dereferenceable iterator that points to the entry with a key that is equivalent to that of item.

Parameters
itAn iterator pointing to a location where the insertion position search will begin.
itemThe key/value pair to insert.
Returns
An iterator that points to the entry with a key that is equivalent to that of item.

◆ insertEntry() [4/4]

template<typename Key , typename Value , bool AllowDefValues, typename KeyCompFunc >
CDPL::Util::MultiMap< Key, Value, AllowDefValues, KeyCompFunc >::EntryIterator CDPL::Util::MultiMap< Key, Value, AllowDefValues, KeyCompFunc >::insertEntry ( const EntryIterator it,
const Key &  key,
const Value &  value 
)

Inserts a new entry with the specified key and value into the map and uses the iterator it as a hint for the insertion location.

The argument it is a hint and points to the location where the insertion position search will begin. The return value is a dereferenceable iterator that points to the entry with a key that is equivalent to the specified key.

Parameters
itAn iterator pointing to a location where the insertion position search will begin.
keyThe key of the entry to insert.
valueThe value associated with key
Returns
An iterator that points to the entry with a key that is equivalent to the specified key.

◆ setEntry() [1/2]

template<typename Key , typename Value , bool AllowDefValues, typename KeyCompFunc >
CDPL::Util::MultiMap< Key, Value, AllowDefValues, KeyCompFunc >::EntryIterator CDPL::Util::MultiMap< Key, Value, AllowDefValues, KeyCompFunc >::setEntry ( const Entry item)

Replaces all entries with a key equivalent to that of item with a single entry specified by item.

If no entries with a key equivalent to that of item exist, setEntry(item) is equivalent to insertEntry(item).

Parameters
itemThe key/value pair to insert or with which existing entries will be replaced.
Returns
An iterator that points to the entry with a key that is equivalent to that of item.

◆ setEntry() [2/2]

template<typename Key , typename Value , bool AllowDefValues, typename KeyCompFunc >
CDPL::Util::MultiMap< Key, Value, AllowDefValues, KeyCompFunc >::EntryIterator CDPL::Util::MultiMap< Key, Value, AllowDefValues, KeyCompFunc >::setEntry ( const Key &  key,
const Value &  value 
)

Replaces all entries with a key equivalent to key with a single copy of the key/value pair (key, value).

If no entries with a key equivalent to the specified key exist, setEntry(k, v) is equivalent to insertEntry(k, v).

Parameters
keyThe key of the entries to replace.
valueThe value associated with key.
Returns
An iterator that points to the entry with a key that is equivalent to the specified key.

◆ insertEntries()

template<typename Key , typename Value , bool AllowDefValues, typename KeyCompFunc >
template<typename InputIter >
void CDPL::Util::MultiMap< Key, Value, AllowDefValues, KeyCompFunc >::insertEntries ( const InputIter &  first,
const InputIter &  last 
)

Inserts the key/value pairs in the range [first, last) into the map.

This is equivalent to calling insertEntry(const Entry&) for each key/value pair i that is pointed to by an iterator in the range [first, last).

Parameters
firstThe start of the range.
lastThe end of the range.

◆ setEntries()

template<typename Key , typename Value , bool AllowDefValues, typename KeyCompFunc >
template<typename InputIter >
void CDPL::Util::MultiMap< Key, Value, AllowDefValues, KeyCompFunc >::setEntries ( const InputIter &  first,
const InputIter &  last 
)

Inserts new entries or updates the value of existing entries using the key/value pairs in the range [first, last).

This is equivalent to calling setEntry(const Entry&) for each key/value pair i that is pointed to by an iterator in the range [first, last).

Parameters
firstThe start of the range.
lastThe end of the range.

◆ getLowerBound() [1/2]

template<typename Key , typename Value , bool AllowDefValues, typename KeyCompFunc >
CDPL::Util::MultiMap< Key, Value, AllowDefValues, KeyCompFunc >::EntryIterator CDPL::Util::MultiMap< Key, Value, AllowDefValues, KeyCompFunc >::getLowerBound ( const Key &  key)

Returns a mutable iterator pointing to the first entry whose key is not less than the specified key.

Returns
A mutable iterator pointing to the first entry whose key is not less than the specified key.

◆ getLowerBound() [2/2]

template<typename Key , typename Value , bool AllowDefValues, typename KeyCompFunc >
CDPL::Util::MultiMap< Key, Value, AllowDefValues, KeyCompFunc >::ConstEntryIterator CDPL::Util::MultiMap< Key, Value, AllowDefValues, KeyCompFunc >::getLowerBound ( const Key &  key) const

Returns a constant iterator pointing to the first entry whose key is not less than the specified key.

Returns
A constant iterator pointing to the first entry whose key is not less than the specified key.

◆ getUpperBound() [1/2]

template<typename Key , typename Value , bool AllowDefValues, typename KeyCompFunc >
CDPL::Util::MultiMap< Key, Value, AllowDefValues, KeyCompFunc >::EntryIterator CDPL::Util::MultiMap< Key, Value, AllowDefValues, KeyCompFunc >::getUpperBound ( const Key &  key)

Returns a mutable iterator pointing to the first entry whose key is greater than the specified key.

Returns
A mutable iterator pointing to the first entry whose key is greater than the specified key.

◆ getUpperBound() [2/2]

template<typename Key , typename Value , bool AllowDefValues, typename KeyCompFunc >
CDPL::Util::MultiMap< Key, Value, AllowDefValues, KeyCompFunc >::ConstEntryIterator CDPL::Util::MultiMap< Key, Value, AllowDefValues, KeyCompFunc >::getUpperBound ( const Key &  key) const

Returns a constant iterator pointing to the first entry whose key is greater than the specified key.

Returns
A constant iterator pointing to the first entry whose key is greater than the specified key.

◆ getEntriesBegin() [1/2]

template<typename Key , typename Value , bool AllowDefValues, typename KeyCompFunc >
CDPL::Util::MultiMap< Key, Value, AllowDefValues, KeyCompFunc >::ConstEntryIterator CDPL::Util::MultiMap< Key, Value, AllowDefValues, KeyCompFunc >::getEntriesBegin

Returns a constant iterator pointing to the beginning of the map.

Returns
A constant iterator pointing to the beginning of the map.

◆ getEntriesBegin() [2/2]

template<typename Key , typename Value , bool AllowDefValues, typename KeyCompFunc >
CDPL::Util::MultiMap< Key, Value, AllowDefValues, KeyCompFunc >::EntryIterator CDPL::Util::MultiMap< Key, Value, AllowDefValues, KeyCompFunc >::getEntriesBegin

Returns a mutable iterator pointing to the beginning of the map.

Returns
A mutable iterator pointing to the beginning of the map.

◆ getEntriesEnd() [1/2]

template<typename Key , typename Value , bool AllowDefValues, typename KeyCompFunc >
CDPL::Util::MultiMap< Key, Value, AllowDefValues, KeyCompFunc >::ConstEntryIterator CDPL::Util::MultiMap< Key, Value, AllowDefValues, KeyCompFunc >::getEntriesEnd

Returns a constant iterator pointing to the end of the map.

Returns
A constant iterator pointing to the end of the map.

◆ getEntriesEnd() [2/2]

template<typename Key , typename Value , bool AllowDefValues, typename KeyCompFunc >
CDPL::Util::MultiMap< Key, Value, AllowDefValues, KeyCompFunc >::EntryIterator CDPL::Util::MultiMap< Key, Value, AllowDefValues, KeyCompFunc >::getEntriesEnd

Returns a mutable iterator pointing to the end of the map.

Returns
A mutable iterator pointing to the end of the map.

◆ begin() [1/2]

template<typename Key , typename Value , bool AllowDefValues, typename KeyCompFunc >
CDPL::Util::MultiMap< Key, Value, AllowDefValues, KeyCompFunc >::ConstEntryIterator CDPL::Util::MultiMap< Key, Value, AllowDefValues, KeyCompFunc >::begin

Returns a constant iterator pointing to the beginning of the map.

Returns
A constant iterator pointing to the beginning of the map.

◆ begin() [2/2]

template<typename Key , typename Value , bool AllowDefValues, typename KeyCompFunc >
CDPL::Util::MultiMap< Key, Value, AllowDefValues, KeyCompFunc >::EntryIterator CDPL::Util::MultiMap< Key, Value, AllowDefValues, KeyCompFunc >::begin

Returns a mutable iterator pointing to the beginning of the map.

Returns
A mutable iterator pointing to the beginning of the map.

◆ end() [1/2]

template<typename Key , typename Value , bool AllowDefValues, typename KeyCompFunc >
CDPL::Util::MultiMap< Key, Value, AllowDefValues, KeyCompFunc >::ConstEntryIterator CDPL::Util::MultiMap< Key, Value, AllowDefValues, KeyCompFunc >::end

Returns a constant iterator pointing to the end of the map.

Returns
A constant iterator pointing to the end of the map.

◆ end() [2/2]

template<typename Key , typename Value , bool AllowDefValues, typename KeyCompFunc >
CDPL::Util::MultiMap< Key, Value, AllowDefValues, KeyCompFunc >::EntryIterator CDPL::Util::MultiMap< Key, Value, AllowDefValues, KeyCompFunc >::end

Returns a mutable iterator pointing to the end of the map.

Returns
A mutable iterator pointing to the end of the map.

◆ getEntriesReverseBegin() [1/2]

template<typename Key , typename Value , bool AllowDefValues, typename KeyCompFunc >
CDPL::Util::MultiMap< Key, Value, AllowDefValues, KeyCompFunc >::ConstReverseEntryIterator CDPL::Util::MultiMap< Key, Value, AllowDefValues, KeyCompFunc >::getEntriesReverseBegin

Returns a constant iterator pointing to the beginning of the reversed map.

Returns
A constant iterator pointing to the beginning of the reversed map.

◆ getEntriesReverseBegin() [2/2]

template<typename Key , typename Value , bool AllowDefValues, typename KeyCompFunc >
CDPL::Util::MultiMap< Key, Value, AllowDefValues, KeyCompFunc >::ReverseEntryIterator CDPL::Util::MultiMap< Key, Value, AllowDefValues, KeyCompFunc >::getEntriesReverseBegin

Returns a mutable iterator pointing to the beginning of the reversed map.

Returns
A mutable iterator pointing to the beginning of the reversed map.

◆ getEntriesReverseEnd() [1/2]

template<typename Key , typename Value , bool AllowDefValues, typename KeyCompFunc >
CDPL::Util::MultiMap< Key, Value, AllowDefValues, KeyCompFunc >::ConstReverseEntryIterator CDPL::Util::MultiMap< Key, Value, AllowDefValues, KeyCompFunc >::getEntriesReverseEnd

Returns a constant iterator pointing to the end of the reversed map.

Returns
A constant iterator pointing to the end of the reversed map.

◆ getEntriesReverseEnd() [2/2]

template<typename Key , typename Value , bool AllowDefValues, typename KeyCompFunc >
CDPL::Util::MultiMap< Key, Value, AllowDefValues, KeyCompFunc >::ReverseEntryIterator CDPL::Util::MultiMap< Key, Value, AllowDefValues, KeyCompFunc >::getEntriesReverseEnd

Returns a mutable iterator pointing to the end of the reversed map.

Returns
A mutable iterator pointing to the end of the reversed map.

◆ getClassName()

template<typename Key , typename Value , bool AllowDefValues, typename KeyCompFunc >
const char * CDPL::Util::MultiMap< Key, Value, AllowDefValues, KeyCompFunc >::getClassName
protectedvirtual

Returns the name of the (derived) Map class.

Overriding this method provides an easy way to customize exception messages with the name of a derived class. Consider the class MyMultiMap which inherits publicly from MultiMap<int, int> and overrides getClassName():

class MyMap : public Map<int, int>
{
.....
private:
const char* getClassName() const {
return "MyMultiMap";
}
};
virtual const char * getClassName() const
Returns the name of the (derived) Map class.
Definition: MultiMap.hpp:1064

If, for example, the requested value for a particular key is not found, the error message of the thrown Base::ItemNotFound exception will now start with "MyMultiMap: ...." instead of the default "MultiMap: ....".

Returns
The name of the class as a C-string.
See also
Array::getClassName

The documentation for this class was generated from the following file: