src/work/alpar/smart_graph.h
changeset 221 d8a67c5b26d1
parent 209 9a37b8d02d74
child 242 b255f25ad394
equal deleted inserted replaced
15:0cd2515d15fb 16:40861597545f
   369       void add(const Node k) 
   369       void add(const Node k) 
   370       {
   370       {
   371 	if(k.n>=int(container.size())) container.resize(k.n+1);
   371 	if(k.n>=int(container.size())) container.resize(k.n+1);
   372       }
   372       }
   373 
   373 
   374       void erase(const Node k) { }
   374       void erase(const Node) { }
   375       
   375       
   376       void set(Node n, T a) { container[n.n]=a; }
   376       void set(Node n, T a) { container[n.n]=a; }
   377       //T get(Node n) const { return container[n.n]; }
   377       //T get(Node n) const { return container[n.n]; }
   378       T& operator[](Node n) { return container[n.n]; }
   378       //Hajjaj:
   379       const T& operator[](Node n) const { return container[n.n]; }
   379       //T& operator[](Node n) { return container[n.n]; }
       
   380       typename std::vector<T>::reference
       
   381       operator[](Node n) { return container[n.n]; }
       
   382       //const T& operator[](Node n) const { return container[n.n]; }
       
   383       typename std::vector<T>::const_reference 
       
   384       operator[](Node n) const { return container[n.n]; }
   380 
   385 
   381       ///\warning There is no safety check at all!
   386       ///\warning There is no safety check at all!
   382       ///Using operator = between maps attached to different graph may
   387       ///Using operator = between maps attached to different graph may
   383       ///cause serious problem.
   388       ///cause serious problem.
   384       ///\todo Is this really so?
   389       ///\todo Is this really so?
   456       
   461       
   457       void add(const Edge k) 
   462       void add(const Edge k) 
   458       {
   463       {
   459 	if(k.n>=int(container.size())) container.resize(k.n+1);
   464 	if(k.n>=int(container.size())) container.resize(k.n+1);
   460       }
   465       }
   461       void erase(const Edge k) { }
   466       void erase(const Edge) { }
   462       
   467       
   463       void set(Edge n, T a) { container[n.n]=a; }
   468       void set(Edge n, T a) { container[n.n]=a; }
   464       //T get(Edge n) const { return container[n.n]; }
   469       //T get(Edge n) const { return container[n.n]; }
   465       T& operator[](Edge n) { return container[n.n]; }
   470       typename std::vector<T>::reference
   466       const T& operator[](Edge n) const { return container[n.n]; }
   471       operator[](Edge n) { return container[n.n]; }
       
   472       typename std::vector<T>::const_reference
       
   473       operator[](Edge n) const { return container[n.n]; }
   467 
   474 
   468       ///\warning There is no safety check at all!
   475       ///\warning There is no safety check at all!
   469       ///Using operator = between maps attached to different graph may
   476       ///Using operator = between maps attached to different graph may
   470       ///cause serious problem.
   477       ///cause serious problem.
   471       ///\todo Is this really so?
   478       ///\todo Is this really so?
   602       }
   609       }
   603       void erase(const Edge k) { }
   610       void erase(const Edge k) { }
   604       
   611       
   605       void set(Edge n, T a) { container[n.idref()/2]=a; }
   612       void set(Edge n, T a) { container[n.idref()/2]=a; }
   606       //T get(Edge n) const { return container[n.idref()/2]; }
   613       //T get(Edge n) const { return container[n.idref()/2]; }
   607       T& operator[](Edge n) { return container[n.idref()/2]; }
   614       typename std::vector<T>::reference
   608       const T& operator[](Edge n) const { return container[n.idref()/2]; }
   615       operator[](Edge n) { return container[n.idref()/2]; }
       
   616       typename std::vector<T>::const_reference
       
   617       operator[](Edge n) const { return container[n.idref()/2]; }
   609 
   618 
   610       ///\warning There is no safety check at all!
   619       ///\warning There is no safety check at all!
   611       ///Using operator = between maps attached to different graph may
   620       ///Using operator = between maps attached to different graph may
   612       ///cause serious problem.
   621       ///cause serious problem.
   613       ///\todo Is this really so?
   622       ///\todo Is this really so?