WIP: somethings wrong.. #19
@ -16,8 +16,13 @@ public:
|
|||||||
class Iterator {
|
class Iterator {
|
||||||
public:
|
public:
|
||||||
LinkedElement<T> *value = nullptr;
|
LinkedElement<T> *value = nullptr;
|
||||||
|
//! Creates an uninitialized iterator which points to nullptr.
|
||||||
Iterator() {}
|
Iterator() {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initialize iterator at specified linked element.
|
||||||
|
* @param element
|
||||||
|
*/
|
||||||
Iterator(LinkedElement<T> *element) :
|
Iterator(LinkedElement<T> *element) :
|
||||||
value(element) {
|
value(element) {
|
||||||
}
|
}
|
||||||
@ -72,6 +77,11 @@ private:
|
|||||||
LinkedElement *next;
|
LinkedElement *next;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief SinglyLinkedList data structure which keeps a pointer to its
|
||||||
|
* first element to perform all operations.
|
||||||
|
* @tparam T
|
||||||
|
*/
|
||||||
template<typename T>
|
template<typename T>
|
||||||
class SinglyLinkedList {
|
class SinglyLinkedList {
|
||||||
public:
|
public:
|
||||||
@ -90,7 +100,11 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
ElementIterator end() const {
|
ElementIterator end() const {
|
||||||
return ElementIterator::Iterator();
|
LinkedElement<T> *element = start;
|
||||||
|
while (element != nullptr) {
|
||||||
|
element = element->getNext();
|
||||||
|
}
|
||||||
|
return ElementIterator::Iterator(element);
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t getSize() const {
|
size_t getSize() const {
|
||||||
|
Loading…
Reference in New Issue
Block a user