src/hugo/sym_map_factory.h
changeset 792 147eb3a58706
parent 782 df2e45e09652
child 798 6d1abeb62dd3
equal deleted inserted replaced
0:329cde76736c 1:9e752d6b1595
    33   class SymMapFactory {
    33   class SymMapFactory {
    34 
    34 
    35   public:
    35   public:
    36 		
    36 		
    37     typedef typename MapRegistry::Graph Graph;
    37     typedef typename MapRegistry::Graph Graph;
    38     typedef typename MapRegistry::Key Key;
    38     typedef typename MapRegistry::KeyType KeyType;
    39     typedef typename MapRegistry::KeyIt KeyIt;
    39     typedef typename MapRegistry::KeyIt KeyIt;
    40 
    40 
    41     typedef typename MapRegistry::MapBase MapBase;
    41     typedef typename MapRegistry::MapBase MapBase;
    42 
    42 
    43     template <typename V>
    43     template <typename V>
    66       template <typename CMap> Map& operator=(const CMap& copy) {
    66       template <typename CMap> Map& operator=(const CMap& copy) {
    67 	MapImpl::operator=(copy);
    67 	MapImpl::operator=(copy);
    68 	return *this;
    68 	return *this;
    69       }
    69       }
    70    
    70    
    71       Value& operator[](const Key& key) {
    71       Value& operator[](const KeyType& key) {
    72 	int id = MapBase::getGraph()->id(key);	
    72 	int id = MapBase::getGraph()->id(key);	
    73 	return MapImpl::operator[](id >> 1);
    73 	return MapImpl::operator[](id >> 1);
    74       } 
    74       } 
    75 		
    75 		
    76       const Value& operator[](const Key& key) const {
    76       const Value& operator[](const KeyType& key) const {
    77 	int id = MapBase::getGraph()->id(key);
    77 	int id = MapBase::getGraph()->id(key);
    78 	return MapImpl::operator[](id >> 1);
    78 	return MapImpl::operator[](id >> 1);
    79       }
    79       }
    80 	
    80 	
    81       const Value& get(const Key& key) const {
    81       const Value& get(const KeyType& key) const {
    82 	int id = MapBase::getGraph()->id(key);
    82 	int id = MapBase::getGraph()->id(key);
    83 	return MapImpl::operator[](id >> 1);
    83 	return MapImpl::operator[](id >> 1);
    84       } 
    84       } 
    85 		
    85 		
    86       void set(const Key& key, const Value& val) {
    86       void set(const KeyType& key, const Value& val) {
    87 	int id = MapBase::getGraph()->id(key);
    87 	int id = MapBase::getGraph()->id(key);
    88 	MapImpl::operator[](id >> 1) = val;
    88 	MapImpl::operator[](id >> 1) = val;
    89       }
    89       }
    90 		
    90 		
    91       void add(const Key& key) {
    91       void add(const KeyType& key) {
    92 	int id = MapBase::getGraph()->id(key);
    92 	int id = MapBase::getGraph()->id(key);
    93 	if (id & 1) return;
    93 	if (id & 1) return;
    94 	MapImpl::add(key);
    94 	MapImpl::add(key);
    95       }
    95       }
    96 		
    96 		
    97       void erase(const Key& key) {
    97       void erase(const KeyType& key) {
    98 	int id = MapBase::getGraph()->id(key);
    98 	int id = MapBase::getGraph()->id(key);
    99 	if (id & 1) return;
    99 	if (id & 1) return;
   100 	MapImpl::add(key);
   100 	MapImpl::add(key);
   101       }
   101       }
   102 
   102