diff options
author | Emiel Bruijntjes <emiel.bruijntjes@copernica.com> | 2014-03-20 16:52:25 +0100 |
---|---|---|
committer | Emiel Bruijntjes <emiel.bruijntjes@copernica.com> | 2014-03-20 16:52:25 +0100 |
commit | 4bd9e7af0ab86adc09d449603158c8bc43d7103c (patch) | |
tree | 0c050b642466f8ef029a07a5b325cf3159e12232 /include | |
parent | b1f91277a29ddac92479106543ecfd62ff99d152 (diff) |
moved implementation for hashiterator to header file, introduced invaliditerator class, valueiterator now uses the hashiterator class internally
Diffstat (limited to 'include')
-rw-r--r-- | include/valueiterator.h | 59 |
1 files changed, 14 insertions, 45 deletions
diff --git a/include/valueiterator.h b/include/valueiterator.h index 62ec175..00ecc39 100644 --- a/include/valueiterator.h +++ b/include/valueiterator.h @@ -23,6 +23,11 @@ struct bucket; namespace Php { /** + * Forward declarations + */ +class IteratorImpl; + +/** * Class definition */ class ValueIterator @@ -30,10 +35,9 @@ class ValueIterator public: /** * Constructor - * @param hashtable The hashtable to iterate over - * @param first Should it start on the first position? + * @param impl Implementation iterator */ - ValueIterator(struct _hashtable *hashtable, bool first); + ValueIterator(IteratorImpl *impl) : _impl(impl) {} /** * Copy constructor @@ -95,69 +99,34 @@ public: * @param that * @return bool */ - bool operator==(const ValueIterator &that) const - { - return _position == that._position; - } + bool operator==(const ValueIterator &that) const; /** * Compare with other iterator * @param that * @return bool */ - bool operator!=(const ValueIterator &that) const - { - return _position != that._position; - } + bool operator!=(const ValueIterator &that) const; /** * Derefecence, this returns a std::pair with the current key and value * @return std::pair */ - const std::pair<Value,Value> &operator*() const - { - return _current; - } + const std::pair<Value,Value> &operator*() const; /** * Dereference, this returns a std::pair with the current key and value * @return std::pair */ - const std::pair<Value,Value> *operator->() const - { - return &_current; - } + const std::pair<Value,Value> *operator->() const; private: /** - * The hash table over which is being iterated - * @var HashTable - */ - struct _hashtable *_table = nullptr; - - /** - * The position in the hash table - * @var HashPosition - */ - struct bucket *_position = nullptr; - - /** - * The current key and value - * @var std::pair - */ - std::pair<Value,Value> _current; - - /** - * Read current key and value - * @return bool + * Pointer to the actual implementation + * @var std::unique_ptr */ - bool read(); + std::unique_ptr<IteratorImpl> _impl; - /** - * Invalidate the iterator - * @return bool - */ - bool invalidate(); }; /** |