- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/GenPoly/ErasableScopedMap.h
re9b5043 rc1fb3903 5 5 // file "LICENCE" distributed with Cforall. 6 6 // 7 // ErasableScopedMap.h --7 // ScopedMap.h -- 8 8 // 9 9 // Author : Aaron B. Moss … … 51 51 typedef typename Scope::const_pointer const_pointer; 52 52 53 // Both iterator types are complete bidirection al iterators, seebelow.53 // Both iterator types are complete bidirection iterators, defined below. 54 54 class iterator; 55 55 class const_iterator; … … 118 118 std::pair< iterator, bool > insert( const Key &key, const Value &value ) { return insert( std::make_pair( key, value ) ); } 119 119 120 Value& operator[] ( const Key &key ) {121 iterator slot = find( key );122 if ( slot != end() ) return slot->second;123 return insert( key, Value() ).first->second;124 }125 126 120 /// Marks the given element as erased from this scope inward; returns 1 for erased an element, 0 otherwise 127 121 size_type erase( const Key &key ) { … … 136 130 } 137 131 138 bool contains( const Key & key ) const { 139 return find( key ) != cend(); 132 Value& operator[] ( const Key &key ) { 133 iterator slot = find( key ); 134 if ( slot != end() ) return slot->second; 135 return insert( key, Value() ).first->second; 140 136 } 141 137 };
Note:
See TracChangeset
for help on using the changeset viewer.