hybrid iter update

This commit is contained in:
Robin Müller 2020-06-26 13:28:58 +02:00
parent 08f25370f3
commit ba5b8bd682

View File

@ -1,5 +1,5 @@
#ifndef HYBRIDITERATOR_H_
#define HYBRIDITERATOR_H_
#ifndef FRAMEWORK_CONTAINER_HYBRIDITERATOR_H_
#define FRAMEWORK_CONTAINER_HYBRIDITERATOR_H_
#include <framework/container/ArrayList.h>
#include <framework/container/SinglyLinkedList.h>
@ -17,23 +17,23 @@ public:
}
HybridIterator(LinkedElement<T> *start) :
LinkedElement<T>::Iterator(start), value(
start->value), linked(true), end(NULL) {
LinkedElement<T>::Iterator(start), value(start->value),
linked(true) {
}
HybridIterator(typename ArrayList<T, count_t>::Iterator start,
typename ArrayList<T, count_t>::Iterator end) :
ArrayList<T, count_t>::Iterator(start), value(start.value), linked(
false), end(end.value) {
ArrayList<T, count_t>::Iterator(start), value(start.value),
linked(false), end(end.value) {
if (value == this->end) {
value = NULL;
}
}
HybridIterator(T *firstElement, T *lastElement) :
ArrayList<T, count_t>::Iterator(firstElement), value(firstElement), linked(
false), end(++lastElement) {
ArrayList<T, count_t>::Iterator(firstElement), value(firstElement),
linked(false), end(++lastElement) {
if (value == end) {
value = NULL;
}
@ -42,17 +42,17 @@ public:
HybridIterator& operator++() {
if (linked) {
LinkedElement<T>::Iterator::operator++();
if (LinkedElement<T>::Iterator::value != NULL) {
if (LinkedElement<T>::Iterator::value != nullptr) {
value = LinkedElement<T>::Iterator::value->value;
} else {
value = NULL;
value = nullptr;
}
} else {
ArrayList<T, count_t>::Iterator::operator++();
value = ArrayList<T, count_t>::Iterator::value;
if (value == end) {
value = NULL;
value = nullptr;
}
}
return *this;
@ -64,11 +64,11 @@ public:
return tmp;
}
bool operator==(const HybridIterator& other) {
bool operator==(const HybridIterator& other) const {
return value == other.value;
}
bool operator!=(const HybridIterator& other) {
bool operator!=(const HybridIterator& other) const {
return !(*this == other);
}
@ -87,4 +87,4 @@ private:
T *end = nullptr;
};
#endif /* HYBRIDITERATOR_H_ */
#endif /* FRAMEWORK_CONTAINER_HYBRIDITERATOR_H_ */