Chemical Data Processing Library C++ API - Version 1.4.0
MultiMap.hpp
Go to the documentation of this file.
1 /*
2  * MultiMap.hpp
3  *
4  * This file is part of the Chemical Data Processing Toolkit
5  *
6  * Copyright (C) 2003 Thomas Seidel <thomas.seidel@univie.ac.at>
7  *
8  * This library is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public
10  * License as published by the Free Software Foundation; either
11  * version 2 of the License, or (at your option) any later version.
12  *
13  * This library is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  * Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public License
19  * along with this library; see the file COPYING. If not, write to
20  * the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
21  * Boston, MA 02111-1307, USA.
22  */
23 
29 #ifndef CDPL_UTIL_MULTIMAP_HPP
30 #define CDPL_UTIL_MULTIMAP_HPP
31 
32 #include <map>
33 #include <functional>
34 #include <utility>
35 #include <string>
36 #include <cstddef>
37 #include <memory>
38 
39 #include "CDPL/Base/Exceptions.hpp"
40 
41 
42 namespace CDPL
43 {
44 
45  namespace Util
46  {
47 
53  template <typename ValueType, bool Allow = true>
55  {
56 
61  static const ValueType& get()
62  {
63  return defValue;
64  }
65 
69  static const ValueType defValue;
70  };
71 
72  template <typename ValueType, bool Allow>
73  const ValueType MultiMapDefaultValue<ValueType, Allow>::defValue = ValueType();
74 
79  template <typename ValueType>
80  struct MultiMapDefaultValue<ValueType, false>
81  {
82 
88  static const ValueType& get()
89  {
90  throw Base::OperationFailed("MultiMap: default value not supported");
91  }
92  };
93 
114  template <typename Key, typename Value, bool AllowDefValues = false,
115  typename KeyCompFunc = std::less<Key> >
116  class MultiMap
117  {
118 
119  typedef std::multimap<Key, Value, KeyCompFunc> StorageType;
120 
121  public:
125  typedef std::shared_ptr<MultiMap> SharedPointer;
126 
130  typedef Key KeyType;
131 
135  typedef Value ValueType;
136 
143  typedef typename StorageType::value_type Entry;
144 
148  typedef typename StorageType::const_iterator ConstEntryIterator;
149 
153  typedef typename StorageType::const_reverse_iterator ConstReverseEntryIterator;
154 
158  typedef typename StorageType::iterator EntryIterator;
159 
163  typedef typename StorageType::reverse_iterator ReverseEntryIterator;
164 
168  typedef typename std::pair<EntryIterator, EntryIterator> EntryIteratorRange;
169 
173  typedef typename std::pair<ConstEntryIterator, ConstEntryIterator> ConstEntryIteratorRange;
174 
179  data() {}
180 
185  MultiMap(const KeyCompFunc& func):
186  data(func) {}
187 
193  template <typename InputIter>
194  MultiMap(const InputIter& first, const InputIter& last):
195  data(first, last)
196  {}
197 
205  template <typename InputIter>
206  MultiMap(const InputIter& first, const InputIter& last, const KeyCompFunc& func):
207  data(first, last, func)
208  {}
209 
213  virtual ~MultiMap() {}
214 
219  StorageType& getData();
220 
225  const StorageType& getData() const;
226 
231  std::size_t getSize() const;
232 
237  bool isEmpty() const;
238 
242  void clear();
243 
248  void swap(MultiMap& map);
249 
254  KeyCompFunc getKeyCompareFunction() const;
255 
261  std::size_t getNumEntries(const Key& key) const;
262 
275 
287  ConstEntryIteratorRange getEntries(const Key& key) const;
288 
299  EntryIterator getEntry(const Key& key);
300 
311  ConstEntryIterator getEntry(const Key& key) const;
312 
327  Value& getValue(const Key& key);
328 
343  Value& getValue(const Key& key, Value& def_value);
344 
359  const Value& getValue(const Key& key) const;
360 
375  const Value& getValue(const Key& key, const Value& def_value) const;
376 
388  Value& operator[](const Key& key);
389 
401  const Value& operator[](const Key& key) const;
402 
407  void removeEntry(const EntryIterator& it);
408 
413  bool removeEntry(const Key& key);
414 
420  void removeEntries(const EntryIterator& first, const EntryIterator& last);
421 
427  std::size_t removeEntries(const Key& key);
428 
435 
442  EntryIterator insertEntry(const Key& key, const Value& value);
443 
455  EntryIterator insertEntry(const EntryIterator& it, const Entry& item);
456 
470  EntryIterator insertEntry(const EntryIterator& it, const Key& key, const Value& value);
471 
483 
495  EntryIterator setEntry(const Key& key, const Value& value);
496 
506  template <typename InputIter>
507  void insertEntries(const InputIter& first, const InputIter& last);
508 
519  template <typename InputIter>
520  void setEntries(const InputIter& first, const InputIter& last);
521 
527  EntryIterator getLowerBound(const Key& key);
528 
534  ConstEntryIterator getLowerBound(const Key& key) const;
535 
541  EntryIterator getUpperBound(const Key& key);
542 
548  ConstEntryIterator getUpperBound(const Key& key) const;
549 
555 
561 
567 
573 
579 
585 
591 
597 
603 
609 
615 
621 
622  protected:
650  virtual const char* getClassName() const;
651 
652  private:
653  const Value& getDefaultValue() const;
654 
655  StorageType data;
656  };
657 
666  template <typename Key, typename Value, bool AllowDefValues, typename KeyCompFunc>
669 
678  template <typename Key, typename Value, bool AllowDefValues, typename KeyCompFunc>
681 
690  template <typename Key, typename Value, bool AllowDefValues, typename KeyCompFunc>
693 
702  template <typename Key, typename Value, bool AllowDefValues, typename KeyCompFunc>
705 
714  template <typename Key, typename Value, bool AllowDefValues, typename KeyCompFunc>
717 
726  template <typename Key, typename Value, bool AllowDefValues, typename KeyCompFunc>
729 
730  } // namespace Util
731 } // namespace CDPL
732 
733 
734 // Implementation
735 
736 template <typename Key, typename Value, bool AllowDefValues, typename KeyCompFunc>
737 typename CDPL::Util::MultiMap<Key, Value, AllowDefValues, KeyCompFunc>::StorageType&
739 {
740  return data;
741 }
742 
743 template <typename Key, typename Value, bool AllowDefValues, typename KeyCompFunc>
744 const typename CDPL::Util::MultiMap<Key, Value, AllowDefValues, KeyCompFunc>::StorageType&
746 {
747  return data;
748 }
749 
750 template <typename Key, typename Value, bool AllowDefValues, typename KeyCompFunc>
752 {
753  return data.size();
754 }
755 
756 template <typename Key, typename Value, bool AllowDefValues, typename KeyCompFunc>
758 {
759  return data.empty();
760 }
761 
762 template <typename Key, typename Value, bool AllowDefValues, typename KeyCompFunc>
764 {
765  data.clear();
766 }
767 
768 template <typename Key, typename Value, bool AllowDefValues, typename KeyCompFunc>
770 {
771  data.swap(map.data);
772 }
773 
774 template <typename Key, typename Value, bool AllowDefValues, typename KeyCompFunc>
776 {
777  return data.key_comp();
778 }
779 
780 template <typename Key, typename Value, bool AllowDefValues, typename KeyCompFunc>
782 {
783  return data.count(key);
784 }
785 
786 template <typename Key, typename Value, bool AllowDefValues, typename KeyCompFunc>
789 {
790  return data.find(key);
791 }
792 
793 template <typename Key, typename Value, bool AllowDefValues, typename KeyCompFunc>
796 {
797  return data.find(key);
798 }
799 
800 template <typename Key, typename Value, bool AllowDefValues, typename KeyCompFunc>
803 {
804  return data.equal_range(key);
805 }
806 
807 template <typename Key, typename Value, bool AllowDefValues, typename KeyCompFunc>
810 {
811  return data.equal_range(key);
812 }
813 
814 template <typename Key, typename Value, bool AllowDefValues, typename KeyCompFunc>
816 {
817  EntryIterator lb = data.lower_bound(key);
818 
819  if (lb == data.end() || data.key_comp()(key, (*lb).first)) {
820  if (!AllowDefValues)
821  throw Base::ItemNotFound(std::string(getClassName()) + ": key not found");
822 
823  return (*data.insert(lb, Entry(key, getDefaultValue()))).second;
824  }
825 
826  return (*lb).second;
827 }
828 
829 template <typename Key, typename Value, bool AllowDefValues, typename KeyCompFunc>
831 {
832  EntryIterator it = data.find(key);
833 
834  if (it == data.end())
835  return def_value;
836 
837  return (*it).second;
838 }
839 
840 template <typename Key, typename Value, bool AllowDefValues, typename KeyCompFunc>
842 {
843  ConstEntryIterator it = data.find(key);
844 
845  if (it == data.end()) {
846  if (!AllowDefValues)
847  throw Base::ItemNotFound(std::string(getClassName()) + ": key not found");
848 
849  return getDefaultValue();
850  }
851 
852  return (*it).second;
853 }
854 
855 template <typename Key, typename Value, bool AllowDefValues, typename KeyCompFunc>
857  const Value& def_value) const
858 {
859  ConstEntryIterator it = data.find(key);
860 
861  if (it == data.end())
862  return def_value;
863 
864  return (*it).second;
865 }
866 
867 template <typename Key, typename Value, bool AllowDefValues, typename KeyCompFunc>
869 {
870  return getValue(key);
871 }
872 
873 template <typename Key, typename Value, bool AllowDefValues, typename KeyCompFunc>
875 {
876  return getValue(key);
877 }
878 
879 template <typename Key, typename Value, bool AllowDefValues, typename KeyCompFunc>
881 {
882  data.erase(it);
883 }
884 
885 template <typename Key, typename Value, bool AllowDefValues, typename KeyCompFunc>
887 {
888  EntryIterator it = data.find(key);
889 
890  if (it == data.end())
891  return false;
892 
893  data.erase(it);
894  return true;
895 }
896 
897 template <typename Key, typename Value, bool AllowDefValues, typename KeyCompFunc>
899 {
900  return data.erase(key);
901 }
902 
903 template <typename Key, typename Value, bool AllowDefValues, typename KeyCompFunc>
905  const EntryIterator& last)
906 {
907  data.erase(first, last);
908 }
909 
910 template <typename Key, typename Value, bool AllowDefValues, typename KeyCompFunc>
913 {
914  return data.insert(item);
915 }
916 
917 template <typename Key, typename Value, bool AllowDefValues, typename KeyCompFunc>
920 {
921  return data.insert(Entry(key, value));
922 }
923 
924 template <typename Key, typename Value, bool AllowDefValues, typename KeyCompFunc>
927 {
928  return data.insert(it, item);
929 }
930 
931 template <typename Key, typename Value, bool AllowDefValues, typename KeyCompFunc>
934  const Value& value)
935 {
936  return data.insert(it, Entry(key, value));
937 }
938 
939 template <typename Key, typename Value, bool AllowDefValues, typename KeyCompFunc>
942 {
943  EntryIterator lb = data.lower_bound(item.first);
944  EntryIterator end = data.end();
945 
946  if (lb == end || data.key_comp()(item.first, (*lb).first))
947  return data.insert(lb, item);
948 
949  EntryIterator range_end = lb;
950 
951  while (range_end != end && !data.key_comp()(item.first, (*range_end).first))
952  ++range_end;
953 
954  data.erase(lb, range_end);
955 
956  return data.insert(range_end, item);
957 }
958 
959 template <typename Key, typename Value, bool AllowDefValues, typename KeyCompFunc>
962 {
963  return setEntry(Entry(key, value));
964 }
965 
966 template <typename Key, typename Value, bool AllowDefValues, typename KeyCompFunc>
967 template <typename InputIter>
969  const InputIter& last)
970 {
971  data.insert(first, last);
972 }
973 
974 template <typename Key, typename Value, bool AllowDefValues, typename KeyCompFunc>
975 template <typename InputIter>
977  const InputIter& last)
978 {
979  for (InputIter it = first; it != last; ++it)
980  setEntry(*it);
981 }
982 
983 template <typename Key, typename Value, bool AllowDefValues, typename KeyCompFunc>
986 {
987  return data.lower_bound(key);
988 }
989 
990 template <typename Key, typename Value, bool AllowDefValues, typename KeyCompFunc>
993 {
994  return data.lower_bound(key);
995 }
996 
997 template <typename Key, typename Value, bool AllowDefValues, typename KeyCompFunc>
1000 {
1001  return data.upper_bound(key);
1002 }
1003 
1004 template <typename Key, typename Value, bool AllowDefValues, typename KeyCompFunc>
1007 {
1008  return data.upper_bound(key);
1009 }
1010 
1011 template <typename Key, typename Value, bool AllowDefValues, typename KeyCompFunc>
1014 {
1015  return data.begin();
1016 }
1017 
1018 template <typename Key, typename Value, bool AllowDefValues, typename KeyCompFunc>
1021 {
1022  return data.begin();
1023 }
1024 
1025 template <typename Key, typename Value, bool AllowDefValues, typename KeyCompFunc>
1028 {
1029  return data.end();
1030 }
1031 
1032 template <typename Key, typename Value, bool AllowDefValues, typename KeyCompFunc>
1035 {
1036  return data.end();
1037 }
1038 
1039 template <typename Key, typename Value, bool AllowDefValues, typename KeyCompFunc>
1042 {
1043  return data.begin();
1044 }
1045 
1046 template <typename Key, typename Value, bool AllowDefValues, typename KeyCompFunc>
1049 {
1050  return data.begin();
1051 }
1052 
1053 template <typename Key, typename Value, bool AllowDefValues, typename KeyCompFunc>
1056 {
1057  return data.end();
1058 }
1059 
1060 template <typename Key, typename Value, bool AllowDefValues, typename KeyCompFunc>
1063 {
1064  return data.end();
1065 }
1066 
1067 template <typename Key, typename Value, bool AllowDefValues, typename KeyCompFunc>
1070 {
1071  return data.rbegin();
1072 }
1073 
1074 template <typename Key, typename Value, bool AllowDefValues, typename KeyCompFunc>
1077 {
1078  return data.rbegin();
1079 }
1080 
1081 template <typename Key, typename Value, bool AllowDefValues, typename KeyCompFunc>
1084 {
1085  return data.rend();
1086 }
1087 
1088 template <typename Key, typename Value, bool AllowDefValues, typename KeyCompFunc>
1091 {
1092  return data.rend();
1093 }
1094 
1095 template <typename Key, typename Value, bool AllowDefValues, typename KeyCompFunc>
1097 {
1098  return "MultiMap";
1099 }
1100 
1101 template <typename Key, typename Value, bool AllowDefValues, typename KeyCompFunc>
1103 {
1105 }
1106 
1107 // \cond DOC_IMPL_DETAILS
1108 
1109 template <typename Key, typename Value, bool AllowDefValues, typename KeyCompFunc>
1110 bool CDPL::Util::operator==(const MultiMap<Key, Value, AllowDefValues, KeyCompFunc>& map1,
1111  const MultiMap<Key, Value, AllowDefValues, KeyCompFunc>& map2)
1112 {
1113  return (map1.getData() == map2.getData());
1114 }
1115 
1116 template <typename Key, typename Value, bool AllowDefValues, typename KeyCompFunc>
1117 bool CDPL::Util::operator!=(const MultiMap<Key, Value, AllowDefValues, KeyCompFunc>& map1,
1118  const MultiMap<Key, Value, AllowDefValues, KeyCompFunc>& map2)
1119 {
1120  return (map1.getData() != map2.getData());
1121 }
1122 
1123 template <typename Key, typename Value, bool AllowDefValues, typename KeyCompFunc>
1124 bool CDPL::Util::operator<=(const MultiMap<Key, Value, AllowDefValues, KeyCompFunc>& map1,
1125  const MultiMap<Key, Value, AllowDefValues, KeyCompFunc>& map2)
1126 {
1127  return (map1.getData() <= map2.getData());
1128 }
1129 
1130 template <typename Key, typename Value, bool AllowDefValues, typename KeyCompFunc>
1131 bool CDPL::Util::operator>=(const MultiMap<Key, Value, AllowDefValues, KeyCompFunc>& map1,
1132  const MultiMap<Key, Value, AllowDefValues, KeyCompFunc>& map2)
1133 {
1134  return (map1.getData() >= map2.getData());
1135 }
1136 
1137 template <typename Key, typename Value, bool AllowDefValues, typename KeyCompFunc>
1138 bool CDPL::Util::operator<(const MultiMap<Key, Value, AllowDefValues, KeyCompFunc>& map1,
1139  const MultiMap<Key, Value, AllowDefValues, KeyCompFunc>& map2)
1140 {
1141  return (map1.getData() < map2.getData());
1142 }
1143 
1144 template <typename Key, typename Value, bool AllowDefValues, typename KeyCompFunc>
1145 bool CDPL::Util::operator>(const MultiMap<Key, Value, AllowDefValues, KeyCompFunc>& map1,
1146  const MultiMap<Key, Value, AllowDefValues, KeyCompFunc>& map2)
1147 {
1148  return (map1.getData() > map2.getData());
1149 }
1150 
1151 // \endcond
1152 
1153 #endif // CDPL_UTIL_MULTIMAP_HPP
Definition of exception classes.
Thrown to indicate that some requested data item could not be found.
Definition: Base/Exceptions.hpp:171
Thrown to indicate that some requested operation has failed (e.g. due to unfulfilled preconditions or...
Definition: Base/Exceptions.hpp:211
A multiple sorted associative container that maps keys to values.
Definition: MultiMap.hpp:117
Key KeyType
The type of the map's keys.
Definition: MultiMap.hpp:130
ConstEntryIterator getEntriesEnd() const
Returns a constant iterator pointing to the end of the map.
Definition: MultiMap.hpp:1027
void swap(MultiMap &map)
Swaps the contents with map.
Definition: MultiMap.hpp:769
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 loc...
Definition: MultiMap.hpp:926
ConstReverseEntryIterator getEntriesReverseEnd() const
Returns a constant iterator pointing to the end of the reversed map.
Definition: MultiMap.hpp:1083
void removeEntries(const EntryIterator &first, const EntryIterator &last)
Removes all entries pointed to by the iterators in the range [first, last) from the map.
Definition: MultiMap.hpp:904
std::pair< EntryIterator, EntryIterator > EntryIteratorRange
A pair of mutable iterators used to specify the start and end of a range of entries.
Definition: MultiMap.hpp:168
virtual ~MultiMap()
Virtual destructor.
Definition: MultiMap.hpp:213
EntryIterator insertEntry(const Key &key, const Value &value)
Inserts a new entry with specified key and value into the map.
Definition: MultiMap.hpp:919
const Value & getValue(const Key &key) const
Returns a const reference to the first value associated with the specified key.
Definition: MultiMap.hpp:841
const Value & operator[](const Key &key) const
Returns a const reference to the first value associated with the specified key.
Definition: MultiMap.hpp:874
ConstEntryIterator getUpperBound(const Key &key) const
Returns a constant iterator pointing to the first entry whose key is greater than key.
Definition: MultiMap.hpp:1006
EntryIterator setEntry(const Entry &item)
Replaces all entries with a key equivalent to that of item with a single entry specified by item.
Definition: MultiMap.hpp:941
const StorageType & getData() const
Returns a const reference to the underlying map storage.
Definition: MultiMap.hpp:745
StorageType::iterator EntryIterator
A mutable iterator used to iterate over the entries of the map.
Definition: MultiMap.hpp:158
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 [...
Definition: MultiMap.hpp:976
EntryIterator getLowerBound(const Key &key)
Returns a mutable iterator pointing to the first entry whose key is not less than key.
Definition: MultiMap.hpp:985
std::size_t getNumEntries(const Key &key) const
Returns the number of entries with the specified key.
Definition: MultiMap.hpp:781
EntryIterator getUpperBound(const Key &key)
Returns a mutable iterator pointing to the first entry whose key is greater than key.
Definition: MultiMap.hpp:999
ConstReverseEntryIterator getEntriesReverseBegin() const
Returns a constant iterator pointing to the beginning of the reversed map.
Definition: MultiMap.hpp:1069
MultiMap(const InputIter &first, const InputIter &last)
Creates and initializes the map with copies of the key value pairs in the range [first,...
Definition: MultiMap.hpp:194
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 ...
Definition: MultiMap.hpp:933
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,...
Definition: MultiMap.hpp:961
Value & getValue(const Key &key)
Returns a non-const reference to the first value associated with the specified key.
Definition: MultiMap.hpp:815
EntryIterator insertEntry(const Entry &item)
Inserts the key/value pair item into the map.
Definition: MultiMap.hpp:912
void removeEntry(const EntryIterator &it)
Removes the entry pointed to by the iterator it from the map.
Definition: MultiMap.hpp:880
StorageType::value_type Entry
The type of the key/value pairs stored in the map.
Definition: MultiMap.hpp:143
ConstEntryIterator getEntry(const Key &key) const
Returns a constant iterator pointing to the first entry with the specified key.
Definition: MultiMap.hpp:795
EntryIterator end()
Returns a mutable iterator pointing to the end of the map.
Definition: MultiMap.hpp:1062
MultiMap(const KeyCompFunc &func)
Creates an empty map and uses func as key compare function.
Definition: MultiMap.hpp:185
MultiMap()
Creates an empty map.
Definition: MultiMap.hpp:178
Value ValueType
The type of the mapped values.
Definition: MultiMap.hpp:135
std::pair< ConstEntryIterator, ConstEntryIterator > ConstEntryIteratorRange
A pair of constant iterators used to specify the start and end of a range of entries.
Definition: MultiMap.hpp:173
Value & getValue(const Key &key, Value &def_value)
Returns a non-const reference to the first value associated with the specified key,...
Definition: MultiMap.hpp:830
void insertEntries(const InputIter &first, const InputIter &last)
Inserts the key/value pairs in the range [first, last) into the map.
Definition: MultiMap.hpp:968
std::size_t getSize() const
Returns the size (number of entries) of the map.
Definition: MultiMap.hpp:751
ReverseEntryIterator getEntriesReverseEnd()
Returns a mutable iterator pointing to the end of the reversed map.
Definition: MultiMap.hpp:1090
ReverseEntryIterator getEntriesReverseBegin()
Returns a mutable iterator pointing to the beginning of the reversed map.
Definition: MultiMap.hpp:1076
std::size_t removeEntries(const Key &key)
Removes all entries with the specified key from the map.
Definition: MultiMap.hpp:898
StorageType & getData()
Returns a non-const reference to the underlying map storage.
Definition: MultiMap.hpp:738
ConstEntryIteratorRange getEntries(const Key &key) const
Returns the bounds of a range that includes all entries with a key that compares equal to the specifi...
Definition: MultiMap.hpp:809
StorageType::const_reverse_iterator ConstReverseEntryIterator
A constant iterator used to iterate backwards over the entries of the map.
Definition: MultiMap.hpp:153
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,...
Definition: MultiMap.hpp:206
std::shared_ptr< MultiMap > SharedPointer
A reference-counted smart pointer [SHPTR] for dynamically allocated MultiMap instances.
Definition: MultiMap.hpp:125
bool removeEntry(const Key &key)
Removes the first entry with the specified key from the map.
Definition: MultiMap.hpp:886
ConstEntryIterator begin() const
Returns a constant iterator pointing to the beginning of the map.
Definition: MultiMap.hpp:1041
KeyCompFunc getKeyCompareFunction() const
Returns the key compare function used by the map.
Definition: MultiMap.hpp:775
EntryIteratorRange getEntries(const Key &key)
Returns the bounds of a range that includes all entries with a key that compares equal to the specifi...
Definition: MultiMap.hpp:802
virtual const char * getClassName() const
Returns the name of the (derived) Map class.
Definition: MultiMap.hpp:1096
bool isEmpty() const
Tells whether the map is empty (getSize() == 0).
Definition: MultiMap.hpp:757
ConstEntryIterator getEntriesBegin() const
Returns a constant iterator pointing to the beginning of the map.
Definition: MultiMap.hpp:1013
EntryIterator begin()
Returns a mutable iterator pointing to the beginning of the map.
Definition: MultiMap.hpp:1048
StorageType::reverse_iterator ReverseEntryIterator
A mutable iterator used to iterate backwards over the entries of the map.
Definition: MultiMap.hpp:163
ConstEntryIterator getLowerBound(const Key &key) const
Returns a constant iterator pointing to the first entry whose key is not less than key.
Definition: MultiMap.hpp:992
Value & operator[](const Key &key)
Returns a non-const reference to the first value associated with the specified key.
Definition: MultiMap.hpp:868
EntryIterator getEntriesEnd()
Returns a mutable iterator pointing to the end of the map.
Definition: MultiMap.hpp:1034
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...
Definition: MultiMap.hpp:856
ConstEntryIterator end() const
Returns a constant iterator pointing to the end of the map.
Definition: MultiMap.hpp:1055
StorageType::const_iterator ConstEntryIterator
A constant iterator used to iterate over the entries of the map.
Definition: MultiMap.hpp:148
void clear()
Erases all entries.
Definition: MultiMap.hpp:763
EntryIterator getEntry(const Key &key)
Returns a mutable iterator pointing to the first entry with the specified key.
Definition: MultiMap.hpp:788
EntryIterator getEntriesBegin()
Returns a mutable iterator pointing to the beginning of the map.
Definition: MultiMap.hpp:1020
bool operator<(const Array< ValueType > &array1, const Array< ValueType > &array2)
Less than comparison operator.
bool operator>=(const Array< ValueType > &array1, const Array< ValueType > &array2)
Greater or equal comparison operator.
bool operator>(const Array< ValueType > &array1, const Array< ValueType > &array2)
Greater than comparison operator.
bool operator!=(const Array< ValueType > &array1, const Array< ValueType > &array2)
Inequality comparison operator.
bool operator<=(const Array< ValueType > &array1, const Array< ValueType > &array2)
Less or equal comparison operator.
bool operator==(const Array< ValueType > &array1, const Array< ValueType > &array2)
Equality comparison operator.
The namespace of the Chemical Data Processing Library.
static const ValueType & get()
Always throws, since default values are not supported for this map configuration.
Definition: MultiMap.hpp:88
Helper supplying the default value returned by Util::MultiMap when a queried key is absent.
Definition: MultiMap.hpp:55
static const ValueType & get()
Returns a const reference to the shared default-constructed value.
Definition: MultiMap.hpp:61
static const ValueType defValue
The default-constructed value returned for an absent key.
Definition: MultiMap.hpp:69