ORIGINAL
|
Dynamic array container with amortized constant time operations. More...
#include <vector.h>
Classes | |
class | Iterator |
Random access iterator implementation for vector. More... | |
Public Member Functions | |
vector (ALLOC alloc=ALLOC{}) | |
Constructs a vector with specified allocator. | |
template<typename... ARGS> | |
vector (u_integer size, ALLOC alloc, ARGS &&... args) | |
Constructs a vector with specified size and allocator, initializing elements with provided arguments. | |
vector (const vector &other) | |
Copy constructor for the vector. | |
vector (const std::initializer_list< TYPE > &list) | |
Constructs a vector from an initializer list. | |
vector (const array< TYPE > &arr) | |
Constructs a vector from an array. | |
vector & | operator= (const vector &other) |
Assignment operator for the vector. | |
vector (vector &&other) noexcept | |
Move constructor for the vector. | |
vector & | operator= (vector &&other) noexcept |
Move assignment operator for the vector. | |
~vector () override | |
Destructor for the vector. | |
void | swap (vector &other) noexcept |
u_integer | size () const override |
Gets the size of the vector. | |
u_integer | capacity () const noexcept |
Gets the current capacity of the vector. | |
TYPE & | data () const |
Gets a reference to the first element in the vector. | |
TYPE | get (integer index) const override |
Gets an element at the specified index. | |
TYPE & | operator[] (integer index) override |
Gets a reference to the element at the specified index. | |
void | set (integer index, const TYPE &e) override |
Sets the element at the specified index. | |
u_integer | indexOf (const TYPE &e) const override |
Finds the index of the first occurrence of the specified element. | |
void | pushBegin (const TYPE &e) override |
Inserts an element at the beginning of the vector. | |
void | push (integer index, const TYPE &e) override |
Inserts an element at the specified index in the vector. | |
void | pushEnd (const TYPE &e) override |
Inserts an element at the end of the vector. | |
TYPE | popBegin () override |
Removes and returns the first element in the vector. | |
TYPE | pop (integer index) override |
Removes and returns the element at the specified index. | |
TYPE | popEnd () override |
Removes and returns the last element in the vector. | |
Iterator * | begins () const override |
Gets an iterator to the beginning of the vector. | |
Iterator * | ends () const override |
Gets an iterator to the end of the vector. | |
std::string | className () const override |
Gets the class name of the vector. | |
![]() | |
virtual void | add (const TYPE &e) |
Adds an element to the end of the list. | |
virtual TYPE | remove (const TYPE &e) |
Removes an element from the list. | |
virtual void | clear () |
Removes all elements. | |
![]() | |
virtual TYPE | getBegin () const |
Retrieves the first element in the container. | |
virtual TYPE | getEnd () const |
Retrieves the last element in the container. | |
virtual TYPE | operator[] (integer index) const |
Retrieves the element at the specified index (const version). | |
bool | contains (const TYPE &e) const override |
Checks if the container contains the specified element. | |
![]() | |
bool | empty () const |
Checks if the container is empty. | |
virtual | ~container ()=default |
Destructor for the container class. | |
![]() | |
integer | compareTo (const iterationStream &other) const override |
Compares the current iteration stream with another iteration stream. | |
u_integer | toHash () const noexcept override |
Computes a hash value for the iteration stream. | |
std::string | toString (bool enter) const override |
Converts the iteration stream to a string representation. | |
![]() | |
operator std::string () const | |
Explicit conversion to std::string. | |
operator const char * () const | |
Explicit conversion to C-style string. | |
const char * | toCString (bool enter) const |
Direct C-string access with formatting control. | |
template<typename TYPE > | |
auto | formatString (const TYPE &t) -> std::string |
template<typename TYPE > | |
auto | formatCString (const TYPE &t) -> const char * |
template<typename TYPE > | |
auto | formatEnum (const TYPE &t) -> std::string |
template<typename TYPE > | |
auto | formatString (TYPE *const &ptr) -> std::string |
![]() | |
iterAdaptor | begin () |
Returns an iterator adapter pointing to the beginning of the container. | |
iterAdaptor | end () |
Returns an iterator adapter pointing to the end sentinel of the container. | |
iterAdaptor | begin () const |
Returns a const iterator adapter pointing to the beginning of the container. | |
iterAdaptor | end () const |
Returns a const iterator adapter pointing to the end sentinel of the container. | |
iterAdaptor | first () |
Returns an iterator adapter pointing to the first element. | |
iterAdaptor | last () |
Returns an iterator adapter pointing to the last element. | |
iterAdaptor | first () const |
Returns a const iterator adapter pointing to the first element. | |
iterAdaptor | last () const |
Returns a const iterator adapter pointing to the last element. | |
template<typename Callback = transform<TYPE>> requires Operation<Callback, TYPE> | |
void | forEach (Callback operation=Callback{}) |
Applies a given operation to each element in the iterable container. | |
template<typename Callback = transform<TYPE>> requires Operation<Callback, TYPE> | |
void | forEach (const Callback &operation=Callback{}) const |
Applies a given operation to each element in the iterable container (const version). | |
coroutine::generator< T > | generator () const |
Creates a coroutine generator that yields elements from this container. | |
template<typename Callback > requires original::Operation<Callback, TYPE> | |
auto | forEach (Callback operation) -> void |
template<typename Callback > requires original::Operation<Callback, TYPE> | |
auto | forEach (const Callback &operation) const -> void |
![]() | |
bool | operator== (const iterationStream< TYPE, DERIVED > &other) const |
Checks if the current object is equal to another. | |
bool | operator!= (const iterationStream< TYPE, DERIVED > &other) const |
Checks if the current object is not equal to another. | |
bool | operator< (const iterationStream< TYPE, DERIVED > &other) const |
Checks if the current object is less than another. | |
bool | operator> (const iterationStream< TYPE, DERIVED > &other) const |
Checks if the current object is greater than another. | |
bool | operator<= (const iterationStream< TYPE, DERIVED > &other) const |
Checks if the current object is less than or equal to another. | |
bool | operator>= (const iterationStream< TYPE, DERIVED > &other) const |
Checks if the current object is greater than or equal to another. | |
virtual | ~comparable ()=default |
Virtual destructor for proper cleanup of derived objects. | |
![]() | |
virtual bool | equals (const iterationStream< TYPE, DERIVED > &other) const noexcept |
Compares two objects for equality. | |
virtual | ~hashable ()=0 |
Virtual destructor. | |
Friends | |
template<typename T , typename... ARGS> | |
vector< T > | makeVector (u_integer size, ARGS &&... args) |
Additional Inherited Members | |
![]() | |
using | T = std::remove_const_t< TYPE > |
![]() | |
template<typename TYPE > | |
static std::string | formatString (const TYPE &t) |
Universal value-to-string conversion with type-specific formatting. | |
template<Printable TYPE> | |
static std::string | formatString (const TYPE &t) |
Specialization for types deriving from printable. | |
template<EnumType TYPE> | |
static std::string | formatString (const TYPE &t) |
Specialization for enum types with type-safe formatting. | |
template<typename TYPE > | |
static std::string | formatString (TYPE *const &ptr) |
Pointer-specific formatting with null safety. | |
template<typename TYPE > | |
static const char * | formatCString (const TYPE &t) |
C-string cache for temporary usage with static storage. | |
template<typename TYPE > | |
static std::string | formatEnum (const TYPE &t) |
Enum formatting utility with underlying value extraction. | |
template<> | |
auto | formatString (const char &t) -> std::string |
template<> | |
auto | formatString (const bool &t) -> std::string |
template<> | |
auto | formatString (const char *const &ptr) -> std::string |
![]() | |
bool | indexOutOfBound (integer index) const |
Checks if the provided index is out of bounds. | |
integer | parseNegIndex (integer index) const |
Converts negative indices into valid positive indices. | |
![]() | |
container (ALLOC alloc=ALLOC{}) | |
Constructs a container with specified allocator. | |
TYPE * | allocate (u_integer size) |
Allocates raw memory for elements. | |
void | deallocate (TYPE *ptr, u_integer size) |
Deallocates memory previously allocated by allocate() | |
template<typename O_TYPE , typename... Args> | |
void | construct (O_TYPE *o_ptr, Args &&... args) |
Constructs an element in-place. | |
template<typename O_TYPE > | |
void | destroy (O_TYPE *o_ptr) |
Destroys an element. | |
![]() | |
std::string | elementsString () const |
Returns a string representation of the elements in the stream. | |
![]() | |
ALLOC | allocator |
The allocator instance used for memory management. | |
Dynamic array container with amortized constant time operations.
TYPE | Element type stored in the vector |
ALLOC | Allocator type for memory management (default: allocator<TYPE>) |
Features include:
Memory management characteristics:
The ALLOC type must meet C++ allocator requirements and provide:
|
explicit |
Constructs a vector with specified allocator.
alloc | Allocator instance to use (default: default-constructed ALLOC) |
Initializes the vector with default capacity (16 elements). The allocator will be used for all subsequent memory operations.
original::vector< TYPE, ALLOC >::vector | ( | u_integer | size, |
ALLOC | alloc, | ||
ARGS &&... | args | ||
) |
Constructs a vector with specified size and allocator, initializing elements with provided arguments.
ARGS | Variadic template parameter pack for element construction arguments |
size | The initial number of elements in the vector |
alloc | Allocator instance to use (default: default-constructed ALLOC) |
args | Arguments to forward to element constructors |
This constructor:
Copy constructor for the vector.
other | The vector to copy from. |
original::vector< TYPE, ALLOC >::vector | ( | const std::initializer_list< TYPE > & | list | ) |
Constructs a vector from an initializer list.
list | The initializer list to construct the vector from. |
Constructs a vector from an array.
arr | The array to construct the vector from. |
Move constructor for the vector.
other | The vector to move from. |
|
overridevirtual |
Gets an iterator to the beginning of the vector.
Implements original::iterable< TYPE >.
|
noexcept |
Gets the current capacity of the vector.
|
overridevirtual |
Gets the class name of the vector.
Reimplemented from original::iterationStream< TYPE, DERIVED >.
Gets a reference to the first element in the vector.
|
overridevirtual |
Gets an iterator to the end of the vector.
Implements original::iterable< TYPE >.
|
overridevirtual |
Gets an element at the specified index.
index | The index of the element. |
Implements original::serial< TYPE, ALLOC >.
Finds the index of the first occurrence of the specified element.
e | The element to find. |
Implements original::serial< TYPE, ALLOC >.
Assignment operator for the vector.
other | The vector to assign from. |
Move assignment operator for the vector.
other | The vector to move from. |
|
overridevirtual |
Gets a reference to the element at the specified index.
index | The index of the element. |
Implements original::serial< TYPE, ALLOC >.
|
overridevirtual |
Removes and returns the element at the specified index.
index | The index of the element to remove. |
Implements original::baseList< TYPE, ALLOC >.
|
overridevirtual |
Removes and returns the first element in the vector.
Implements original::baseList< TYPE, ALLOC >.
|
overridevirtual |
Removes and returns the last element in the vector.
Implements original::baseList< TYPE, ALLOC >.
Inserts an element at the specified index in the vector.
index | The index to insert the element at. |
e | The element to insert. |
Implements original::baseList< TYPE, ALLOC >.
Inserts an element at the beginning of the vector.
e | The element to insert. |
Implements original::baseList< TYPE, ALLOC >.
Inserts an element at the end of the vector.
e | The element to insert. |
Implements original::baseList< TYPE, ALLOC >.
Sets the element at the specified index.
index | The index of the element to set. |
e | The value to set. |
Implements original::serial< TYPE, ALLOC >.
|
overridevirtual |
Gets the size of the vector.
Implements original::container< TYPE, ALLOC >.