ORIGINAL
|
Abstract base class for sequential containers with index-based access. More...
#include <serial.h>
Public Member Functions | |
virtual TYPE | get (integer index) const =0 |
Retrieves the element at the specified index. | |
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). | |
virtual TYPE & | operator[] (integer index)=0 |
Retrieves or sets the element at the specified index. | |
virtual void | set (integer index, const TYPE &e)=0 |
Sets the element at the specified index. | |
virtual u_integer | indexOf (const TYPE &e) const =0 |
Finds the index of the specified element. | |
bool | contains (const TYPE &e) const override |
Checks if the container contains the specified element. | |
![]() | |
virtual u_integer | size () const =0 |
Gets the number of elements in the container. | |
bool | empty () const |
Checks if the container is empty. | |
virtual | ~container ()=default |
Destructor for the container class. | |
Protected Member Functions | |
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. | |
Additional Inherited Members | |
![]() | |
ALLOC | allocator |
The allocator instance used for memory management. | |
Abstract base class for sequential containers with index-based access.
TYPE | Type of the elements contained in the serial container |
ALLOC | Allocator type for memory management (default: depends on derived class) |
Defines common interface for containers that support index-based access to their elements. It provides methods for element retrieval, bounds checking, and negative index handling. Derived classes must implement get()
, operator[]
, set()
, and indexOf()
methods.
The allocator is inherited from the base container class and is propagated to derived classes for consistent memory management. The ALLOC type must meet the C++ allocator requirements.
|
overridevirtual |
Checks if the container contains the specified element.
e | The element to check for. |
true
if the container contains the element, otherwise false
.This method uses indexOf()
by default to check if the element exists within the container.
Implements original::container< TYPE, ALLOC >.
|
pure virtual |
Retrieves the element at the specified index.
index | The index of the element. |
Derived classes must implement this method to provide the actual element retrieval.
Implemented in original::array< TYPE, ALLOC >, original::array< underlying_type, rebind_alloc_underlying >, original::bitSet< ALLOC >, original::blocksList< TYPE, ALLOC >, original::blocksList< TYPE, allocator< TYPE > >, original::chain< TYPE, ALLOC >, original::chain< opts >, original::chain< original::strongPtr< original::filter< TYPE > > >, original::chain< original::strongPtr< original::transform< TYPE > > >, original::chain< TYPE, allocator< TYPE > >, original::forwardChain< TYPE, ALLOC >, original::vector< TYPE, ALLOC >, original::vector< hashNode *, rebind_alloc_pointer >, original::vector< hashNode *, rebind_alloc_pointer >, original::vector< original::hashTable::hashNode *, rebind_alloc_pointer >, original::vector< original::skipList::skipListNode * >, and original::vector< TYPE * >.
|
virtual |
Retrieves the first element in the container.
This method provides a shortcut to get the first element by calling get(0)
.
|
virtual |
Retrieves the last element in the container.
This method provides a shortcut to get the last element by calling get(-1)
.
|
pure virtual |
Finds the index of the specified element.
e | The element to find. |
size()
if not found.This method searches for the element in the container and returns its index.
Implemented in original::array< TYPE, ALLOC >, original::array< underlying_type, rebind_alloc_underlying >, original::blocksList< TYPE, ALLOC >, original::blocksList< TYPE, allocator< TYPE > >, original::chain< TYPE, ALLOC >, original::chain< opts >, original::chain< original::strongPtr< original::filter< TYPE > > >, original::chain< original::strongPtr< original::transform< TYPE > > >, original::chain< TYPE, allocator< TYPE > >, original::forwardChain< TYPE, ALLOC >, original::vector< TYPE, ALLOC >, original::vector< hashNode *, rebind_alloc_pointer >, original::vector< original::hashTable::hashNode *, rebind_alloc_pointer >, original::vector< original::skipList::skipListNode * >, and original::vector< TYPE * >.
|
nodiscardprotected |
Checks if the provided index is out of bounds.
index | The index to check. |
true
if the index is out of bounds, otherwise false
.This method accounts for negative indices by converting them to positive indices before performing the bounds check.
|
virtual |
Retrieves the element at the specified index (const version).
index | The index of the element. |
The non-const version allows direct modification of elements in allocator-managed storage. The const version returns a copy of the element.
May | throw original::outOfBoundError exceptions for invalid indices |
|
pure virtual |
Retrieves or sets the element at the specified index.
index | The index of the element. |
The non-const version allows direct modification of elements in allocator-managed storage. The const version returns a copy of the element.
May | throw original::outOfBoundError exceptions for invalid indices |
Implemented in original::array< TYPE, ALLOC >, original::array< underlying_type, rebind_alloc_underlying >, original::bitSet< ALLOC >, original::blocksList< TYPE, ALLOC >, original::blocksList< TYPE, allocator< TYPE > >, original::chain< TYPE, ALLOC >, original::chain< opts >, original::chain< original::strongPtr< original::filter< TYPE > > >, original::chain< original::strongPtr< original::transform< TYPE > > >, original::chain< TYPE, allocator< TYPE > >, original::forwardChain< TYPE, ALLOC >, original::vector< TYPE, ALLOC >, original::vector< hashNode *, rebind_alloc_pointer >, original::vector< hashNode *, rebind_alloc_pointer >, original::vector< original::hashTable::hashNode *, rebind_alloc_pointer >, original::vector< original::skipList::skipListNode * >, and original::vector< TYPE * >.
|
nodiscardprotected |
Converts negative indices into valid positive indices.
index | The index to convert. |
For example, if the index is -1, it will be converted to the last element's index.
|
pure virtual |
Sets the element at the specified index.
index | The index of the element to set. |
e | The new value to store at the specified index. |
Implemented in original::array< TYPE, ALLOC >, original::array< underlying_type, rebind_alloc_underlying >, original::blocksList< TYPE, ALLOC >, original::blocksList< TYPE, allocator< TYPE > >, original::chain< TYPE, ALLOC >, original::chain< opts >, original::chain< original::strongPtr< original::filter< TYPE > > >, original::chain< original::strongPtr< original::transform< TYPE > > >, original::chain< TYPE, allocator< TYPE > >, original::forwardChain< TYPE, ALLOC >, original::vector< TYPE, ALLOC >, original::vector< hashNode *, rebind_alloc_pointer >, original::vector< original::hashTable::hashNode *, rebind_alloc_pointer >, original::vector< original::skipList::skipListNode * >, and original::vector< TYPE * >.