Plaquette
 
Loading...
Searching...
No Matches
HybridArrayList< T, STATIC_CAPACITY > Class Template Reference

A hybrid array list that starts with a static array and switches to dynamic allocation when full. More...

#include <HybridArrayList.h>

Public Member Functions

 HybridArrayList ()
 Constructs a new Hybrid Array List object.
 
 ~HybridArrayList ()
 Destroys the Hybrid Array List object, deallocating any dynamic memory used.
 
void add (const T &item)
 Adds an element to the end of the list.
 
void insert (int index, const T &item)
 Inserts an element at the specified position in the list.
 
int indexOf (const T &item)
 Finds the first occurrence of the specified element in this list.
 
bool removeItem (const T &item)
 Removes the first occurrence of the specified element from this list, if it is present.
 
void remove (int index)
 Removes the element at the specified position in the list.
 
T & operator[] (int index)
 
const T & operator[] (int index) const
 
get (int index) const
 Retrieves the element at the specified position in the list.
 
void removeAll ()
 Removes all items from the list without changing its capacity.
 
size_t size () const
 
size_t capacity () const
 

Detailed Description

template<typename T, int STATIC_CAPACITY = HYBRID_ARRAY_LIST_DEFAULT_STATIC_CAPACITY>
class HybridArrayList< T, STATIC_CAPACITY >

A hybrid array list that starts with a static array and switches to dynamic allocation when full.

Template Parameters
TThe type of elements stored in the list.
STATIC_CAPACITYThe initial static size of the array.

Member Function Documentation

◆ add()

template<typename T , int STATIC_CAPACITY = HYBRID_ARRAY_LIST_DEFAULT_STATIC_CAPACITY>
void HybridArrayList< T, STATIC_CAPACITY >::add ( const T &  item)
inline

Adds an element to the end of the list.

Parameters
elementThe element to be added.

◆ get()

template<typename T , int STATIC_CAPACITY = HYBRID_ARRAY_LIST_DEFAULT_STATIC_CAPACITY>
T HybridArrayList< T, STATIC_CAPACITY >::get ( int  index) const
inline

Retrieves the element at the specified position in the list.

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

◆ indexOf()

template<typename T , int STATIC_CAPACITY = HYBRID_ARRAY_LIST_DEFAULT_STATIC_CAPACITY>
int HybridArrayList< T, STATIC_CAPACITY >::indexOf ( const T &  item)
inline

Finds the first occurrence of the specified element in this list.

Parameters
itemThe element to search for.
Returns
The index of the first occurrence of the specified element in this list, or -1 if this list does not contain the element.

◆ insert()

template<typename T , int STATIC_CAPACITY = HYBRID_ARRAY_LIST_DEFAULT_STATIC_CAPACITY>
void HybridArrayList< T, STATIC_CAPACITY >::insert ( int  index,
const T &  item 
)
inline

Inserts an element at the specified position in the list.

Parameters
indexThe position at which the element should be inserted.
elementThe element to insert.

◆ remove()

template<typename T , int STATIC_CAPACITY = HYBRID_ARRAY_LIST_DEFAULT_STATIC_CAPACITY>
void HybridArrayList< T, STATIC_CAPACITY >::remove ( int  index)
inline

Removes the element at the specified position in the list.

Parameters
indexThe position of the element to remove.

◆ removeItem()

template<typename T , int STATIC_CAPACITY = HYBRID_ARRAY_LIST_DEFAULT_STATIC_CAPACITY>
bool HybridArrayList< T, STATIC_CAPACITY >::removeItem ( const T &  item)
inline

Removes the first occurrence of the specified element from this list, if it is present.

Parameters
itemThe element to be removed from this list, if present.

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