Chemical Data Processing Library C++ API - Version 1.1.1
Map.hpp
Go to the documentation of this file.
1 /*
2  * Map.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_MAP_HPP
30 #define CDPL_UTIL_MAP_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 MapDefaultValue<ValueType, Allow>::defValue = ValueType();
62 
63  template <typename ValueType>
64  struct MapDefaultValue<ValueType, false>
65  {
66 
67  static const ValueType& get()
68  {
69  throw Base::OperationFailed("Map: default value not supported");
70  }
71  };
72 
93  template <typename Key, typename Value, bool AllowDefValues = false,
94  typename KeyCompFunc = std::less<Key> >
95  class Map
96  {
97 
98  typedef std::map<Key, Value, KeyCompFunc> StorageType;
99 
100  public:
104  typedef std::shared_ptr<Map> 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  Map():
148  data() {}
149 
154  Map(const KeyCompFunc& func):
155  data(func) {}
156 
162  template <typename InputIter>
163  Map(const InputIter& first, const InputIter& last):
164  data(first, last)
165  {}
166 
174  template <typename InputIter>
175  Map(const InputIter& first, const InputIter& last, const KeyCompFunc& func):
176  data(first, last, func)
177  {}
178 
182  virtual ~Map() {}
183 
184  StorageType& getData();
185 
186  const StorageType& getData() const;
187 
192  std::size_t getSize() const;
193 
198  bool isEmpty() const;
199 
203  void clear();
204 
209  void swap(Map& map);
210 
215  KeyCompFunc getKeyCompareFunction() const;
216 
227  EntryIterator getEntry(const Key& key);
228 
239  ConstEntryIterator getEntry(const Key& key) const;
240 
246  bool containsEntry(const Key& key) const;
247 
262  Value& getValue(const Key& key);
263 
278  Value& getValue(const Key& key, Value& def_value);
279 
294  const Value& getValue(const Key& key) const;
295 
310  const Value& getValue(const Key& key, const Value& def_value) const;
311 
323  Value& operator[](const Key& key);
324 
336  const Value& operator[](const Key& key) const;
337 
342  void removeEntry(const EntryIterator& it);
343 
348  bool removeEntry(const Key& key);
349 
355  void removeEntries(const EntryIterator& first, const EntryIterator& last);
356 
372  std::pair<EntryIterator, bool> insertEntry(const Entry& item);
373 
390  std::pair<EntryIterator, bool> insertEntry(const Key& key, const Value& value);
391 
405  EntryIterator insertEntry(const EntryIterator& it, const Entry& item);
406 
421  EntryIterator insertEntry(const EntryIterator& it, const Key& key, const Value& value);
422 
436 
450  EntryIterator setEntry(const Key& key, const Value& value);
451 
462  template <typename InputIter>
463  void insertEntries(const InputIter& first, const InputIter& last);
464 
475  template <typename InputIter>
476  void setEntries(const InputIter& first, const InputIter& last);
477 
482  EntryIterator getLowerBound(const Key& key);
483 
488  ConstEntryIterator getLowerBound(const Key& key) const;
489 
494  EntryIterator getUpperBound(const Key& key);
495 
500  ConstEntryIterator getUpperBound(const Key& key) const;
501 
507 
513 
519 
525 
531 
537 
543 
549 
555 
561 
567 
573 
574 
575  protected:
603  virtual const char* getClassName() const;
604 
605  private:
606  const Value& getDefaultValue() const;
607 
608  StorageType data;
609  };
610 
619  template <typename Key, typename Value, bool AllowDefValues, typename KeyCompFunc>
622 
631  template <typename Key, typename Value, bool AllowDefValues, typename KeyCompFunc>
634 
643  template <typename Key, typename Value, bool AllowDefValues, typename KeyCompFunc>
646 
655  template <typename Key, typename Value, bool AllowDefValues, typename KeyCompFunc>
658 
667  template <typename Key, typename Value, bool AllowDefValues, typename KeyCompFunc>
670 
679  template <typename Key, typename Value, bool AllowDefValues, typename KeyCompFunc>
682 
683  } // namespace Util
684 } // namespace CDPL
685 
686 
687 // Implementation
688 
689 template <typename Key, typename Value, bool AllowDefValues, typename KeyCompFunc>
690 typename CDPL::Util::Map<Key, Value, AllowDefValues, KeyCompFunc>::StorageType&
692 {
693  return data;
694 }
695 
696 template <typename Key, typename Value, bool AllowDefValues, typename KeyCompFunc>
697 const typename CDPL::Util::Map<Key, Value, AllowDefValues, KeyCompFunc>::StorageType&
699 {
700  return data;
701 }
702 
703 template <typename Key, typename Value, bool AllowDefValues, typename KeyCompFunc>
705 {
706  return data.size();
707 }
708 
709 template <typename Key, typename Value, bool AllowDefValues, typename KeyCompFunc>
711 {
712  return data.empty();
713 }
714 
715 template <typename Key, typename Value, bool AllowDefValues, typename KeyCompFunc>
717 {
718  data.clear();
719 }
720 
721 template <typename Key, typename Value, bool AllowDefValues, typename KeyCompFunc>
723 {
724  data.swap(map.data);
725 }
726 
727 template <typename Key, typename Value, bool AllowDefValues, typename KeyCompFunc>
729 {
730  return data.key_comp();
731 }
732 
733 template <typename Key, typename Value, bool AllowDefValues, typename KeyCompFunc>
736 {
737  return data.find(key);
738 }
739 
740 template <typename Key, typename Value, bool AllowDefValues, typename KeyCompFunc>
743 {
744  return data.find(key);
745 }
746 
747 template <typename Key, typename Value, bool AllowDefValues, typename KeyCompFunc>
749 {
750  return (data.find(key) != data.end());
751 }
752 
753 template <typename Key, typename Value, bool AllowDefValues, typename KeyCompFunc>
755 {
756  EntryIterator lb = data.lower_bound(key);
757 
758  if (lb == data.end() || data.key_comp()(key, (*lb).first)) {
759  if (!AllowDefValues)
760  throw Base::ItemNotFound(std::string(getClassName()) + ": key not found");
761 
762  return (*data.insert(lb, Entry(key, getDefaultValue()))).second;
763  }
764 
765  return (*lb).second;
766 }
767 
768 template <typename Key, typename Value, bool AllowDefValues, typename KeyCompFunc>
770 {
771  EntryIterator it = data.find(key);
772 
773  if (it == data.end())
774  return def_value;
775 
776  return (*it).second;
777 }
778 
779 template <typename Key, typename Value, bool AllowDefValues, typename KeyCompFunc>
781 {
782  ConstEntryIterator it = data.find(key);
783 
784  if (it == data.end()) {
785  if (!AllowDefValues)
786  throw Base::ItemNotFound(std::string(getClassName()) + ": key not found");
787 
788  return getDefaultValue();
789  }
790 
791  return (*it).second;
792 }
793 
794 template <typename Key, typename Value, bool AllowDefValues, typename KeyCompFunc>
796  const Value& def_value) const
797 {
798  ConstEntryIterator it = data.find(key);
799 
800  if (it == data.end())
801  return def_value;
802 
803  return (*it).second;
804 }
805 
806 template <typename Key, typename Value, bool AllowDefValues, typename KeyCompFunc>
808 {
809  return getValue(key);
810 }
811 
812 template <typename Key, typename Value, bool AllowDefValues, typename KeyCompFunc>
814 {
815  return getValue(key);
816 }
817 
818 template <typename Key, typename Value, bool AllowDefValues, typename KeyCompFunc>
820 {
821  data.erase(it);
822 }
823 
824 template <typename Key, typename Value, bool AllowDefValues, typename KeyCompFunc>
826 {
827  return (data.erase(key) > 0);
828 }
829 
830 template <typename Key, typename Value, bool AllowDefValues, typename KeyCompFunc>
832  const EntryIterator& last)
833 {
834  data.erase(first, last);
835 }
836 
837 template <typename Key, typename Value, bool AllowDefValues, typename KeyCompFunc>
838 std::pair<typename CDPL::Util::Map<Key, Value, AllowDefValues, KeyCompFunc>::EntryIterator, bool>
840 {
841  return data.insert(item);
842 }
843 
844 template <typename Key, typename Value, bool AllowDefValues, typename KeyCompFunc>
845 std::pair<typename CDPL::Util::Map<Key, Value, AllowDefValues, KeyCompFunc>::EntryIterator, bool>
847 {
848  return data.insert(Entry(key, value));
849 }
850 
851 template <typename Key, typename Value, bool AllowDefValues, typename KeyCompFunc>
854 {
855  return data.insert(it, item);
856 }
857 
858 template <typename Key, typename Value, bool AllowDefValues, typename KeyCompFunc>
861  const Value& value)
862 {
863  return data.insert(it, Entry(key, value));
864 }
865 
866 template <typename Key, typename Value, bool AllowDefValues, typename KeyCompFunc>
869 {
870  EntryIterator lb = data.lower_bound(item.first);
871 
872  if (lb == data.end() || data.key_comp()(item.first, (*lb).first))
873  return data.insert(lb, item);
874 
875  (*lb).second = item.second;
876  return lb;
877 }
878 
879 template <typename Key, typename Value, bool AllowDefValues, typename KeyCompFunc>
882 {
883  return setEntry(Entry(key, value));
884 }
885 
886 template <typename Key, typename Value, bool AllowDefValues, typename KeyCompFunc>
887 template <typename InputIter>
888 void CDPL::Util::Map<Key, Value, AllowDefValues, KeyCompFunc>::insertEntries(const InputIter& first, const InputIter& last)
889 {
890  data.insert(first, last);
891 }
892 
893 template <typename Key, typename Value, bool AllowDefValues, typename KeyCompFunc>
894 template <typename InputIter>
895 void CDPL::Util::Map<Key, Value, AllowDefValues, KeyCompFunc>::setEntries(const InputIter& first, const InputIter& last)
896 {
897  for (InputIter it = first; it != last; ++it)
898  setEntry(*it);
899 }
900 
901 template <typename Key, typename Value, bool AllowDefValues, typename KeyCompFunc>
904 {
905  return data.lower_bound(key);
906 }
907 
908 template <typename Key, typename Value, bool AllowDefValues, typename KeyCompFunc>
911 {
912  return data.lower_bound(key);
913 }
914 
915 template <typename Key, typename Value, bool AllowDefValues, typename KeyCompFunc>
918 {
919  return data.upper_bound(key);
920 }
921 
922 template <typename Key, typename Value, bool AllowDefValues, typename KeyCompFunc>
925 {
926  return data.upper_bound(key);
927 }
928 
929 template <typename Key, typename Value, bool AllowDefValues, typename KeyCompFunc>
932 {
933  return data.begin();
934 }
935 
936 template <typename Key, typename Value, bool AllowDefValues, typename KeyCompFunc>
939 {
940  return data.begin();
941 }
942 
943 template <typename Key, typename Value, bool AllowDefValues, typename KeyCompFunc>
946 {
947  return data.end();
948 }
949 
950 template <typename Key, typename Value, bool AllowDefValues, typename KeyCompFunc>
953 {
954  return data.end();
955 }
956 
957 template <typename Key, typename Value, bool AllowDefValues, typename KeyCompFunc>
960 {
961  return data.begin();
962 }
963 
964 template <typename Key, typename Value, bool AllowDefValues, typename KeyCompFunc>
967 {
968  return data.begin();
969 }
970 
971 template <typename Key, typename Value, bool AllowDefValues, typename KeyCompFunc>
974 {
975  return data.end();
976 }
977 
978 template <typename Key, typename Value, bool AllowDefValues, typename KeyCompFunc>
981 {
982  return data.end();
983 }
984 
985 template <typename Key, typename Value, bool AllowDefValues, typename KeyCompFunc>
988 {
989  return data.rbegin();
990 }
991 
992 template <typename Key, typename Value, bool AllowDefValues, typename KeyCompFunc>
995 {
996  return data.rbegin();
997 }
998 
999 template <typename Key, typename Value, bool AllowDefValues, typename KeyCompFunc>
1002 {
1003  return data.rend();
1004 }
1005 
1006 template <typename Key, typename Value, bool AllowDefValues, typename KeyCompFunc>
1009 {
1010  return data.rend();
1011 }
1012 
1013 template <typename Key, typename Value, bool AllowDefValues, typename KeyCompFunc>
1015 {
1016  return "Map";
1017 }
1018 
1019 template <typename Key, typename Value, bool AllowDefValues, typename KeyCompFunc>
1021 {
1023 }
1024 
1025 // \cond DOC_IMPL_DETAILS
1026 
1027 template <typename Key, typename Value, bool AllowDefValues, typename KeyCompFunc>
1028 bool CDPL::Util::operator==(const Map<Key, Value, AllowDefValues, KeyCompFunc>& map1,
1029  const Map<Key, Value, AllowDefValues, KeyCompFunc>& map2)
1030 {
1031  return (map1.getData() == map2.getData());
1032 }
1033 
1034 template <typename Key, typename Value, bool AllowDefValues, typename KeyCompFunc>
1035 bool CDPL::Util::operator!=(const Map<Key, Value, AllowDefValues, KeyCompFunc>& map1,
1036  const Map<Key, Value, AllowDefValues, KeyCompFunc>& map2)
1037 {
1038  return (map1.getData() != map2.getData());
1039 }
1040 
1041 template <typename Key, typename Value, bool AllowDefValues, typename KeyCompFunc>
1042 bool CDPL::Util::operator<=(const Map<Key, Value, AllowDefValues, KeyCompFunc>& map1,
1043  const Map<Key, Value, AllowDefValues, KeyCompFunc>& map2)
1044 {
1045  return (map1.getData() <= map2.getData());
1046 }
1047 
1048 template <typename Key, typename Value, bool AllowDefValues, typename KeyCompFunc>
1049 bool CDPL::Util::operator>=(const Map<Key, Value, AllowDefValues, KeyCompFunc>& map1,
1050  const Map<Key, Value, AllowDefValues, KeyCompFunc>& map2)
1051 {
1052  return (map1.getData() >= map2.getData());
1053 }
1054 
1055 template <typename Key, typename Value, bool AllowDefValues, typename KeyCompFunc>
1056 bool CDPL::Util::operator<(const Map<Key, Value, AllowDefValues, KeyCompFunc>& map1,
1057  const Map<Key, Value, AllowDefValues, KeyCompFunc>& map2)
1058 {
1059  return (map1.getData() < map2.getData());
1060 }
1061 
1062 template <typename Key, typename Value, bool AllowDefValues, typename KeyCompFunc>
1063 bool CDPL::Util::operator>(const Map<Key, Value, AllowDefValues, KeyCompFunc>& map1,
1064  const Map<Key, Value, AllowDefValues, KeyCompFunc>& map2)
1065 {
1066  return (map1.getData() > map2.getData());
1067 }
1068 
1069 // \endcond
1070 
1071 #endif // CDPL_UTIL_MAP_HPP
CDPL::Util::Map::operator[]
const Value & operator[](const Key &key) const
Returns a const reference to the value associated with the specified key.
Definition: Map.hpp:813
CDPL::Util::Map::setEntry
EntryIterator setEntry(const Entry &item)
Inserts a new entry or updates the value of an existing entry with the key and value given by item.
Definition: Map.hpp:868
CDPL::Util::Map::getData
StorageType & getData()
Definition: Map.hpp:691
CDPL::Util::Map::begin
EntryIterator begin()
Returns a mutable iterator pointing to the beginning of the map.
Definition: Map.hpp:966
CDPL::Util::Map::setEntry
EntryIterator setEntry(const Key &key, const Value &value)
Inserts a new entry or updates the value of an existing entry with the specified key and value.
Definition: Map.hpp:881
CDPL::Util::Map::getEntriesEnd
ConstEntryIterator getEntriesEnd() const
Returns a constant iterator pointing to the end of the map.
Definition: Map.hpp:945
CDPL::Util::Map::getKeyCompareFunction
KeyCompFunc getKeyCompareFunction() const
Returns the key compare function used by the map.
Definition: Map.hpp:728
CDPL::Util::Map::SharedPointer
std::shared_ptr< Map > SharedPointer
A reference-counted smart pointer [SHPTR] for dynamically allocated Map instances.
Definition: Map.hpp:104
CDPL::Util::Map::getValue
Value & getValue(const Key &key)
Returns a non-const reference to the value associated with the specified key.
Definition: Map.hpp:754
CDPL::Util::operator!=
bool operator!=(const Array< ValueType > &array1, const Array< ValueType > &array2)
Inequality comparison operator.
CDPL::Util::Map::clear
void clear()
Erases all entries.
Definition: Map.hpp:716
CDPL::Util::Map::ConstEntryIterator
StorageType::const_iterator ConstEntryIterator
A constant iterator used to iterate over the entries of the map.
Definition: Map.hpp:127
CDPL::Util::Map::isEmpty
bool isEmpty() const
Tells whether the map is empty (getSize() == 0).
Definition: Map.hpp:710
CDPL::Util::Map
A unique sorted associative container that maps keys to values.
Definition: Map.hpp:96
CDPL::Util::Map::containsEntry
bool containsEntry(const Key &key) const
Tells whether the map contains an entry with the specified key.
Definition: Map.hpp:748
CDPL::Util::Map::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: Map.hpp:910
CDPL::Util::Map::getEntry
EntryIterator getEntry(const Key &key)
Returns a mutable iterator pointing to the entry specified by key.
Definition: Map.hpp:735
CDPL::Util::Map::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: Map.hpp:903
CDPL::Util::Map::getEntry
ConstEntryIterator getEntry(const Key &key) const
Returns a constant iterator pointing to the entry specified by key.
Definition: Map.hpp:742
CDPL::Util::Map::begin
ConstEntryIterator begin() const
Returns a constant iterator pointing to the beginning of the map.
Definition: Map.hpp:959
CDPL::Util::Map::getEntriesReverseBegin
ReverseEntryIterator getEntriesReverseBegin()
Returns a mutable iterator pointing to the beginning of the reversed map.
Definition: Map.hpp:994
CDPL::Util::Map::insertEntry
std::pair< EntryIterator, bool > insertEntry(const Entry &item)
Tries to insert the key/value pair item into the map.
Definition: Map.hpp:839
CDPL::Util::Map::getUpperBound
EntryIterator getUpperBound(const Key &key)
Returns a mutable iterator pointing to the first entry whose key is greater than the specified key.
Definition: Map.hpp:917
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::Util::Map::removeEntry
bool removeEntry(const Key &key)
Removes the entry specified by key from the map.
Definition: Map.hpp:825
CDPL::Base::ItemNotFound
Thrown to indicate that some requested data item could not be found.
Definition: Base/Exceptions.hpp:171
CDPL::Util::Map::getValue
const Value & getValue(const Key &key, const Value &def_value) const
Returns a const reference to the value associated with the specified key, or the value given by the s...
Definition: Map.hpp:795
CDPL::Util::Map::Entry
StorageType::value_type Entry
The type of the key/value pairs stored in the map.
Definition: Map.hpp:122
CDPL::Util::Map::getValue
const Value & getValue(const Key &key) const
Returns a const reference to the value associated with the specified key.
Definition: Map.hpp:780
CDPL::Util::Map::getSize
std::size_t getSize() const
Returns the size (number of entries) of the map.
Definition: Map.hpp:704
CDPL::Util::Map::getData
const StorageType & getData() const
Definition: Map.hpp:698
CDPL::Util::Map::ValueType
Value ValueType
The type of the mapped values.
Definition: Map.hpp:114
CDPL::Util::Map::Map
Map()
Creates an empty map.
Definition: Map.hpp:147
CDPL::Util::Map::getEntriesReverseEnd
ReverseEntryIterator getEntriesReverseEnd()
Returns a mutable iterator pointing to the end of the reversed map.
Definition: Map.hpp:1008
CDPL::Util::Map::getValue
Value & getValue(const Key &key, Value &def_value)
Returns a non-const reference to the value associated with the specified key, or the value given by t...
Definition: Map.hpp:769
CDPL::Util::Map::removeEntry
void removeEntry(const EntryIterator &it)
Removes the entry pointed to by the iterator it from the map.
Definition: Map.hpp:819
CDPL::Util::Map::getEntriesReverseEnd
ConstReverseEntryIterator getEntriesReverseEnd() const
Returns a constant iterator pointing to the end of the reversed map.
Definition: Map.hpp:1001
CDPL::Util::Map::EntryIterator
StorageType::iterator EntryIterator
A mutable iterator used to iterate over the entries of the map.
Definition: Map.hpp:137
CDPL::Util::Map::insertEntry
EntryIterator insertEntry(const EntryIterator &it, const Entry &item)
Tries to insert the key/value pair item into the map and uses the iterator it as a hint for the inser...
Definition: Map.hpp:853
CDPL::Util::MapDefaultValue< ValueType, false >::get
static const ValueType & get()
Definition: Map.hpp:67
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::MapDefaultValue::defValue
static const ValueType defValue
Definition: Map.hpp:57
CDPL::Util::Map::swap
void swap(Map &map)
Swaps the contents with map.
Definition: Map.hpp:722
CDPL::Util::Map::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: Map.hpp:924
CDPL::Util::Map::getEntriesEnd
EntryIterator getEntriesEnd()
Returns a mutable iterator pointing to the end of the map.
Definition: Map.hpp:952
Exceptions.hpp
Definition of exception classes.
CDPL::Util::MapDefaultValue
Definition: Map.hpp:50
CDPL::Util::operator<=
bool operator<=(const Array< ValueType > &array1, const Array< ValueType > &array2)
Less or equal comparison operator.
CDPL
The namespace of the Chemical Data Processing Library.
CDPL::Util::Map::Map
Map(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: Map.hpp:175
CDPL::Util::Map::end
EntryIterator end()
Returns a mutable iterator pointing to the end of the map.
Definition: Map.hpp:980
CDPL::Util::Map::end
ConstEntryIterator end() const
Returns a constant iterator pointing to the end of the map.
Definition: Map.hpp:973
CDPL::Util::Map::insertEntry
std::pair< EntryIterator, bool > insertEntry(const Key &key, const Value &value)
Tries to insert a new entry with specified key and value into the map.
Definition: Map.hpp:846
CDPL::Util::Map::insertEntry
EntryIterator insertEntry(const EntryIterator &it, const Key &key, const Value &value)
Tries to insert a new entry with the specified key and value into the map and uses the iterator it as...
Definition: Map.hpp:860
CDPL::Util::Map::getEntriesReverseBegin
ConstReverseEntryIterator getEntriesReverseBegin() const
Returns a constant iterator pointing to the beginning of the reversed map.
Definition: Map.hpp:987
CDPL::Util::Map::Map
Map(const KeyCompFunc &func)
Creates an empty map and uses func as key compare function.
Definition: Map.hpp:154
CDPL::Util::Map::insertEntries
void insertEntries(const InputIter &first, const InputIter &last)
Tries to insert the key/value pairs in the range [first, last).
Definition: Map.hpp:888
CDPL::Util::Map::getClassName
virtual const char * getClassName() const
Returns the name of the (derived) Map class.
Definition: Map.hpp:1014
CDPL::Util::Map::Map
Map(const InputIter &first, const InputIter &last)
Creates and initializes the map with copies of the key value pairs in the range [first,...
Definition: Map.hpp:163
CDPL::Util::operator>
bool operator>(const Array< ValueType > &array1, const Array< ValueType > &array2)
Greater than comparison operator.
CDPL::Util::operator==
bool operator==(const Array< ValueType > &array1, const Array< ValueType > &array2)
Equality comparison operator.
CDPL::Util::Map::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: Map.hpp:831
CDPL::Util::Map::operator[]
Value & operator[](const Key &key)
Returns a non-const reference to the value associated with the specified key.
Definition: Map.hpp:807
CDPL::Util::Map::ReverseEntryIterator
StorageType::reverse_iterator ReverseEntryIterator
A mutable iterator used to iterate backwards over the entries of the map.
Definition: Map.hpp:142
CDPL::Util::Map::getEntriesBegin
ConstEntryIterator getEntriesBegin() const
Returns a constant iterator pointing to the beginning of the map.
Definition: Map.hpp:931
CDPL::Util::Map::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: Map.hpp:895
CDPL::Util::Map::KeyType
Key KeyType
The type of the map's keys.
Definition: Map.hpp:109
CDPL::Util::MapDefaultValue::get
static const ValueType & get()
Definition: Map.hpp:52
CDPL::Util::Map::getEntriesBegin
EntryIterator getEntriesBegin()
Returns a mutable iterator pointing to the beginning of the map.
Definition: Map.hpp:938
CDPL::Util::Map::~Map
virtual ~Map()
Virtual destructor.
Definition: Map.hpp:182
CDPL::Util::Map::ConstReverseEntryIterator
StorageType::const_reverse_iterator ConstReverseEntryIterator
A constant iterator used to iterate backwards over the entries of the map.
Definition: Map.hpp:132