A queue that ensures each element is inserted only once. More...
#include <UniqueQueue.h>
Public Member Functions | |
void | push (const T &value) |
Pushes an element to the queue if it hasn't been inserted before. | |
void | pop () |
Removes the front element from the queue. | |
const T & | front () const |
Accesses the front element of the queue. | |
bool | empty () const |
Checks whether the queue is empty. | |
void | clear () |
Clears the queue and the set of seen elements. | |
A queue that ensures each element is inserted only once.
This data structure behaves like a standard FIFO queue but prevents duplicate insertions.
Internally, it uses a std::queue
for ordering and a std::unordered_set
to track seen elements.
T | The type of elements stored in the queue. Must be hashable and comparable. |
|
inline |
Clears the queue and the set of seen elements.
|
inline |
Checks whether the queue is empty.
|
inline |
Accesses the front element of the queue.
|
inline |
Removes the front element from the queue.
|
inline |
Pushes an element to the queue if it hasn't been inserted before.
value | The element to insert. |