ORIGINAL
Loading...
Searching...
No Matches
original::baseList< TYPE, ALLOC > Class Template Referenceabstract

Base class for variable-size serial containers. More...

#include <baseList.h>

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

Public Member Functions

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 void push (integer index, const TYPE &e)=0
 Inserts an element at a specific index.
 
virtual TYPE pop (integer index)=0
 Removes an element from a specific index.
 
virtual void pushBegin (const TYPE &e)=0
 Inserts an element at the beginning of the list.
 
virtual TYPE popBegin ()=0
 Removes an element from the beginning of the list.
 
virtual void pushEnd (const TYPE &e)=0
 Inserts an element at the end of the list.
 
virtual TYPE popEnd ()=0
 Removes an element from the end of the list.
 
- Public Member Functions inherited from original::serial< TYPE, ALLOC >
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.
 
- Public Member Functions inherited from original::container< TYPE, ALLOC >
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.
 

Additional Inherited Members

- 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 Attributes inherited from original::container< TYPE, ALLOC >
ALLOC allocator
 The allocator instance used for memory management.
 

Detailed Description

template<typename TYPE, typename ALLOC>
class original::baseList< TYPE, ALLOC >

Base class for variable-size serial containers.

Template Parameters
TYPEType of the elements contained in the base list
ALLOCAllocator type for dynamic memory management (default depends on derived class)

This class serves as the base class for containers that can dynamically grow or shrink in size. It inherits from original::serial and provides an interface for manipulating elements in a variable-size sequence.

The allocator is used for all dynamic memory operations including:

  • Memory allocation/de-allocation when growing/shrinking
  • Element construction/destruction
  • Node allocation in linked implementations

Key memory characteristics:

  • Dynamic resizing operations may trigger reallocations
  • Allocator state is preserved during copy/move operations
  • Strong exception safety guarantee for most operations

The ALLOC type must meet C++ allocator requirements and provide:

  • allocate()/deallocate() methods
  • construct()/destroy() methods
  • propagate_on_container_copy_assignment/move_assignment typedefs

Member Function Documentation

◆ add()

template<typename TYPE, typename ALLOC>
auto original::baseList< TYPE, ALLOC >::add ( const TYPE & e)
virtual

Adds an element to the end of the list.

Parameters
eThe element to be added to the list.

This method adds an element to the end of the container by calling pushEnd.

◆ clear()

template<typename TYPE, typename ALLOC>
auto original::baseList< TYPE, ALLOC >::clear ( )
virtual

Removes all elements.

Uses the allocator to:

  • Destroy all elements
  • Deallocate storage if applicable
    Note
    No-throw guarantee if element destructors don't throw

◆ pop()

template<typename TYPE, typename ALLOC>
virtual TYPE original::baseList< TYPE, ALLOC >::pop ( integer index)
pure virtual

◆ popBegin()

◆ popEnd()

◆ push()

template<typename TYPE, typename ALLOC>
virtual void original::baseList< TYPE, ALLOC >::push ( integer index,
const TYPE & e )
pure virtual

◆ pushBegin()

template<typename TYPE, typename ALLOC>
virtual void original::baseList< TYPE, ALLOC >::pushBegin ( const TYPE & e)
pure virtual

◆ pushEnd()

template<typename TYPE, typename ALLOC>
virtual void original::baseList< TYPE, ALLOC >::pushEnd ( const TYPE & e)
pure virtual

◆ remove()

template<typename TYPE, typename ALLOC>
auto original::baseList< TYPE, ALLOC >::remove ( const TYPE & e)
virtual

Removes an element from the list.

Parameters
eThe element to be removed.
Returns
The removed element.

This method finds the element in the list and removes it by calling pop at the found index.


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