25 Node(
const T& value) : data(value), next(
nullptr) {}
30 mutable Node* read_position;
37 SimpleList() : head(nullptr), tail(nullptr), read_position(nullptr), size(0) {}
52 Node* new_node =
new Node(value);
54 head = tail = read_position = new_node;
56 tail->next = new_node;
69 if (read_position == temp) {
76 read_position =
nullptr;
88 T value = read_position->data;
89 read_position = read_position->next;
108 return read_position ==
nullptr;
130 read_position =
nullptr;
Iterator class for SimpleList.
const_iterator()
Construct a new const_iterator object.
const T & operator*() const
Dereference operator.
bool operator!=(const const_iterator &other) const
Inequality comparison operator.
const T * operator->() const
Arrow operator.
const_iterator operator++(int)
Postfix increment operator.
const_iterator(const Node *node)
Construct a new const_iterator object.
bool operator==(const const_iterator &other) const
Equality comparison operator.
const_iterator & operator++()
Prefix increment operator.
bool operator==(const iterator &other) const
Equality comparison operator.
iterator(Node *node)
Construct a new iterator object.
iterator()
Construct a new iterator object.
T & operator*()
Dereference operator.
bool operator!=(const iterator &other) const
Inequality comparison operator.
iterator & operator++()
Prefix increment operator.
T * operator->()
Arrow operator.
A simple linked list implementation.
void push_back(const T &value)
Add a new element to the end of the list.
size_t get_size() const
Get the number of elements in the list.
bool is_exhausted() const
Check if all elements have been read.
const_iterator cbegin() const
Get a const_iterator pointing to the beginning of the list.
void pop_front()
Remove the first element from the list.
iterator begin() const
Get an iterator pointing to the beginning of the list.
void rewind() const
Reset the read position to the beginning of the list.
~SimpleList()
Destroy the SimpleList object and free all allocated memory.
SimpleList()
Construct a new empty SimpleList object.
T read() const
Read the current element and move the read position to the next element.
void clear()
Remove all elements from the list.
const_iterator cend() const
Get a const_iterator pointing to the end of the list.
iterator end() const
Get an iterator pointing to the end of the list.