|
| | Queue ()=default |
| | Queue (const Queue &)=default |
| | Queue (Queue &&other) noexcept |
| | Takes other's elements, leaving it empty.
|
| T * | begin () |
| const T * | begin () const |
| void | clear () |
| T * | end () |
| const T * | end () const |
| T & | front () |
| | Front element without removing it; throws if empty.
|
| const T & | front () const |
| List< T > | GetData () |
| | Copies out the queued elements, front-to-back.
|
| bool | isEmpty () const |
| Queue & | operator= (const Queue &)=default |
| Queue & | operator= (Queue &&other) noexcept |
| | Replaces this queue with other's elements, leaving other empty.
|
| T | pop () |
| | Removes and returns the front element; throws if empty.
|
| void | push (const T &value) |
| | Adds value to the back of the queue.
|
| void | push (T &&value) |
| | Moves value onto the back of the queue.
|
| const void | reverse () |
| | Reverses the queue's element order in place.
|
| size_t | size () const |
template<typename T>
class Sleak::Queue< T >
Implements a FIFO (First-In, First-Out) queue data structure.
The Queue class maintains a collection of elements in the order they were added. It is suitable for scenarios where you need to process elements in a first-come, first-served manner. Use this class when you need to implement task queues, message queues, or breadth-first search algorithms.
Example Use Cases:
- Implementing a task queue for background processing.
- Managing message queues in a network communication system.
- Performing breadth-first search in graph algorithms.
- Simulating real-world queues, such as waiting lines.
Implementation Details:
- Uses an underlying List plus a head index; pop is amortized O(1).
- Provides methods for enqueueing (adding) and dequeueing (removing) elements.
- Maintains the FIFO order of elements.
Definition at line 36 of file Queue.hpp.