hybrid iterator fix and improvement

This commit is contained in:
Robin Müller 2020-06-17 20:57:35 +02:00
parent 454524d213
commit 0c45522540

View File

@ -8,13 +8,11 @@ template<typename T, typename count_t = uint8_t>
class HybridIterator: public LinkedElement<T>::Iterator, class HybridIterator: public LinkedElement<T>::Iterator,
public ArrayList<T, count_t>::Iterator { public ArrayList<T, count_t>::Iterator {
public: public:
HybridIterator() : HybridIterator() {}
value(NULL), linked(NULL), end(NULL) {
}
HybridIterator(typename LinkedElement<T>::Iterator *iter) : HybridIterator(typename LinkedElement<T>::Iterator *iter) :
LinkedElement<T>::Iterator(*iter), value( LinkedElement<T>::Iterator(*iter), value(iter->value),
iter->value), linked(true), end(NULL) { linked(true) {
} }
@ -66,11 +64,11 @@ public:
return tmp; return tmp;
} }
bool operator==(HybridIterator other) { bool operator==(const HybridIterator& other) {
return value == other->value; return value == other.value;
} }
bool operator!=(HybridIterator other) { bool operator!=(const HybridIterator& other) {
return !(*this == other); return !(*this == other);
} }
@ -82,11 +80,11 @@ public:
return value; return value;
} }
T* value; T* value = nullptr;
private: private:
bool linked; bool linked = false;
T *end; T *end = nullptr;
}; };
#endif /* HYBRIDITERATOR_H_ */ #endif /* HYBRIDITERATOR_H_ */