MT Core (C++)
Core library for replacing C++ standard in project usage
|
FIFO Queue (First In, First Out) Dynamically allocated, can be resized. More...
#include <queue.hpp>
Public Member Functions | |
Result< void, AllocationError > | init (Allocator &alloc, size_t capacity=10) |
Initializes Queue with capacity. | |
Result< void, AllocationError > | init (Allocator &alloc, std::initializer_list< T > init, size_t capacity=10) |
Initializes Queue with initial items. | |
void | deinit (Allocator &alloc) |
Cleans up allocated memory. | |
bool | is_full () const noexcept |
Checks if ring buffer is full. | |
bool | is_empty () const noexcept |
Checks if ring buffer is empty. | |
size_t | size () const noexcept |
size_t | capacity () const noexcept |
Result< void, AllocationError > | shrink_to_fit (Allocator &alloc) |
Optional< T > | peek () const noexcept |
Peeks at first element of Queue. | |
Optional< T > | pop () noexcept |
Removes and returns the next element in the Queue. | |
Result< void, CollectionAddNoAllocationError > | push (const T &elem) noexcept |
Tries to add an element to the Queue Fails if Queue is empty. | |
Result< void, AllocationError > | push (Allocator &alloc, const T &elem) noexcept |
Tries to add an element to the Queue Will allocate more space if needed Fails if it cannot allocate larger Queue. | |
bool | is_initialized () const noexcept |
Checks if an Queue is initialized. | |
FIFO Queue (First In, First Out) Dynamically allocated, can be resized.
Adding elements is worst case \(O(N)\), but generally \(O(1)\) Removing elements is \(O(1)\)
T | Element to store |
|
inlinenodiscardnoexcept |
|
inline |
Cleans up allocated memory.
alloc | Allocator to clean up memory with |
Definition at line 65 of file queue.hpp.
|
inline |
|
inline |
Initializes Queue with initial items.
alloc | Allocator for initial allocation |
init | Initial elements |
capacity | Initial capacity |
Definition at line 57 of file queue.hpp.
|
inlinenodiscardnoexcept |
|
inlinenodiscardnoexcept |
|
inlinenodiscardnoexcept |
|
inlinenoexcept |
Peeks at first element of Queue.
Definition at line 95 of file queue.hpp.
|
inlinenoexcept |
|
inlinenoexcept |
Tries to add an element to the Queue Will allocate more space if needed Fails if it cannot allocate larger Queue.
alloc | Allocator to use for new allocation |
elem | Element to add |
Definition at line 133 of file queue.hpp.
|
inlinenoexcept |
|
inline |
|
inlinenodiscardnoexcept |