ROSE  0.11.145.0
Sawyer/Map.h
1 // WARNING: Changes to this file must be contributed back to Sawyer or else they will
2 // be clobbered by the next update from Sawyer. The Sawyer repository is at
3 // https://github.com/matzke1/sawyer.
4 
5 
6 
7 
8 #ifndef Sawyer_Map_H
9 #define Sawyer_Map_H
10 
11 #include <Sawyer/Interval.h>
12 #include <Sawyer/Optional.h>
13 #include <Sawyer/Sawyer.h>
14 #include <boost/range/iterator_range.hpp>
15 #include <boost/serialization/access.hpp>
16 #include <boost/serialization/nvp.hpp>
17 #include <boost/serialization/map.hpp>
18 #include <stdexcept>
19 
20 namespace Sawyer {
21 
47 namespace Container {
48 
62 template<class K,
63  class T,
64  class Cmp = std::less<K>,
65  class Alloc = std::allocator<std::pair<const K, T> > >
66 class Map {
67 public:
68  typedef K Key;
69  typedef T Value;
70  typedef Cmp Comparator;
71  typedef Alloc Allocator;
73 private:
74  typedef std::map<Key, Value, Comparator, Alloc> StlMap;
75  StlMap map_;
76 
77 private:
78  friend class boost::serialization::access;
79 
80  template<class S>
81  void serialize(S &s, const unsigned /*version*/) {
82  s & BOOST_SERIALIZATION_NVP(map_);
83  }
84 
85 public:
89  class Node: private std::pair<const Key, Value> {
90  // This class MUST BE binary compatible with its super class (see NodeIterator::operator* below)
91  public:
92  explicit Node(const std::pair<const Key, Value> &pair): std::pair<const Key, Value>(pair) {}
93  Node(const Key &key, Value &value): std::pair<const Key, Value>(key, value) {}
94  public:
98  const Key& key() const { return this->first; }
99 
105  Value& value() { return this->second; }
106  const Value& value() const { return this->second; }
108  };
109 
111  // Iterators
113 private:
114  template<class Derived, class Value, class BaseIterator>
115  class BidirectionalIterator {
116 
117  public:
118  // Five standard iterator types
119  using iterator_category = std::bidirectional_iterator_tag;
120  using value_type = Value;
121  using difference_type = std::ptrdiff_t;
122  using pointer = Value*;
123  using reference = Value&;
124 
125  protected:
126  BaseIterator base_;
127  BidirectionalIterator() {}
128  BidirectionalIterator(const BaseIterator &base): base_(base) {}
129  BidirectionalIterator(const BidirectionalIterator &other): base_(other.base_) {}
130 
131  public:
132  Derived& operator=(const Derived &other) { base_ = other.base(); return *derived(); }
133  BidirectionalIterator& operator=(const BidirectionalIterator &other) { base_ = other.base(); return *this; }
134 
136  Derived& operator++() { ++base_; return *derived(); }
137 
139  Derived operator++(int) { Derived old=*derived(); ++*this; return old; }
140 
142  Derived& operator--() { --base_; return *derived(); }
143 
145  Derived operator--(int) { Derived old=*derived(); --*this; return old; }
146 
151  template<class OtherIter> bool operator==(const OtherIter &other) const { return base_ == other.base(); }
152 
156  template<class OtherIter> bool operator!=(const OtherIter &other) const { return base_ != other.base(); }
157 
158  const BaseIterator& base() const { return base_; }
159  protected:
160  Derived* derived() { return static_cast<Derived*>(this); }
161  const Derived* derived() const { return static_cast<const Derived*>(this); }
162  };
163 
164 public:
169  class NodeIterator: public BidirectionalIterator<NodeIterator, Node, typename StlMap::iterator> {
170  typedef BidirectionalIterator<NodeIterator, Node, typename StlMap::iterator> Super;
171  public:
172  NodeIterator() {}
173 
175  NodeIterator(const NodeIterator &other): Super(other) {}
176 
178  NodeIterator& operator=(const NodeIterator &other) { this->Super::operator=(other); return *this; }
179 
180  // std::map stores std::pair nodes, but we want to return Node, which must have the same layout.
182  Node& operator*() const { return *(Node*)&*this->base_; }
183 
185  Node* operator->() const { return (Node*)&*this->base_; }
186  private:
187  friend class Map;
188  NodeIterator(const typename StlMap::iterator &base): Super(base) {}
189  };
190 
195  class ConstNodeIterator: public BidirectionalIterator<ConstNodeIterator, const Node, typename StlMap::const_iterator> {
196  typedef BidirectionalIterator<ConstNodeIterator, const Node, typename StlMap::const_iterator> Super;
197  public:
198  ConstNodeIterator() {}
199 
201  ConstNodeIterator(const ConstNodeIterator &other): Super(other) {}
202 
204  ConstNodeIterator(const NodeIterator &other): Super(typename StlMap::const_iterator(other.base())) {}
205 
207  ConstNodeIterator& operator=(const ConstNodeIterator &other) { this->Super::operator=(other); return *this; }
208 
209  // std::map stores std::pair nodes, but we want to return Node, which must have the same layout.
211  const Node& operator*() const { return *(const Node*)&*this->base_; }
212 
214  const Node* operator->() const { return (const Node*)&*this->base_; }
215  private:
216  friend class Map;
217  ConstNodeIterator(const typename StlMap::const_iterator &base): Super(base) {}
218  ConstNodeIterator(const typename StlMap::iterator &base): Super(typename StlMap::const_iterator(base)) {}
219  };
220 
225  class ConstKeyIterator: public BidirectionalIterator<ConstKeyIterator, const Key, typename StlMap::const_iterator> {
226  typedef BidirectionalIterator<ConstKeyIterator, const Key, typename StlMap::const_iterator> Super;
227  public:
228  ConstKeyIterator() {}
229 
231  ConstKeyIterator(const ConstKeyIterator &other): Super(other) {}
232 
234  ConstKeyIterator(const NodeIterator &other): Super(typename StlMap::const_iterator(other.base())) {}
235 
237  ConstKeyIterator(const ConstNodeIterator &other): Super(other.base()) {}
238 
240  ConstKeyIterator& operator=(const ConstKeyIterator &other) { this->Super::operator=(other); return *this; }
241 
243  const Key& operator*() const { return this->base()->first; }
244 
246  const Key* operator->() const { return &this->base()->first; }
247  };
248 
253  class ValueIterator: public BidirectionalIterator<ValueIterator, Value, typename StlMap::iterator> {
254  typedef BidirectionalIterator<ValueIterator, Value, typename StlMap::iterator> Super;
255  public:
256  ValueIterator() {}
257 
259  ValueIterator(const ValueIterator &other): Super(other) {}
260 
262  ValueIterator(const NodeIterator &other): Super(other.base()) {}
263 
265  ValueIterator& operator=(const ValueIterator &other) { this->Super::operator=(other); return *this; }
266 
268  Value& operator*() const { return this->base()->second; }
269 
271  Value* operator->() const { return &this->base()->second; }
272  };
273 
278  class ConstValueIterator: public BidirectionalIterator<ConstValueIterator, const Value, typename StlMap::const_iterator> {
279  typedef BidirectionalIterator<ConstValueIterator, const Value, typename StlMap::const_iterator> Super;
280  public:
281  ConstValueIterator() {}
282 
284  ConstValueIterator(const ConstValueIterator &other): Super(other) {}
285 
287  ConstValueIterator(const ValueIterator &other): Super(typename StlMap::const_iterator(other.base())) {}
288 
290  ConstValueIterator(const ConstNodeIterator &other): Super(other.base()) {}
291 
293  ConstValueIterator(const NodeIterator &other): Super(typename StlMap::const_iterator(other.base())) {}
294 
296  ConstValueIterator& operator=(const ConstValueIterator &other) { this->Super::operator=(other); return *this; }
297 
299  const Value& operator*() const { return this->base()->second; }
300 
302  const Value* operator->() const { return &this->base()->second; }
303  };
304 
305 
307  // Constructors
309 public:
310 
314  Map() {}
315 
319  explicit Map(const Comparator &comparator, const Allocator &allocator = Allocator())
320  : map_(comparator, allocator) {}
321 
323  Map(const Map& other) {
324  map_ = other.map_;
325  }
326 
331  template<class Key2, class T2, class Cmp2, class Alloc2>
333  typedef typename Map<Key2, T2, Cmp2, Alloc2>::ConstNodeIterator OtherIterator;
334  boost::iterator_range<OtherIterator> otherNodes = other.nodes();
335  for (OtherIterator otherIter=otherNodes.begin(); otherIter!=otherNodes.end(); ++otherIter)
336  map_.insert(map_.end(), std::make_pair(Key(otherIter->key()), Value(otherIter->value())));
337  }
338 
339  Map& operator=(const Map &other) {
340  clear();
341  for (const auto &node: other.nodes())
342  map_.insert(map_.end(), std::make_pair(node.key(), node.value()));
343  return *this;
344  }
345 
349  template<class Key2, class T2, class Cmp2, class Alloc2>
351  typedef typename Map<Key2, T2, Cmp2, Alloc2>::ConstNodeIterator OtherIterator;
352  clear();
353  boost::iterator_range<OtherIterator> otherNodes = other.nodes();
354  for (OtherIterator otherIter=otherNodes.begin(); otherIter!=otherNodes.end(); ++otherIter)
355  map_.insert(map_.end(), std::make_pair(Key(otherIter->key()), Value(otherIter->value())));
356  return *this;
357  }
358 
359 
361  // Iteration
363 public:
369  boost::iterator_range<NodeIterator> nodes() {
370  return boost::iterator_range<NodeIterator>(NodeIterator(map_.begin()), NodeIterator(map_.end()));
371  }
372  boost::iterator_range<ConstNodeIterator> nodes() const {
373  return boost::iterator_range<ConstNodeIterator>(ConstNodeIterator(map_.begin()), ConstNodeIterator(map_.end()));
374  }
382  boost::iterator_range<ConstKeyIterator> keys() {
383  return boost::iterator_range<ConstKeyIterator>(NodeIterator(map_.begin()), NodeIterator(map_.end()));
384  }
385  boost::iterator_range<ConstKeyIterator> keys() const {
386  return boost::iterator_range<ConstKeyIterator>(ConstNodeIterator(map_.begin()), ConstNodeIterator(map_.end()));
387  }
396  boost::iterator_range<ValueIterator> values() {
397  return boost::iterator_range<ValueIterator>(NodeIterator(map_.begin()), NodeIterator(map_.end()));
398  }
399  boost::iterator_range<ConstValueIterator> values() const {
400  return boost::iterator_range<ConstValueIterator>(ConstNodeIterator(map_.begin()), ConstNodeIterator(map_.end()));
401  }
405  // Size and capacity
408 public:
409 
413  bool isEmpty() const {
414  return map_.empty();
415  }
416 
420  size_t size() const {
421  return map_.size();
422  }
423 
425  Key least() const {
426  ASSERT_forbid(isEmpty());
427  return map_.begin()->first;
428  }
429 
431  Key greatest() const {
432  ASSERT_forbid(isEmpty());
433  typename StlMap::const_iterator last = map_.end();
434  --last;
435  return last->first;
436  }
437 
445  Interval<Key> hull() const {
447  }
448 
449 
451  // Searching
453 public:
454 
462  NodeIterator find(const Key &key) {
463  return map_.find(key);
464  }
465  ConstNodeIterator find(const Key &key) const {
466  return map_.find(key);
467  }
475  bool exists(const Key &key) const {
476  return map_.find(key)!=map_.end();
477  }
478 
488  NodeIterator lowerBound(const Key &key) {
489  return map_.lower_bound(key);
490  }
491  ConstNodeIterator lowerBound(const Key &key) const {
492  return map_.lower_bound(key);
493  }
505  NodeIterator upperBound(const Key &key) {
506  return map_.upper_bound(key);
507  }
508  ConstNodeIterator upperBound(const Key &key) const {
509  return map_.upper_bound(key);
510  }
514  // Accessors
517 public:
518 
531  Value& operator[](const Key &key) {
532  return get(key);
533  }
534  const Value& operator[](const Key &key) const {
535  return get(key);
536  }
547  Value& get(const Key &key) {
548  typename StlMap::iterator found = map_.find(key);
549  if (found==map_.end())
550  throw std::domain_error("key lookup failure; key is not in map domain");
551  return found->second;
552  }
553  const Value& get(const Key &key) const {
554  typename StlMap::const_iterator found = map_.find(key);
555  if (found==map_.end())
556  throw std::domain_error("key lookup failure; key is not in map domain");
557  return found->second;
558  }
584  Optional<Value> getOptional(const Key &key) const {
585  typename StlMap::const_iterator found = map_.find(key);
586  return found == map_.end() ? Optional<Value>() : Optional<Value>(found->second);
587  }
588 
596  Value& getOrElse(const Key &key, Value &dflt) {
597  typename StlMap::iterator found = map_.find(key);
598  return found == map_.end() ? dflt : found->second;
599  }
600  const Value& getOrElse(const Key &key, const Value &dflt) const {
601  typename StlMap::const_iterator found = map_.find(key);
602  return found == map_.end() ? dflt : found->second;
603  }
611  const Value& getOrDefault(const Key &key) const {
612  static const Value dflt;
613  typename StlMap::const_iterator found = map_.find(key);
614  return found==map_.end() ? dflt : found->second;
615  }
616 
618  // Mutators
620 public:
621 
628  Map& insert(const Key &key, const Value &value) {
629  std::pair<typename StlMap::iterator, bool> inserted = map_.insert(std::make_pair(key, value));
630  if (!inserted.second)
631  inserted.first->second = value;
632  return *this;
633  }
634 
641  Map& insertDefault(const Key &key) {
642  map_[key] = T();
643  return *this;
644  }
645 
663  template<class OtherNodeIterator>
664  Map& insertMultiple(const OtherNodeIterator &begin, const OtherNodeIterator &end) {
665  for (OtherNodeIterator otherIter=begin; otherIter!=end; ++otherIter)
666  insert(Key(otherIter->key()), Value(otherIter->value()));
667  return *this;
668  }
669  template<class OtherNodeIterator>
670  Map& insertMultiple(const boost::iterator_range<OtherNodeIterator> &range) {
671  return insertMultiple(range.begin(), range.end());
672  }
682  Value& insertMaybe(const Key &key, const Value &value) {
683  return map_.insert(std::make_pair(key, value)).first->second;
684  }
685 
693  Value& insertMaybeDefault(const Key &key) {
694  return map_.insert(std::make_pair(key, T())).first->second;
695  }
696 
703  template<class OtherNodeIterator>
704  Map& insertMaybeMultiple(const boost::iterator_range<OtherNodeIterator> &range) {
705  for (OtherNodeIterator otherIter=range.begin(); otherIter!=range.end(); ++otherIter)
706  insertMaybe(Key(otherIter->key()), Value(otherIter->value()));
707  return *this;
708  }
709 
714  Map& clear() {
715  map_.clear();
716  return *this;
717  }
718 
726  Map& erase(const Key &key) {
727  map_.erase(key);
728  return *this;
729  }
730 
739  template<class OtherKeyIterator>
740  Map& eraseMultiple(const boost::iterator_range<OtherKeyIterator> &range) {
741  for (OtherKeyIterator otherIter=range.begin(); otherIter!=range.end(); ++otherIter)
742  map_.erase(Key(*otherIter));
743  return *this;
744  }
745 
753  Map& eraseAt(const NodeIterator &iter) {
754  map_.erase(iter.base());
755  return *this;
756  }
757  Map& eraseAt(const ConstKeyIterator &iter) {
758  // std::map can't erase using a const_iterator
759  ASSERT_require(iter != keys().end());
760  typename StlMap::iterator stdIter = map_.find(*iter);
761  ASSERT_require(stdIter != map_.end());
762  map_.erase(stdIter);
763  return *this;
764  }
765  Map& eraseAt(const ValueIterator &iter) {
766  map_.erase(iter.base());
767  return *this;
768  }
778  template<class Iter>
779  Map& eraseAtMultiple(const Iter &begin, const Iter &end) {
780  map_.erase(begin.base(), end.base());
781  return *this;
782  }
783  template<class Iter>
784  Map& eraseAtMultiple(const boost::iterator_range<Iter> &range) {
785  map_.erase(range.begin().base(), range.end().base());
786  return *this;
787  }
790 };
791 
792 } // namespace
793 } // namespace
794 
795 #endif
const Value * operator->() const
Returns a pointer to the value of the storage node.
Definition: Sawyer/Map.h:302
boost::iterator_range< ConstKeyIterator > keys() const
Iterators for container keys.
Definition: Sawyer/Map.h:385
ValueIterator & operator=(const ValueIterator &other)
Assignment.
Definition: Sawyer/Map.h:265
Map(const Map &other)
Copy constructor.
Definition: Sawyer/Map.h:323
bool exists(const Key &key) const
Determine if a key exists.
Definition: Sawyer/Map.h:475
Value & operator[](const Key &key)
Return a reference to an existing value.
Definition: Sawyer/Map.h:531
NodeIterator(const NodeIterator &other)
Copy constructor.
Definition: Sawyer/Map.h:175
Optional< Value > getOptional(const Key &key) const
Lookup and return a value or nothing.
Definition: Sawyer/Map.h:584
const Value & operator[](const Key &key) const
Return a reference to an existing value.
Definition: Sawyer/Map.h:534
Map()
Default constructor.
Definition: Sawyer/Map.h:314
ValueIterator(const ValueIterator &other)
Copy constructor.
Definition: Sawyer/Map.h:259
ConstNodeIterator(const ConstNodeIterator &other)
Copy constructor.
Definition: Sawyer/Map.h:201
Value & value()
Value part of key/value node.
Definition: Sawyer/Map.h:105
ConstNodeIterator upperBound(const Key &key) const
Find a node close to a key.
Definition: Sawyer/Map.h:508
Map(const Comparator &comparator, const Allocator &allocator=Allocator())
Constructs an empty map.
Definition: Sawyer/Map.h:319
boost::iterator_range< ConstNodeIterator > nodes() const
Iterators for container nodes.
Definition: Sawyer/Map.h:372
Value & operator*() const
Dereference iterator to return the value of the storage node.
Definition: Sawyer/Map.h:268
const Value & getOrElse(const Key &key, const Value &dflt) const
Lookup and return a value or something else.
Definition: Sawyer/Map.h:600
ConstNodeIterator & operator=(const ConstNodeIterator &other)
Assignment.
Definition: Sawyer/Map.h:207
ConstNodeIterator lowerBound(const Key &key) const
Find a node close to a key.
Definition: Sawyer/Map.h:491
Value & insertMaybeDefault(const Key &key)
Conditionally insert a new key with default value.
Definition: Sawyer/Map.h:693
Map & eraseAt(const ValueIterator &iter)
Remove a node by iterator.
Definition: Sawyer/Map.h:765
const Key & operator*() const
Dereference iterator to return the interval of the storage node.
Definition: Sawyer/Map.h:243
Node * operator->() const
Returns a pointer to a storage node.
Definition: Sawyer/Map.h:185
Map & clear()
Remove all nodes.
Definition: Sawyer/Map.h:714
NodeIterator & operator=(const NodeIterator &other)
Assignment.
Definition: Sawyer/Map.h:178
boost::iterator_range< ValueIterator > values()
Iterators for container values.
Definition: Sawyer/Map.h:396
Cmp Comparator
Type of comparator, third template argument.
Definition: Sawyer/Map.h:70
Name space for the entire library.
Definition: FeasiblePath.h:767
Bidirectional iterator over key/value nodes.
Definition: Sawyer/Map.h:169
Alloc Allocator
Type of allocator, fourth template argument.
Definition: Sawyer/Map.h:71
Value & getOrElse(const Key &key, Value &dflt)
Lookup and return a value or something else.
Definition: Sawyer/Map.h:596
bool isEmpty() const
Determines whether this container is empty.
Definition: Sawyer/Map.h:413
Map & insertDefault(const Key &key)
Insert or update a key with a default value.
Definition: Sawyer/Map.h:641
ConstNodeIterator find(const Key &key) const
Find a node by key.
Definition: Sawyer/Map.h:465
Map & insertMultiple(const boost::iterator_range< OtherNodeIterator > &range)
Insert multiple values.
Definition: Sawyer/Map.h:670
NodeIterator lowerBound(const Key &key)
Find a node close to a key.
Definition: Sawyer/Map.h:488
Bidirectional iterator over values.
Definition: Sawyer/Map.h:253
boost::iterator_range< ConstValueIterator > values() const
Iterators for container values.
Definition: Sawyer/Map.h:399
ConstValueIterator & operator=(const ConstValueIterator &other)
Assignment.
Definition: Sawyer/Map.h:296
ConstKeyIterator & operator=(const ConstKeyIterator &other)
Assignment.
Definition: Sawyer/Map.h:240
const Key * operator->() const
Returns a pointer to the interval of the storage node.
Definition: Sawyer/Map.h:246
ConstKeyIterator(const NodeIterator &other)
Copy constructor.
Definition: Sawyer/Map.h:234
ConstKeyIterator(const ConstKeyIterator &other)
Copy constructor.
Definition: Sawyer/Map.h:231
ConstValueIterator(const ConstNodeIterator &other)
Copy constructor.
Definition: Sawyer/Map.h:290
Node & operator*() const
Dereference iterator to return a storage node.
Definition: Sawyer/Map.h:182
const Key & key() const
Key part of key/value node.
Definition: Sawyer/Map.h:98
Map & insertMultiple(const OtherNodeIterator &begin, const OtherNodeIterator &end)
Insert multiple values.
Definition: Sawyer/Map.h:664
Bidirectional iterator over values.
Definition: Sawyer/Map.h:278
Map & operator=(const Map< Key2, T2, Cmp2, Alloc2 > &other)
Make this map be a copy of another map.
Definition: Sawyer/Map.h:350
ConstNodeIterator(const NodeIterator &other)
Copy constructor.
Definition: Sawyer/Map.h:204
Interval< Key > hull() const
Returns the range of keys in this map.
Definition: Sawyer/Map.h:445
const Value & getOrDefault(const Key &key) const
Lookup and return a value or a default.
Definition: Sawyer/Map.h:611
const Value & value() const
Value part of key/value node.
Definition: Sawyer/Map.h:106
Map & eraseAt(const NodeIterator &iter)
Remove a node by iterator.
Definition: Sawyer/Map.h:753
boost::iterator_range< ConstKeyIterator > keys()
Iterators for container keys.
Definition: Sawyer/Map.h:382
Map & insertMaybeMultiple(const boost::iterator_range< OtherNodeIterator > &range)
Conditionally insert multiple key/value pairs.
Definition: Sawyer/Map.h:704
Map & eraseAtMultiple(const Iter &begin, const Iter &end)
Remove multiple nodes by iterator range.
Definition: Sawyer/Map.h:779
T Value
Type for values associated with each key.
Definition: Sawyer/Map.h:69
Map & erase(const Key &key)
Remove a node with specified key.
Definition: Sawyer/Map.h:726
Range of values delimited by endpoints.
Definition: Interval.h:33
Map(const Map< Key2, T2, Cmp2, Alloc2 > &other)
Copy constructor.
Definition: Sawyer/Map.h:332
Map & eraseAt(const ConstKeyIterator &iter)
Remove a node by iterator.
Definition: Sawyer/Map.h:757
NodeIterator find(const Key &key)
Find a node by key.
Definition: Sawyer/Map.h:462
ConstValueIterator(const ConstValueIterator &other)
Copy constructor.
Definition: Sawyer/Map.h:284
Map & insert(const Key &key, const Value &value)
Insert or update a key/value pair.
Definition: Sawyer/Map.h:628
Key least() const
Returns the minimum key.
Definition: Sawyer/Map.h:425
ConstKeyIterator(const ConstNodeIterator &other)
Copy constructor.
Definition: Sawyer/Map.h:237
ConstValueIterator(const ValueIterator &other)
Copy constructor.
Definition: Sawyer/Map.h:287
const Node * operator->() const
Returns a pointer to a storage node.
Definition: Sawyer/Map.h:214
Bidirectional iterator over keys.
Definition: Sawyer/Map.h:225
NodeIterator upperBound(const Key &key)
Find a node close to a key.
Definition: Sawyer/Map.h:505
Map & eraseMultiple(const boost::iterator_range< OtherKeyIterator > &range)
Remove keys stored in another Map.
Definition: Sawyer/Map.h:740
ConstValueIterator(const NodeIterator &other)
Copy constructor.
Definition: Sawyer/Map.h:293
Key greatest() const
Returns the maximum key.
Definition: Sawyer/Map.h:431
const Node & operator*() const
Dereference iterator to return a storage node.
Definition: Sawyer/Map.h:211
boost::iterator_range< NodeIterator > nodes()
Iterators for container nodes.
Definition: Sawyer/Map.h:369
K Key
Type for keys.
Definition: Sawyer/Map.h:68
size_t size() const
Number of nodes, keys, or values in this container.
Definition: Sawyer/Map.h:420
Container associating values with keys.
Definition: Sawyer/Map.h:66
const Value & operator*() const
Dereference iterator to return the value of the storage node.
Definition: Sawyer/Map.h:299
Value & insertMaybe(const Key &key, const Value &value)
Conditionally insert a new key/value pair.
Definition: Sawyer/Map.h:682
Map & eraseAtMultiple(const boost::iterator_range< Iter > &range)
Remove multiple nodes by iterator range.
Definition: Sawyer/Map.h:784
Type for stored nodes.
Definition: Sawyer/Map.h:89
Bidirectional iterator over key/value nodes.
Definition: Sawyer/Map.h:195
Value * operator->() const
Returns a pointer to the value of the storage node.
Definition: Sawyer/Map.h:271
ValueIterator(const NodeIterator &other)
Copy constructor.
Definition: Sawyer/Map.h:262