Changes in src/GenPoly/ScopedMap.h [46f6134:f6d4204]
- File:
-
- 1 edited
-
src/GenPoly/ScopedMap.h (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/GenPoly/ScopedMap.h
r46f6134 rf6d4204 42 42 typedef typename Scope::pointer pointer; 43 43 typedef typename Scope::const_pointer const_pointer; 44 44 45 45 class iterator : public std::iterator< std::bidirectional_iterator_tag, 46 46 value_type > { … … 68 68 } 69 69 70 iterator(scope_list &_scopes, const wrapped_iterator &_it, size_type _i)70 iterator(scope_list const &_scopes, const wrapped_iterator &_it, size_type _i) 71 71 : scopes(&_scopes), it(_it), i(_i) {} 72 72 public: … … 76 76 return *this; 77 77 } 78 78 79 79 reference operator* () { return *it; } 80 80 pointer operator-> () { return it.operator->(); } … … 109 109 110 110 private: 111 scope_list *scopes;111 scope_list const *scopes; 112 112 wrapped_iterator it; 113 113 size_type i; … … 189 189 size_type i; 190 190 }; 191 191 192 192 /// Starts a new scope 193 193 void beginScope() { 194 scopes.emplace_back(); 194 Scope scope; 195 scopes.push_back(scope); 195 196 } 196 197 … … 226 227 return const_iterator( const_cast< ScopedMap< Key, Value >* >(this)->find( key ) ); 227 228 } 228 229 229 230 /// Finds the given key in the outermost scope inside the given scope where it occurs 230 231 iterator findNext( const_iterator &it, const Key &key ) { … … 246 247 return std::make_pair( iterator(scopes, res.first, scopes.size()-1), res.second ); 247 248 } 248 249 std::pair< iterator, bool > insert( value_type &&value ) {250 std::pair< typename Scope::iterator, bool > res = scopes.back().insert( std::move( value ) );251 return std::make_pair( iterator(scopes, std::move( res.first ), scopes.size()-1), std::move( res.second ) );252 }253 254 249 std::pair< iterator, bool > insert( const Key &key, const Value &value ) { return insert( std::make_pair( key, value ) ); } 255 std::pair< iterator, bool > insert( const Key &key, Value &&value ) { return insert( std::make_pair( key, std::move( value ) ) ); }256 250 257 251 Value& operator[] ( const Key &key ) { … … 260 254 return insert( key, Value() ).first->second; 261 255 } 262 263 iterator erase( iterator pos ) {264 Scope& scope = (*pos.scopes) [ pos.i ];265 const typename iterator::wrapped_iterator& new_it = scope.erase( pos.it );266 iterator it( *pos.scopes, new_it, pos.i );267 return it.next_valid();268 }269 270 size_type count( const Key &key ) const {271 size_type c = 0;272 auto it = find( key );273 auto end = cend();274 275 while(it != end) {276 c++;277 it = findNext(it, key);278 }279 280 return c;281 }282 283 256 }; 284 257 } // namespace GenPoly
Note:
See TracChangeset
for help on using the changeset viewer.