Reserve is resolved.
7 ///\brief Graph maps that construates and destruates
8 ///their elements dynamically.
12 /// \addtogroup graphmaps
15 /** The SymEdgeIt is wrapper class for the EdgeIt. It can be used to
16 * iterate on the symmetric maps when all of the edge - reverse edge pair
17 * has different parity.
20 template <typename Graph, typename Edge, typename EdgeIt>
21 class SymEdgeIt : public EdgeIt {
24 /** Default constructor.
29 /** Graph initialized constructor.
31 SymEdgeIt(const Graph& graph)
33 while ( (n & 1) && n != -1) {
38 /** Creating invelid SymEdgeIt.
40 SymEdgeIt(Invalid invalid)
43 /** SymEdgeIt from the given Edge.
45 SymEdgeIt(const Graph& graph, const Edge& edge)
46 : EdgeIt(graph, edge) {
47 while ( (n & 1) && n != -1) {
52 /** Increase operator.
54 SymEdgeIt& operator++() {
56 while ( (n & 1) && n != -1) {
63 /** The SymMap template class is graph map structure what
64 * wraps an other map structure to use as symmetric map structure.
66 * The template parameter is the MapRegistry that the maps
67 * will belong to and the ValueType.
69 template <template <typename, typename> class DynMap,
70 typename MapRegistry, typename Value>
71 class SymMap : public DynMap<MapRegistry, Value>{
75 typedef DynMap<MapRegistry, Value> MapImpl;
79 /// The graph type of the maps.
80 typedef typename MapRegistry::Graph Graph;
82 typedef typename MapImpl::KeyType KeyType;
87 /** Default constructor for the map.
89 SymMap() : MapImpl() {}
91 /** Graph and Registry initialized map constructor.
93 SymMap(const Graph& g, MapRegistry& r) : MapImpl(g, r) {}
95 /** Constructor to use default value to initialize the map.
97 SymMap(const Graph& g, MapRegistry& r, const Value& v)
100 /** Constructor to copy a map of the same map type.
102 SymMap(const SymMap& copy)
103 : MapImpl(static_cast<const MapImpl&>(copy)) {}
105 /** Constructor to copy a map of an other map type.
107 template <typename CMap> SymMap(const CMap& copy)
110 /** Assign operator to copy a map of the same map type.
112 SymMap& operator=(const SymMap& copy) {
113 MapImpl::operator=(static_cast<const MapImpl&>(copy));
117 /** Assign operator to copy a map of an other map type.
119 template <typename CMap> SymMap& operator=(const CMap& copy) {
120 MapImpl::operator=(copy);
125 * The subscript operator. The map can be subscripted by the
126 * actual keys of the graph.
128 typename MapImpl::ReferenceType operator[](const KeyType& key) {
129 int id = MapImpl::getGraph()->id(key);
130 return MapImpl::operator[](id >> 1);
134 * The const subscript operator. The map can be subscripted by the
135 * actual keys of the graph.
137 typename MapImpl::ConstReferenceType operator[](const KeyType& key) const {
138 int id = MapImpl::getGraph()->id(key);
139 return MapImpl::operator[](id >> 1);
142 /** Setter function of the map. Equivalent with map[key] = val.
143 * This is a compatibility feature with the not dereferable maps.
145 void set(const KeyType& key, const typename MapImpl::ValueType& val) {
146 int id = MapImpl::getGraph()->id(key);
147 MapImpl::operator[](id >> 1) = val;
150 /** Add a new key to the map. It called by the map registry.
152 void add(const KeyType& key) {
153 int id = MapImpl::getGraph()->id(key);
158 /** Erase a key from the map. It called by the map registry.
160 void erase(const KeyType& key) {
161 int id = MapImpl::getGraph()->id(key);