A hybrid array list that starts with a static array and switches to dynamic allocation when full.
More...
#include <HybridArrayList.h>
|
|
| 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 |
| |
| T | 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 |
| |
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
-
| T | The type of elements stored in the list. |
| STATIC_CAPACITY | The initial static size of the array. |
◆ add()
template<typename T , int STATIC_CAPACITY = HYBRID_ARRAY_LIST_DEFAULT_STATIC_CAPACITY>
Adds an element to the end of the list.
- Parameters
-
| element | The element to be added. |
◆ get()
template<typename T , int STATIC_CAPACITY = HYBRID_ARRAY_LIST_DEFAULT_STATIC_CAPACITY>
Retrieves the element at the specified position in the list.
- Parameters
-
| index | The 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>
Finds the first occurrence of the specified element in this list.
- Parameters
-
| item | The 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
-
| index | The position at which the element should be inserted. |
| element | The element to insert. |
◆ remove()
template<typename T , int STATIC_CAPACITY = HYBRID_ARRAY_LIST_DEFAULT_STATIC_CAPACITY>
Removes the element at the specified position in the list.
- Parameters
-
| index | The position of the element to remove. |
◆ removeItem()
template<typename T , int STATIC_CAPACITY = HYBRID_ARRAY_LIST_DEFAULT_STATIC_CAPACITY>
Removes the first occurrence of the specified element from this list, if it is present.
- Parameters
-
| item | The element to be removed from this list, if present. |
The documentation for this class was generated from the following file: