ORIGINAL
Loading...
Searching...
No Matches
original::chain< TYPE, ALLOC > Class Template Referencefinal

Non-cyclic doubly linked list container. More...

#include <chain.h>

Inheritance diagram for original::chain< TYPE, ALLOC >:
Inheritance graph
Collaboration diagram for original::chain< TYPE, ALLOC >:
Collaboration graph

Classes

class  Iterator
 Bidirectional iterator implementation for chain. More...
 

Public Member Functions

 chain (ALLOC alloc=ALLOC{})
 Constructs an empty chain with specified allocator.
 
 chain (const chain &other)
 Copy constructs a chain with optional allocator.
 
 chain (const std::initializer_list< TYPE > &list)
 Constructs a chain from an initializer list.
 
 chain (const array< TYPE > &arr)
 Constructs a chain from an array.
 
chainoperator= (const chain &other)
 Copy assignment operator with allocator propagation.
 
 chain (chain &&other) noexcept
 Move constructs a chain with optional allocator.
 
chainoperator= (chain &&other) noexcept
 Move assignment operator with allocator propagation.
 
chainoperator+= (chain &other)
 Concatenates another chain to this one.
 
u_integer size () const override
 Gets the size of the chain.
 
TYPE get (integer index) const override
 Gets the 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
 Pushes an element to the beginning of the chain.
 
void push (integer index, const TYPE &e) override
 Pushes an element at the specified index in the chain.
 
void pushEnd (const TYPE &e) override
 Pushes an element to the end of the chain.
 
TYPE popBegin () override
 Pops an element from the beginning of the chain.
 
TYPE pop (integer index) override
 Pops an element at the specified index in the chain.
 
TYPE popEnd () override
 Pops an element from the end of the chain.
 
Iteratorbegins () const override
 Gets an iterator to the beginning of the chain.
 
Iteratorends () const override
 Gets an iterator to the end of the chain.
 
std::string className () const override
 Gets the class name of the chain.
 
 ~chain () override
 Destructor for the chain.
 
- Public Member Functions inherited from original::baseList< TYPE, ALLOC >
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.
 
- Public Member Functions inherited from original::serial< TYPE, ALLOC >
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.
 
- Public Member Functions inherited from original::container< TYPE, ALLOC >
bool empty () const
 Checks if the container is empty.
 
virtual ~container ()=default
 Destructor for the container class.
 
- Public Member Functions inherited from original::iterationStream< TYPE, DERIVED >
integer compareTo (const iterationStream &other) const override
 Compares the current iteration stream with another iteration stream.
 
std::string className () const override
 Returns the class name.
 
std::string toString (bool enter) const override
 Converts the iteration stream to a string representation.
 
- Public Member Functions inherited from original::printable
 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
 
- Public Member Functions inherited from original::iterable< TYPE >
iterAdaptor begin ()
 Returns an iterator pointing to the beginning of the iterable container.
 
iterAdaptor end ()
 Returns an iterator pointing to the end of the iterable container.
 
iterAdaptor begin () const
 Returns a constant iterator pointing to the beginning of the iterable container.
 
iterAdaptor end () const
 Returns a constant iterator pointing to the end of the iterable container.
 
iterAdaptor first ()
 Returns an iterator pointing to the first element.
 
iterAdaptor last ()
 Returns an iterator pointing to the last element.
 
iterAdaptor first () const
 Returns a constant iterator pointing to the first element.
 
iterAdaptor last () const
 Returns a constant iterator 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).
 
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
 
- Public Member Functions inherited from original::comparable< iterationStream< TYPE, DERIVED > >
virtual integer compareTo (const DERIVED &other) const=0
 Compares the current object with another of the same type.
 
bool operator== (const DERIVED &other) const
 Checks if the current object is equal to another.
 
bool operator!= (const DERIVED &other) const
 Checks if the current object is not equal to another.
 
bool operator< (const DERIVED &other) const
 Checks if the current object is less than another.
 
bool operator> (const DERIVED &other) const
 Checks if the current object is greater than another.
 
bool operator<= (const DERIVED &other) const
 Checks if the current object is less than or equal to another.
 
bool operator>= (const 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.
 

Additional Inherited Members

- Static Public Member Functions inherited from original::printable
template<typename TYPE>
static std::string formatString (const TYPE &t)
 Universal value-to-string conversion.
 
template<typename TYPE>
static std::string formatString (TYPE *const &ptr)
 Pointer-specific formatting.
 
template<typename TYPE>
static const char * formatCString (const TYPE &t)
 C-string cache for temporary usage.
 
template<typename TYPE>
static std::string formatEnum (const TYPE &t)
 Enum formatting utility.
 
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
 
- Protected Member Functions inherited from original::serial< TYPE, ALLOC >
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.
 
- Protected Member Functions inherited from original::container< TYPE, ALLOC >
 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.
 
- Protected Member Functions inherited from original::iterationStream< TYPE, DERIVED >
std::string elementsString () const
 Returns a string representation of the elements in the stream.
 
- Protected Attributes inherited from original::container< TYPE, ALLOC >
ALLOC allocator
 The allocator instance used for memory management.
 

Detailed Description

template<typename TYPE, typename ALLOC = allocator<TYPE>>
class original::chain< TYPE, ALLOC >

Non-cyclic doubly linked list container.

Template Parameters
TYPEType of elements stored in the list
ALLOCAllocator type for memory management (default is allocator<TYPE>)

Implements a classic doubly linked list with:

  • Sentinel nodes for boundary management
  • Bidirectional traversal capabilities
  • Index-based element access (O(n) complexity)
  • Deep copy semantics
  • Custom memory allocation through allocator

Constructor & Destructor Documentation

◆ chain() [1/5]

template<typename TYPE, typename ALLOC>
original::chain< TYPE, ALLOC >::chain ( ALLOC alloc = ALLOC{})
explicit

Constructs an empty chain with specified allocator.

Parameters
allocAllocator instance to use (has default-constructed ALLOC)

◆ chain() [2/5]

template<typename TYPE, typename ALLOC>
original::chain< TYPE, ALLOC >::chain ( const chain< TYPE, ALLOC > & other)

Copy constructs a chain with optional allocator.

Parameters
otherThe chain to copy from
Note
Allocator is copied if ALLOC::propagate_on_container_copy_assignment is true

◆ chain() [3/5]

template<typename TYPE, typename ALLOC>
original::chain< TYPE, ALLOC >::chain ( const std::initializer_list< TYPE > & list)

Constructs a chain from an initializer list.

Parameters
listThe initializer list to construct the chain from.

◆ chain() [4/5]

template<typename TYPE, typename ALLOC>
original::chain< TYPE, ALLOC >::chain ( const array< TYPE > & arr)
explicit

Constructs a chain from an array.

Parameters
arrThe array to construct the chain from.

◆ chain() [5/5]

template<typename TYPE, typename ALLOC>
original::chain< TYPE, ALLOC >::chain ( chain< TYPE, ALLOC > && other)
noexcept

Move constructs a chain with optional allocator.

Parameters
otherThe chain to move from
Note
Allocator is moved if ALLOC::propagate_on_container_move_assignment is true

Member Function Documentation

◆ begins()

template<typename TYPE, typename ALLOC>
auto original::chain< TYPE, ALLOC >::begins ( ) const
overridevirtual

Gets an iterator to the beginning of the chain.

Returns
An iterator to the beginning of the chain.

Implements original::iterable< TYPE >.

◆ className()

template<typename TYPE, typename ALLOC>
auto original::chain< TYPE, ALLOC >::className ( ) const
nodiscardoverridevirtual

Gets the class name of the chain.

Returns
The class name as a string.

Reimplemented from original::printable.

◆ ends()

template<typename TYPE, typename ALLOC>
auto original::chain< TYPE, ALLOC >::ends ( ) const
overridevirtual

Gets an iterator to the end of the chain.

Returns
An iterator to the end of the chain.

Implements original::iterable< TYPE >.

◆ get()

template<typename TYPE, typename ALLOC>
auto original::chain< TYPE, ALLOC >::get ( integer index) const
overridevirtual

Gets the element at the specified index.

Parameters
indexThe index of the element to retrieve.
Returns
The element at the specified index.

Implements original::serial< TYPE, ALLOC >.

◆ indexOf()

template<typename TYPE, typename ALLOC>
auto original::chain< TYPE, ALLOC >::indexOf ( const TYPE & e) const
overridevirtual

Finds the index of the first occurrence of the specified element.

Parameters
eThe element to search for.
Returns
The index of the element, or the size of the chain if not found.

Implements original::serial< TYPE, ALLOC >.

◆ operator+=()

template<typename TYPE, typename ALLOC>
auto original::chain< TYPE, ALLOC >::operator+= ( chain< TYPE, ALLOC > & other)

Concatenates another chain to this one.

Parameters
otherThe chain to concatenate
Returns
Reference to this chain after merge

◆ operator=() [1/2]

template<typename TYPE, typename ALLOC>
auto original::chain< TYPE, ALLOC >::operator= ( chain< TYPE, ALLOC > && other)
noexcept

Move assignment operator with allocator propagation.

Parameters
otherChain to move from
Returns
Reference to this chain
Note
Allocator is moved if ALLOC::propagate_on_container_move_assignment is true

◆ operator=() [2/2]

template<typename TYPE, typename ALLOC>
original::chain< TYPE, ALLOC > & original::chain< TYPE, ALLOC >::operator= ( const chain< TYPE, ALLOC > & other)

Copy assignment operator with allocator propagation.

Parameters
otherThe chain to copy from
Returns
Reference to this chain
Note
Allocator is copied if ALLOC::propagate_on_container_copy_assignment is true

◆ operator[]()

template<typename TYPE, typename ALLOC>
auto original::chain< TYPE, ALLOC >::operator[] ( integer index)
overridevirtual

Gets a reference to the element at the specified index.

Parameters
indexThe index of the element to retrieve.
Returns
A reference to the element at the specified index.

Implements original::serial< TYPE, ALLOC >.

◆ pop()

template<typename TYPE, typename ALLOC>
auto original::chain< TYPE, ALLOC >::pop ( integer index)
overridevirtual

Pops an element at the specified index in the chain.

Parameters
indexThe index of the element to pop.
Returns
The element that was popped.

Implements original::baseList< TYPE, ALLOC >.

◆ popBegin()

template<typename TYPE, typename ALLOC>
auto original::chain< TYPE, ALLOC >::popBegin ( )
overridevirtual

Pops an element from the beginning of the chain.

Returns
The element that was popped.

Implements original::baseList< TYPE, ALLOC >.

◆ popEnd()

template<typename TYPE, typename ALLOC>
auto original::chain< TYPE, ALLOC >::popEnd ( )
overridevirtual

Pops an element from the end of the chain.

Returns
The element that was popped.

Implements original::baseList< TYPE, ALLOC >.

◆ push()

template<typename TYPE, typename ALLOC>
auto original::chain< TYPE, ALLOC >::push ( integer index,
const TYPE & e )
overridevirtual

Pushes an element at the specified index in the chain.

Parameters
indexThe index at which to insert the element.
eThe element to push.

Implements original::baseList< TYPE, ALLOC >.

◆ pushBegin()

template<typename TYPE, typename ALLOC>
auto original::chain< TYPE, ALLOC >::pushBegin ( const TYPE & e)
overridevirtual

Pushes an element to the beginning of the chain.

Parameters
eThe element to push to the beginning.

Implements original::baseList< TYPE, ALLOC >.

◆ pushEnd()

template<typename TYPE, typename ALLOC>
auto original::chain< TYPE, ALLOC >::pushEnd ( const TYPE & e)
overridevirtual

Pushes an element to the end of the chain.

Parameters
eThe element to push to the end.

Implements original::baseList< TYPE, ALLOC >.

◆ set()

template<typename TYPE, typename ALLOC>
auto original::chain< TYPE, ALLOC >::set ( integer index,
const TYPE & e )
overridevirtual

Sets the element at the specified index.

Parameters
indexThe index of the element to set.
eThe value to set the element to.

Implements original::serial< TYPE, ALLOC >.

◆ size()

template<typename TYPE, typename ALLOC>
auto original::chain< TYPE, ALLOC >::size ( ) const
nodiscardoverridevirtual

Gets the size of the chain.

Returns
The number of elements in the chain.

Implements original::container< TYPE, ALLOC >.


The documentation for this class was generated from the following file: