Chemical Data Processing Library C++ API - Version 1.1.1
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 
48  template <typename ValueType, bool Allow = true>
50  {
51 
52  static const ValueType& get()
53  {
54  return defValue;
55  }
56 
57  static const ValueType defValue;
58  };
59 
60  template <typename ValueType, bool Allow>
61  const ValueType MultiMapDefaultValue<ValueType, Allow>::defValue = ValueType();
62 
63  template <typename ValueType>
64  struct MultiMapDefaultValue<ValueType, false>
65  {
66 
67  static const ValueType& get()
68  {
69  throw Base::OperationFailed("MultiMap: default value not supported");
70  }
71  };
72 
93  template <typename Key, typename Value, bool AllowDefValues = false,
94  typename KeyCompFunc = std::less<Key> >
95  class MultiMap
96  {
97 
98  typedef std::multimap<Key, Value, KeyCompFunc> StorageType;
99 
100  public:
104  typedef std::shared_ptr<MultiMap> SharedPointer;
105 
109  typedef Key KeyType;
110 
114  typedef Value ValueType;
115 
122  typedef typename StorageType::value_type Entry;
123 
127  typedef typename StorageType::const_iterator ConstEntryIterator;
128 
132  typedef typename StorageType::const_reverse_iterator ConstReverseEntryIterator;
133 
137  typedef typename StorageType::iterator EntryIterator;
138 
142  typedef typename StorageType::reverse_iterator ReverseEntryIterator;
143 
147  typedef typename std::pair<EntryIterator, EntryIterator> EntryIteratorRange;
148 
152  typedef typename std::pair<ConstEntryIterator, ConstEntryIterator> ConstEntryIteratorRange;
153 
158  data() {}
159 
164  MultiMap(const KeyCompFunc& func):
165  data(func) {}
166 
172  template <typename InputIter>
173  MultiMap(const InputIter& first, const InputIter& last):
174  data(first, last)
175  {}
176 
184  template <typename InputIter>
185  MultiMap(const InputIter& first, const InputIter& last, const KeyCompFunc& func):
186  data(first, last, func)
187  {}
188 
192  virtual ~MultiMap() {}
193 
194  StorageType& getData();
195 
196  const StorageType& getData() const;
197 
202  std::size_t getSize() const;
203 
208  bool isEmpty() const;
209 
213  void clear();
214 
219  void swap(MultiMap& map);
220 
225  KeyCompFunc getKeyCompareFunction() const;
226 
232  std::size_t getNumEntries(const Key& key) const;
233 
246 
258  ConstEntryIteratorRange getEntries(const Key& key) const;
259 
270  EntryIterator getEntry(const Key& key);
271 
282  ConstEntryIterator getEntry(const Key& key) const;
283 
298  Value& getValue(const Key& key);
299 
314  Value& getValue(const Key& key, Value& def_value);
315 
331  const Value& getValue(const Key& key) const;
332 
347  const Value& getValue(const Key& key, const Value& def_value) const;
348 
360  Value& operator[](const Key& key);
361 
373  const Value& operator[](const Key& key) const;
374 
379  void removeEntry(const EntryIterator& it);
380 
385  bool removeEntry(const Key& key);
386 
392  void removeEntries(const EntryIterator& first, const EntryIterator& last);
393 
399  std::size_t removeEntries(const Key& key);
400 
407 
414  EntryIterator insertEntry(const Key& key, const Value& value);
415 
427  EntryIterator insertEntry(const EntryIterator& it, const Entry& item);
428 
442  EntryIterator insertEntry(const EntryIterator& it, const Key& key, const Value& value);
443 
455 
467  EntryIterator setEntry(const Key& key, const Value& value);
468 
478  template <typename InputIter>
479  void insertEntries(const InputIter& first, const InputIter& last);
480 
491  template <typename InputIter>
492  void setEntries(const InputIter& first, const InputIter& last);
493 
498  EntryIterator getLowerBound(const Key& key);
499 
504  ConstEntryIterator getLowerBound(const Key& key) const;
505 
510  EntryIterator getUpperBound(const Key& key);
511 
516  ConstEntryIterator getUpperBound(const Key& key) const;
517 
523 
529 
535 
541 
547 
553 
559 
565 
571 
577 
583 
589 
590  protected:
618  virtual const char* getClassName() const;
619 
620  private:
621  const Value& getDefaultValue() const;
622 
623  StorageType data;
624  };
625 
634  template <typename Key, typename Value, bool AllowDefValues, typename KeyCompFunc>
637 
646  template <typename Key, typename Value, bool AllowDefValues, typename KeyCompFunc>
649 
658  template <typename Key, typename Value, bool AllowDefValues, typename KeyCompFunc>
661 
670  template <typename Key, typename Value, bool AllowDefValues, typename KeyCompFunc>
673 
682  template <typename Key, typename Value, bool AllowDefValues, typename KeyCompFunc>
685 
694  template <typename Key, typename Value, bool AllowDefValues, typename KeyCompFunc>
697 
698  } // namespace Util
699 } // namespace CDPL
700 
701 
702 // Implementation
703 
704 template <typename Key, typename Value, bool AllowDefValues, typename KeyCompFunc>
705 typename CDPL::Util::MultiMap<Key, Value, AllowDefValues, KeyCompFunc>::StorageType&
707 {
708  return data;
709 }
710 
711 template <typename Key, typename Value, bool AllowDefValues, typename KeyCompFunc>
712 const typename CDPL::Util::MultiMap<Key, Value, AllowDefValues, KeyCompFunc>::StorageType&
714 {
715  return data;
716 }
717 
718 template <typename Key, typename Value, bool AllowDefValues, typename KeyCompFunc>
720 {
721  return data.size();
722 }
723 
724 template <typename Key, typename Value, bool AllowDefValues, typename KeyCompFunc>
726 {
727  return data.empty();
728 }
729 
730 template <typename Key, typename Value, bool AllowDefValues, typename KeyCompFunc>
732 {
733  data.clear();
734 }
735 
736 template <typename Key, typename Value, bool AllowDefValues, typename KeyCompFunc>
738 {
739  data.swap(map.data);
740 }
741 
742 template <typename Key, typename Value, bool AllowDefValues, typename KeyCompFunc>
744 {
745  return data.key_comp();
746 }
747 
748 template <typename Key, typename Value, bool AllowDefValues, typename KeyCompFunc>
750 {
751  return data.count(key);
752 }
753 
754 template <typename Key, typename Value, bool AllowDefValues, typename KeyCompFunc>
757 {
758  return data.find(key);
759 }
760 
761 template <typename Key, typename Value, bool AllowDefValues, typename KeyCompFunc>
764 {
765  return data.find(key);
766 }
767 
768 template <typename Key, typename Value, bool AllowDefValues, typename KeyCompFunc>
771 {
772  return data.equal_range(key);
773 }
774 
775 template <typename Key, typename Value, bool AllowDefValues, typename KeyCompFunc>
778 {
779  return data.equal_range(key);
780 }
781 
782 template <typename Key, typename Value, bool AllowDefValues, typename KeyCompFunc>
784 {
785  EntryIterator lb = data.lower_bound(key);
786 
787  if (lb == data.end() || data.key_comp()(key, (*lb).first)) {
788  if (!AllowDefValues)
789  throw Base::ItemNotFound(std::string(getClassName()) + ": key not found");
790 
791  return (*data.insert(lb, Entry(key, getDefaultValue()))).second;
792  }
793 
794  return (*lb).second;
795 }
796 
797 template <typename Key, typename Value, bool AllowDefValues, typename KeyCompFunc>
799 {
800  EntryIterator it = data.find(key);
801 
802  if (it == data.end())
803  return def_value;
804 
805  return (*it).second;
806 }
807 
808 template <typename Key, typename Value, bool AllowDefValues, typename KeyCompFunc>
810 {
811  ConstEntryIterator it = data.find(key);
812 
813  if (it == data.end()) {
814  if (!AllowDefValues)
815  throw Base::ItemNotFound(std::string(getClassName()) + ": key not found");
816 
817  return getDefaultValue();
818  }
819 
820  return (*it).second;
821 }
822 
823 template <typename Key, typename Value, bool AllowDefValues, typename KeyCompFunc>
825  const Value& def_value) const
826 {
827  ConstEntryIterator it = data.find(key);
828 
829  if (it == data.end())
830  return def_value;
831 
832  return (*it).second;
833 }
834 
835 template <typename Key, typename Value, bool AllowDefValues, typename KeyCompFunc>
837 {
838  return getValue(key);
839 }
840 
841 template <typename Key, typename Value, bool AllowDefValues, typename KeyCompFunc>
843 {
844  return getValue(key);
845 }
846 
847 template <typename Key, typename Value, bool AllowDefValues, typename KeyCompFunc>
849 {
850  data.erase(it);
851 }
852 
853 template <typename Key, typename Value, bool AllowDefValues, typename KeyCompFunc>
855 {
856  EntryIterator it = data.find(key);
857 
858  if (it == data.end())
859  return false;
860 
861  data.erase(it);
862  return true;
863 }
864 
865 template <typename Key, typename Value, bool AllowDefValues, typename KeyCompFunc>
867 {
868  return data.erase(key);
869 }
870 
871 template <typename Key, typename Value, bool AllowDefValues, typename KeyCompFunc>
873  const EntryIterator& last)
874 {
875  data.erase(first, last);
876 }
877 
878 template <typename Key, typename Value, bool AllowDefValues, typename KeyCompFunc>
881 {
882  return data.insert(item);
883 }
884 
885 template <typename Key, typename Value, bool AllowDefValues, typename KeyCompFunc>
888 {
889  return data.insert(Entry(key, value));
890 }
891 
892 template <typename Key, typename Value, bool AllowDefValues, typename KeyCompFunc>
895 {
896  return data.insert(it, item);
897 }
898 
899 template <typename Key, typename Value, bool AllowDefValues, typename KeyCompFunc>
902  const Value& value)
903 {
904  return data.insert(it, Entry(key, value));
905 }
906 
907 template <typename Key, typename Value, bool AllowDefValues, typename KeyCompFunc>
910 {
911  EntryIterator lb = data.lower_bound(item.first);
912  EntryIterator end = data.end();
913 
914  if (lb == end || data.key_comp()(item.first, (*lb).first))
915  return data.insert(lb, item);
916 
917  EntryIterator range_end = lb;
918 
919  while (range_end != end && !data.key_comp()(item.first, (*range_end).first))
920  ++range_end;
921 
922  data.erase(lb, range_end);
923 
924  return data.insert(range_end, item);
925 }
926 
927 template <typename Key, typename Value, bool AllowDefValues, typename KeyCompFunc>
930 {
931  return setEntry(Entry(key, value));
932 }
933 
934 template <typename Key, typename Value, bool AllowDefValues, typename KeyCompFunc>
935 template <typename InputIter>
937  const InputIter& last)
938 {
939  data.insert(first, last);
940 }
941 
942 template <typename Key, typename Value, bool AllowDefValues, typename KeyCompFunc>
943 template <typename InputIter>
945  const InputIter& last)
946 {
947  for (InputIter it = first; it != last; ++it)
948  setEntry(*it);
949 }
950 
951 template <typename Key, typename Value, bool AllowDefValues, typename KeyCompFunc>
954 {
955  return data.lower_bound(key);
956 }
957 
958 template <typename Key, typename Value, bool AllowDefValues, typename KeyCompFunc>
961 {
962  return data.lower_bound(key);
963 }
964 
965 template <typename Key, typename Value, bool AllowDefValues, typename KeyCompFunc>
968 {
969  return data.upper_bound(key);
970 }
971 
972 template <typename Key, typename Value, bool AllowDefValues, typename KeyCompFunc>
975 {
976  return data.upper_bound(key);
977 }
978 
979 template <typename Key, typename Value, bool AllowDefValues, typename KeyCompFunc>
982 {
983  return data.begin();
984 }
985 
986 template <typename Key, typename Value, bool AllowDefValues, typename KeyCompFunc>
989 {
990  return data.begin();
991 }
992 
993 template <typename Key, typename Value, bool AllowDefValues, typename KeyCompFunc>
996 {
997  return data.end();
998 }
999 
1000 template <typename Key, typename Value, bool AllowDefValues, typename KeyCompFunc>
1003 {
1004  return data.end();
1005 }
1006 
1007 template <typename Key, typename Value, bool AllowDefValues, typename KeyCompFunc>
1010 {
1011  return data.begin();
1012 }
1013 
1014 template <typename Key, typename Value, bool AllowDefValues, typename KeyCompFunc>
1017 {
1018  return data.begin();
1019 }
1020 
1021 template <typename Key, typename Value, bool AllowDefValues, typename KeyCompFunc>
1024 {
1025  return data.end();
1026 }
1027 
1028 template <typename Key, typename Value, bool AllowDefValues, typename KeyCompFunc>
1031 {
1032  return data.end();
1033 }
1034 
1035 template <typename Key, typename Value, bool AllowDefValues, typename KeyCompFunc>
1038 {
1039  return data.rbegin();
1040 }
1041 
1042 template <typename Key, typename Value, bool AllowDefValues, typename KeyCompFunc>
1045 {
1046  return data.rbegin();
1047 }
1048 
1049 template <typename Key, typename Value, bool AllowDefValues, typename KeyCompFunc>
1052 {
1053  return data.rend();
1054 }
1055 
1056 template <typename Key, typename Value, bool AllowDefValues, typename KeyCompFunc>
1059 {
1060  return data.rend();
1061 }
1062 
1063 template <typename Key, typename Value, bool AllowDefValues, typename KeyCompFunc>
1065 {
1066  return "MultiMap";
1067 }
1068 
1069 template <typename Key, typename Value, bool AllowDefValues, typename KeyCompFunc>
1071 {
1073 }
1074 
1075 // \cond DOC_IMPL_DETAILS
1076 
1077 template <typename Key, typename Value, bool AllowDefValues, typename KeyCompFunc>
1078 bool CDPL::Util::operator==(const MultiMap<Key, Value, AllowDefValues, KeyCompFunc>& map1,
1079  const MultiMap<Key, Value, AllowDefValues, KeyCompFunc>& map2)
1080 {
1081  return (map1.getData() == map2.getData());
1082 }
1083 
1084 template <typename Key, typename Value, bool AllowDefValues, typename KeyCompFunc>
1085 bool CDPL::Util::operator!=(const MultiMap<Key, Value, AllowDefValues, KeyCompFunc>& map1,
1086  const MultiMap<Key, Value, AllowDefValues, KeyCompFunc>& map2)
1087 {
1088  return (map1.getData() != map2.getData());
1089 }
1090 
1091 template <typename Key, typename Value, bool AllowDefValues, typename KeyCompFunc>
1092 bool CDPL::Util::operator<=(const MultiMap<Key, Value, AllowDefValues, KeyCompFunc>& map1,
1093  const MultiMap<Key, Value, AllowDefValues, KeyCompFunc>& map2)
1094 {
1095  return (map1.getData() <= map2.getData());
1096 }
1097 
1098 template <typename Key, typename Value, bool AllowDefValues, typename KeyCompFunc>
1099 bool CDPL::Util::operator>=(const MultiMap<Key, Value, AllowDefValues, KeyCompFunc>& map1,
1100  const MultiMap<Key, Value, AllowDefValues, KeyCompFunc>& map2)
1101 {
1102  return (map1.getData() >= map2.getData());
1103 }
1104 
1105 template <typename Key, typename Value, bool AllowDefValues, typename KeyCompFunc>
1106 bool CDPL::Util::operator<(const MultiMap<Key, Value, AllowDefValues, KeyCompFunc>& map1,
1107  const MultiMap<Key, Value, AllowDefValues, KeyCompFunc>& map2)
1108 {
1109  return (map1.getData() < map2.getData());
1110 }
1111 
1112 template <typename Key, typename Value, bool AllowDefValues, typename KeyCompFunc>
1113 bool CDPL::Util::operator>(const MultiMap<Key, Value, AllowDefValues, KeyCompFunc>& map1,
1114  const MultiMap<Key, Value, AllowDefValues, KeyCompFunc>& map2)
1115 {
1116  return (map1.getData() > map2.getData());
1117 }
1118 
1119 // \endcond
1120 
1121 #endif // CDPL_UTIL_MULTIMAP_HPP
CDPL::Util::MultiMap::ConstEntryIterator
StorageType::const_iterator ConstEntryIterator
A constant iterator used to iterate over the entries of the map.
Definition: MultiMap.hpp:127
CDPL::Util::MultiMap::insertEntry
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:901
CDPL::Util::MultiMap::EntryIteratorRange
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:147
CDPL::Util::MultiMapDefaultValue
Definition: MultiMap.hpp:50
CDPL::Util::MultiMap::removeEntry
void removeEntry(const EntryIterator &it)
Removes the entry pointed to by the iterator it from the map.
Definition: MultiMap.hpp:848
CDPL::Util::MultiMap::isEmpty
bool isEmpty() const
Tells whether the map is empty (getSize() == 0).
Definition: MultiMap.hpp:725
CDPL::Util::MultiMap::getUpperBound
ConstEntryIterator getUpperBound(const Key &key) const
Returns a constant iterator pointing to the first entry whose key is greater than the specified key.
Definition: MultiMap.hpp:974
CDPL::Util::MultiMap::setEntry
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:929
CDPL::Util::MultiMap::getData
const StorageType & getData() const
Definition: MultiMap.hpp:713
CDPL::Util::MultiMap::getUpperBound
EntryIterator getUpperBound(const Key &key)
Returns a mutable iterator pointing to the first entry whose key is greater than the specified key.
Definition: MultiMap.hpp:967
CDPL::Util::MultiMap::MultiMap
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:173
CDPL::Util::operator!=
bool operator!=(const Array< ValueType > &array1, const Array< ValueType > &array2)
Inequality comparison operator.
CDPL::Util::MultiMap::getEntry
ConstEntryIterator getEntry(const Key &key) const
Returns a constant iterator pointing to the first entry with the specified key.
Definition: MultiMap.hpp:763
CDPL::Util::MultiMap::getEntriesReverseBegin
ReverseEntryIterator getEntriesReverseBegin()
Returns a mutable iterator pointing to the beginning of the reversed map.
Definition: MultiMap.hpp:1044
CDPL::Util::MultiMap::ReverseEntryIterator
StorageType::reverse_iterator ReverseEntryIterator
A mutable iterator used to iterate backwards over the entries of the map.
Definition: MultiMap.hpp:142
CDPL::Util::MultiMapDefaultValue::get
static const ValueType & get()
Definition: MultiMap.hpp:52
CDPL::Util::MultiMap::insertEntry
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:894
CDPL::Base::OperationFailed
Thrown to indicate that some requested operation has failed (e.g. due to unfulfilled preconditions or...
Definition: Base/Exceptions.hpp:211
CDPL::Base::ItemNotFound
Thrown to indicate that some requested data item could not be found.
Definition: Base/Exceptions.hpp:171
CDPL::Util::MultiMap::ConstEntryIteratorRange
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:152
CDPL::Util::MultiMap::getNumEntries
std::size_t getNumEntries(const Key &key) const
Returns the number of entries with the specified key.
Definition: MultiMap.hpp:749
CDPL::Util::MultiMap::getClassName
virtual const char * getClassName() const
Returns the name of the (derived) Map class.
Definition: MultiMap.hpp:1064
CDPL::Util::MultiMap::ConstReverseEntryIterator
StorageType::const_reverse_iterator ConstReverseEntryIterator
A constant iterator used to iterate backwards over the entries of the map.
Definition: MultiMap.hpp:132
CDPL::Util::MultiMap::Entry
StorageType::value_type Entry
The type of the key/value pairs stored in the map.
Definition: MultiMap.hpp:122
CDPL::Util::MultiMap::clear
void clear()
Erases all entries.
Definition: MultiMap.hpp:731
CDPL::Util::MultiMap::end
EntryIterator end()
Returns a mutable iterator pointing to the end of the map.
Definition: MultiMap.hpp:1030
CDPL::Util::MultiMap::getLowerBound
EntryIterator getLowerBound(const Key &key)
Returns a mutable iterator pointing to the first entry whose key is not less than the specified key.
Definition: MultiMap.hpp:953
CDPL::Util::MultiMap::insertEntry
EntryIterator insertEntry(const Entry &item)
Inserts the key/value pair item into the map.
Definition: MultiMap.hpp:880
CDPL::Util::MultiMap::ValueType
Value ValueType
The type of the mapped values.
Definition: MultiMap.hpp:114
CDPL::Util::MultiMap::getEntriesBegin
EntryIterator getEntriesBegin()
Returns a mutable iterator pointing to the beginning of the map.
Definition: MultiMap.hpp:988
CDPL::Util::MultiMap::getEntriesBegin
ConstEntryIterator getEntriesBegin() const
Returns a constant iterator pointing to the beginning of the map.
Definition: MultiMap.hpp:981
CDPL::Util::MultiMap::getValue
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:824
CDPL::Util::MultiMap::getEntriesReverseEnd
ConstReverseEntryIterator getEntriesReverseEnd() const
Returns a constant iterator pointing to the end of the reversed map.
Definition: MultiMap.hpp:1051
CDPL::Util::MultiMap::getEntriesEnd
EntryIterator getEntriesEnd()
Returns a mutable iterator pointing to the end of the map.
Definition: MultiMap.hpp:1002
CDPL::Util::MultiMap::getEntries
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:770
CDPL::Util::MultiMap::setEntries
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:944
CDPL::Util::operator<
bool operator<(const Array< ValueType > &array1, const Array< ValueType > &array2)
Less than comparison operator.
CDPL::Util::operator>=
bool operator>=(const Array< ValueType > &array1, const Array< ValueType > &array2)
Greater or equal comparison operator.
CDPL::Util::MultiMap::getEntriesReverseBegin
ConstReverseEntryIterator getEntriesReverseBegin() const
Returns a constant iterator pointing to the beginning of the reversed map.
Definition: MultiMap.hpp:1037
CDPL::Util::MultiMap::getEntriesReverseEnd
ReverseEntryIterator getEntriesReverseEnd()
Returns a mutable iterator pointing to the end of the reversed map.
Definition: MultiMap.hpp:1058
CDPL::Util::MultiMap::begin
ConstEntryIterator begin() const
Returns a constant iterator pointing to the beginning of the map.
Definition: MultiMap.hpp:1009
CDPL::Util::MultiMap::removeEntry
bool removeEntry(const Key &key)
Removes the first entry with the specified key from the map.
Definition: MultiMap.hpp:854
CDPL::Util::MultiMap::getValue
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:798
CDPL::Util::MultiMap::EntryIterator
StorageType::iterator EntryIterator
A mutable iterator used to iterate over the entries of the map.
Definition: MultiMap.hpp:137
CDPL::Util::MultiMap
A multiple sorted associative container that maps keys to values.
Definition: MultiMap.hpp:96
CDPL::Util::MultiMap::~MultiMap
virtual ~MultiMap()
Virtual destructor.
Definition: MultiMap.hpp:192
CDPL::Util::MultiMap::insertEntries
void insertEntries(const InputIter &first, const InputIter &last)
Inserts the key/value pairs in the range [first, last) into the map.
Definition: MultiMap.hpp:936
Exceptions.hpp
Definition of exception classes.
CDPL::Util::operator<=
bool operator<=(const Array< ValueType > &array1, const Array< ValueType > &array2)
Less or equal comparison operator.
CDPL::Util::MultiMap::MultiMap
MultiMap(const KeyCompFunc &func)
Creates an empty map and uses func as key compare function.
Definition: MultiMap.hpp:164
CDPL::Util::MultiMap::operator[]
Value & operator[](const Key &key)
Returns a non-const reference to the first value associated with the specified key.
Definition: MultiMap.hpp:836
CDPL
The namespace of the Chemical Data Processing Library.
CDPL::Util::MultiMap::getData
StorageType & getData()
Definition: MultiMap.hpp:706
CDPL::Util::MultiMap::getEntry
EntryIterator getEntry(const Key &key)
Returns a mutable iterator pointing to the first entry with the specified key.
Definition: MultiMap.hpp:756
CDPL::Util::MultiMapDefaultValue::defValue
static const ValueType defValue
Definition: MultiMap.hpp:57
CDPL::Util::MultiMap::getKeyCompareFunction
KeyCompFunc getKeyCompareFunction() const
Returns the key compare function used by the map.
Definition: MultiMap.hpp:743
CDPL::Util::MultiMap::KeyType
Key KeyType
The type of the map's keys.
Definition: MultiMap.hpp:109
CDPL::Util::MultiMap::getLowerBound
ConstEntryIterator getLowerBound(const Key &key) const
Returns a constant iterator pointing to the first entry whose key is not less than the specified key.
Definition: MultiMap.hpp:960
CDPL::Util::MultiMap::operator[]
const Value & operator[](const Key &key) const
Returns a const reference to the first value associated with the specified key.
Definition: MultiMap.hpp:842
CDPL::Util::MultiMap::insertEntry
EntryIterator insertEntry(const Key &key, const Value &value)
Inserts a new entry with specified key and value into the map.
Definition: MultiMap.hpp:887
CDPL::Util::MultiMap::getValue
const Value & getValue(const Key &key) const
Returns a const reference to the first value associated with the specified key.
Definition: MultiMap.hpp:809
CDPL::Util::MultiMap::removeEntries
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:872
CDPL::Util::MultiMap::getValue
Value & getValue(const Key &key)
Returns a non-const reference to the first value associated with the specified key.
Definition: MultiMap.hpp:783
CDPL::Util::MultiMap::end
ConstEntryIterator end() const
Returns a constant iterator pointing to the end of the map.
Definition: MultiMap.hpp:1023
CDPL::Util::MultiMapDefaultValue< ValueType, false >::get
static const ValueType & get()
Definition: MultiMap.hpp:67
CDPL::Util::operator>
bool operator>(const Array< ValueType > &array1, const Array< ValueType > &array2)
Greater than comparison operator.
CDPL::Util::MultiMap::MultiMap
MultiMap()
Creates an empty map.
Definition: MultiMap.hpp:157
CDPL::Util::MultiMap::getEntriesEnd
ConstEntryIterator getEntriesEnd() const
Returns a constant iterator pointing to the end of the map.
Definition: MultiMap.hpp:995
CDPL::Util::MultiMap::setEntry
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:909
CDPL::Util::operator==
bool operator==(const Array< ValueType > &array1, const Array< ValueType > &array2)
Equality comparison operator.
CDPL::Util::MultiMap::getSize
std::size_t getSize() const
Returns the size (number of entries) of the map.
Definition: MultiMap.hpp:719
CDPL::Util::MultiMap::removeEntries
std::size_t removeEntries(const Key &key)
Removes all entries with the specified key from the map.
Definition: MultiMap.hpp:866
CDPL::Util::MultiMap::MultiMap
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:185
CDPL::Util::MultiMap::SharedPointer
std::shared_ptr< MultiMap > SharedPointer
A reference-counted smart pointer [SHPTR] for dynamically allocated MultiMap instances.
Definition: MultiMap.hpp:104
CDPL::Util::MultiMap::begin
EntryIterator begin()
Returns a mutable iterator pointing to the beginning of the map.
Definition: MultiMap.hpp:1016
CDPL::Util::MultiMap::swap
void swap(MultiMap &map)
Swaps the contents with map.
Definition: MultiMap.hpp:737
CDPL::Util::MultiMap::getEntries
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:777