sincerely
Singaporean
If you have not done so, read this full tutorial on how to use SGEXTN to build an application.
(no source file, everything inside header)
template ‹typename T› class SGLQueue;
part of SGEXTN module SG_Containers
queue for any type of data
list of all including inherited members
preprocessor file inclusion directive: #include ‹SGLQueue.h›
CMake target for BuildLah: SGEXTN::SG_Containers
see this link for more information about BuildLah
parent class: (none)
children classes: (none)
SGLQueue();
[[nodiscard]] const T& back() const;
[[nodiscard]] const T& front() const;
[[nodiscard]] int length() const;
void pop();
void push(const T& x);
void reserve(int newMemoryLength);
SGLQueue provides a template based queue for any data type. This is a template based class with no separate source file. This class is a SGEXTN container. Copy constructor, copy assignment, move constructor, move assignment, and destructor work as expected. A deep copy is performed whenever this class is copied, and the new instance will not be linked to the old instance in any way. It is assumed that the contents placed into this SGEXTN container can be copied and moved. This means that their copy constructor copy assignment, move constructor, move assignment, and destructor work as expected. If this is not the case or if you want the container to store references or constant references, store pointers instead.
SGLQueue internally stores a buffer in the form of a C array. When no more elements can be appended into the buffer, it resizes to double its previous size and aligns all elements to the front of the queue.
Creates an empty SGLQueue.
Returns the element at the back of the SGLQueue.
This will crash if the SGLQueue is empty.
Returns the element at the front of the SGLQueue.
This will crash if the SGLQueue is empty.
Returns the length of the SGLQueue.
Removes the front element of the SGLQueue.
This has truly constant time complexity.
This does not return the removed element. To access the removed element, use SGLQueue::front before removal.
This will crash if the SGLQueue is empty.
Appends x at the back of the SGLQueue.
This has a amortised constant time complexity. To achieve true constant time complexity, pre allocate memory equal to the amount you need using SGLQueue::reserve.
Pre allocates sufficient memory to store newMemoryLength elements in the SGLQueue.
If there is already sufficient memory to store newMemoryLength elements, this is ignored.
©2025 05524F.sg (Singapore)