10#ifndef SEMF_UTILS_CORE_QUEUES_LINKEDQUEUE_H_
11#define SEMF_UTILS_CORE_QUEUES_LINKEDQUEUE_H_
78 return queue.
end() != std::find_if(queue.
begin(), queue.
end(), [&me](T& node) { return &node == me; });
137 m_node = m_node->LinkedQueue::Node::next();
149 m_node = m_node->LinkedQueue::Node::next();
160 return m_node == other.m_node;
170 return m_node != other.m_node;
204 : m_node(iterator.m_node)
237 m_node = m_node->LinkedQueue::Node::next();
249 m_node = m_node->LinkedQueue::Node::next();
260 return m_node == other.m_node;
270 return m_node != other.m_node;
275 const T* m_node =
nullptr;
355 ConstIterator
end()
const;
403 T* m_front =
nullptr;
485 element.LinkedQueue::Node::setNext(
nullptr);
488 m_back->LinkedQueue::Node::setNext(&element);
491 else if (m_size == 1)
493 m_front->LinkedQueue::Node::setNext(&element);
515 m_front = m_front->LinkedQueue::Node::next();
523 this->m_front = queue.m_front;
524 this->m_back = queue.m_back;
525 this->m_size = queue.m_size;
Implementation of a forward constant iterator for LinkedQueue.
std::forward_iterator_tag iterator_category
const T & operator*() const
Returns the reference of the element the iterator's position.
ConstIterator operator++(int)
Iterates to the next element in the queue.
bool operator!=(const ConstIterator &other) const
Compares this element with that element.
std::ptrdiff_t difference_type
ConstIterator(const T *element)
Constructor with member variable initialization.
bool operator==(const ConstIterator &other) const
Compares this element with that element.
const T * operator->() const
Returns the pointer into the element the iterator's position.
ConstIterator(const Iterator &iterator)
Copy constructor.
virtual ~ConstIterator()=default
ConstIterator & operator++()
Iterates to the next element in the queue.
Implementation of a forward iterator for LinkedQueue.
bool operator!=(const Iterator &other) const
Compares this element with that element.
std::forward_iterator_tag iterator_category
bool operator==(const Iterator &other) const
Compares this element with that element.
Iterator & operator++()
Iterates to the next element in the list.
std::ptrdiff_t difference_type
Iterator(T *element)
Constructor with member variable initialization.
Iterator operator++(int)
Iterates to the next element in the queue.
virtual ~Iterator()=default
T & operator*() const
Returns the reference of the element the iterator's position.
T * operator->() const
Returns the pointer into the element the iterator's position.
Implements the next() functionality for every element in a queue.
T * next() const
Returns a pointer to the next element in a queue.
void setNext(T *next)
Sets a pointer to the next element in a list.
bool isInQueue(LinkedQueue &queue)
Returns if a node is part of this LinkedQueue.
LinkedQueue is an managed single linked queue implementation.
void push(T &element)
Adds a new element to the end of the queue, after its current last element.
T & front()
Returns a reference to the first element in the queue.
const T & front() const
Returns a reference to the first element in the queue.
const T & back() const
Returns a reference to the last element in the queue.
bool empty() const
Returns whether the queue is empty (i.e. whether its size is 0).
ConstIterator cbegin() const
Returns an iterator pointing to the first element in the queue.
LinkedQueue< T > & operator=(const LinkedQueue< T > &queue)
Assigns new contents to the queue, replacing its current contents, and modifying its size accordingly...
ConstIterator cend() const
Returns an iterator referring to the past-the-end element in the queue.
Iterator end()
Returns an iterator referring to the past-the-end element in the queue.
size_t size() const
Returns the number of elements in the queue.
void pop()
Removes the first element in the queue, effectively reducing the queue size by one.
Iterator begin()
Returns an iterator pointing to the first element in the queue.
ConstIterator begin() const
Returns an iterator pointing to the first element in the queue.
T & back()
Returns a reference to the last element in the queue.
ConstIterator end() const
Returns an iterator referring to the past-the-end element in the queue.