2 #ifndef SYM_MAP_FACTORY_H
3 #define SYM_MAP_FACTORY_H
7 template <typename Graph, typename Edge, typename EdgeIt>
8 class SymEdgeIt : public EdgeIt {
14 SymEdgeIt(const Graph& graph)
16 while ( n != -1 && (n & 1)) {
21 SymEdgeIt(Invalid invalid)
24 SymEdgeIt(const Graph& graph, Edge edge)
25 : EdgeIt(graph, edge) {}
27 SymEdgeIt& operator++() {
29 while ( n != -1 && (n & 1)) {
36 template <typename MapRegistry, template <typename> class MapFactory>
41 typedef typename MapRegistry::Graph Graph;
42 typedef typename MapRegistry::KeyType KeyType;
43 typedef typename MapRegistry::KeyIt KeyIt;
45 typedef typename MapRegistry::MapBase MapBase;
48 class Map : public MapFactory<MapRegistry>::template Map<V> {
50 typedef typename MapFactory<MapRegistry>::template Map<V> MapImpl;
57 Map(const Graph& g, MapRegistry& r) : MapImpl(g, r) {}
59 Map(const Graph& g, MapRegistry& r, const Value& v)
62 Map(const Map& copy) : MapImpl(static_cast<const MapImpl&>(copy)) {}
64 template <typename CMap> Map(const CMap& copy) : MapImpl(copy) {}
66 Map& operator=(const Map& copy) {
67 MapImpl::operator=(static_cast<const MapImpl&>(copy));
71 template <typename CMap> Map& operator=(const CMap& copy) {
72 MapImpl::operator=(copy);
76 Value& operator[](const KeyType& key) {
77 int id = MapBase::getGraph()->id(key);
78 return MapImpl::operator[](id >> 1);
81 const Value& operator[](const KeyType& key) const {
82 int id = MapBase::getGraph()->id(key);
83 return MapImpl::operator[](id >> 1);
86 const Value& get(const KeyType& key) const {
87 int id = MapBase::getGraph()->id(key);
88 return MapImpl::operator[](id >> 1);
91 void set(const KeyType& key, const Value& val) {
92 int id = MapBase::getGraph()->id(key);
93 MapImpl::operator[](id >> 1) = val;
96 void add(const KeyType& key) {
97 int id = MapBase::getGraph()->id(key);
102 void erase(const KeyType& key) {
103 int id = MapBase::getGraph()->id(key);