diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2018-01-08 22:29:03 +0100 |
---|---|---|
committer | Henning Baldersheim <balder@yahoo-inc.com> | 2018-01-08 22:29:03 +0100 |
commit | b4cd09c8fcd0a018580a99cf9a2b07a64312b00a (patch) | |
tree | aacb77c2fdf92f7686d89dded5517de83e1d87aa /vespalib | |
parent | 77ad6aa02a73f0b5720b5c2c816cc697ba733aa0 (diff) |
Place end() right after last element.
Diffstat (limited to 'vespalib')
-rw-r--r-- | vespalib/src/vespa/vespalib/stllike/hashtable.h | 10 |
1 files changed, 2 insertions, 8 deletions
diff --git a/vespalib/src/vespa/vespalib/stllike/hashtable.h b/vespalib/src/vespa/vespalib/stllike/hashtable.h index 16d9cde1f78..6e3c753836e 100644 --- a/vespalib/src/vespa/vespalib/stllike/hashtable.h +++ b/vespalib/src/vespa/vespalib/stllike/hashtable.h @@ -147,7 +147,7 @@ public: } } iterator(hashtable * hash, next_t pos) : _current(pos), _hashTable(hash) { } - static iterator end(hashtable *hash) { return iterator(hash, Node::npos); } + static iterator end(hashtable *hash) { return iterator(hash, hash->initializedSize()); } Value & operator * () const { return _hashTable->get(_current); } Value * operator -> () const { return & _hashTable->get(_current); } @@ -168,9 +168,6 @@ public: private: void advanceToNextValidHash() { for (_current++;(_current < _hashTable->initializedSize()) && ! _hashTable->_nodes[_current].valid(); _current++) { } - if (_current >= _hashTable->initializedSize()) { - _current = Node::npos; - } } next_t _current; hashtable * _hashTable; @@ -192,7 +189,7 @@ public: } const_iterator(const hashtable * hash, next_t pos) : _current(pos), _hashTable(hash) { } const_iterator(const iterator &i) : _current(i._current), _hashTable(i._hashTable) {} - static const_iterator end(const hashtable *hash) { return const_iterator(hash, Node::npos); } + static const_iterator end(const hashtable *hash) { return const_iterator(hash, hash->initializedSize()); } const Value & operator * () const { return _hashTable->get(_current); } const Value * operator -> () const { return & _hashTable->get(_current); } @@ -211,9 +208,6 @@ public: private: void advanceToNextValidHash() { for (_current++;(_current < _hashTable->initializedSize()) && ! _hashTable->_nodes[_current].valid(); _current++) { } - if (_current >= _hashTable->initializedSize()) { - _current = Node::npos; - } } next_t _current; const hashtable * _hashTable; |