11#include <Sawyer/Map.h> 
   12#include <Sawyer/Sawyer.h> 
   13#include <boost/foreach.hpp> 
   25template<
class S, 
class T>
 
   51        BOOST_FOREACH (
const typename Forward::Node &anode, a.forward_.
nodes()) {
 
   52            if (b.forward_.
exists(anode.value())) {
 
   53                const Target &target = b.forward_[anode.value()];
 
   54                forward_.
insert(anode.key(), target);
 
   55                reverse_.
insert(target, anode.key());
 
 
   73        if (!forward_.
exists(source))
 
   75        reverse_.
erase(forward_[source]);
 
   76        forward_.
erase(source);
 
 
   85        if (!reverse_.
exists(target))
 
   87        forward_.
erase(reverse_[target]);
 
   88        reverse_.
erase(target);
 
 
   98        if (!forward_.
exists(source) || forward_[source]!=target)
 
  100        forward_.
erase(source);
 
  101        reverse_.
erase(target);
 
 
  113        forward_.
insert(source, target);
 
  114        reverse_.
insert(target, source);
 
 
 
One-to-one mapping between source and target values.
 
Sawyer::Container::Map< Target, Source > Reverse
Type for range-to-domain map.
 
BiMap(const BiMap< Source, U > &a, const BiMap< U, Target > &b)
Construct a new map by composition of two maps.
 
Sawyer::Container::Map< Source, Target > Forward
Type for domain-to-range map.
 
T Target
Type of values in the range.
 
BiMap()
Default constructor.
 
bool eraseSource(const Source &source)
Erase domain value and its associated range value.
 
void clear()
Erase all mappings.
 
S Source
Type of values in the domain.
 
bool eraseTarget(const Target &target)
Erase range value and its associated domain value.
 
const Reverse & reverse() const
Return reverse mapping.
 
BiMap(const BiMap &other)
Copy constructor.
 
void insert(const Source &source, const Target &target)
Insert a new mapping.
 
bool erase(const Source &source, const Target &target)
Erase a specific map entry.
 
const Forward & forward() const
Return forward mapping.
 
Container associating values with keys.
 
bool exists(const Key &key) const
Determine if a key exists.
 
Map & erase(const Key &key)
Remove a node with specified key.
 
boost::iterator_range< NodeIterator > nodes()
Iterators for container nodes.
 
Map & insert(const Key &key, const Value &value)
Insert or update a key/value pair.
 
Map & clear()
Remove all nodes.