Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/GenPoly/ScopedMap.h

    r46f6134 rf6d4204  
    4242                typedef typename Scope::pointer pointer;
    4343                typedef typename Scope::const_pointer const_pointer;
    44 
     44               
    4545                class iterator : public std::iterator< std::bidirectional_iterator_tag,
    4646                                                       value_type > {
     
    6868                        }
    6969
    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)
    7171                                : scopes(&_scopes), it(_it), i(_i) {}
    7272                public:
     
    7676                                return *this;
    7777                        }
    78 
     78                       
    7979                        reference operator* () { return *it; }
    8080                        pointer operator-> () { return it.operator->(); }
     
    109109
    110110                private:
    111                         scope_list *scopes;
     111                        scope_list const *scopes;
    112112                        wrapped_iterator it;
    113113                        size_type i;
     
    189189                        size_type i;
    190190                };
    191 
     191               
    192192                /// Starts a new scope
    193193                void beginScope() {
    194                         scopes.emplace_back();
     194                        Scope scope;
     195                        scopes.push_back(scope);
    195196                }
    196197
     
    226227                                return const_iterator( const_cast< ScopedMap< Key, Value >* >(this)->find( key ) );
    227228                }
    228 
     229               
    229230                /// Finds the given key in the outermost scope inside the given scope where it occurs
    230231                iterator findNext( const_iterator &it, const Key &key ) {
     
    246247                        return std::make_pair( iterator(scopes, res.first, scopes.size()-1), res.second );
    247248                }
    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 
    254249                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 ) ) ); }
    256250
    257251                Value& operator[] ( const Key &key ) {
     
    260254                        return insert( key, Value() ).first->second;
    261255                }
    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 
    283256        };
    284257} // namespace GenPoly
Note: See TracChangeset for help on using the changeset viewer.