SyntaxTutor
Educational app designed to help compiler students understand LL(1) and SLR(1) parsing algorithms.
 
Loading...
Searching...
No Matches
UniqueQueue< T > Class Template Reference

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.
 

Detailed Description

template<typename T>
class UniqueQueue< T >

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.

Template Parameters
TThe type of elements stored in the queue. Must be hashable and comparable.

Member Function Documentation

◆ clear()

template<typename T>
void UniqueQueue< T >::clear ( )
inline

Clears the queue and the set of seen elements.

◆ empty()

template<typename T>
bool UniqueQueue< T >::empty ( ) const
inline

Checks whether the queue is empty.

Returns
true if the queue is empty; false otherwise.

◆ front()

template<typename T>
const T & UniqueQueue< T >::front ( ) const
inline

Accesses the front element of the queue.

Returns
A reference to the front element.

◆ pop()

template<typename T>
void UniqueQueue< T >::pop ( )
inline

Removes the front element from the queue.

◆ push()

template<typename T>
void UniqueQueue< T >::push ( const T & value)
inline

Pushes an element to the queue if it hasn't been inserted before.

Parameters
valueThe element to insert.

The documentation for this class was generated from the following file: