Arduino List Library  3.0.1
The Ultimate Collection of Lists
Data Structures | Public Member Functions | Protected Member Functions
DoubleLinkedList< T > Class Template Reference

Implementation of a double-linked list. More...

#include <DoubleLinkedList.hpp>

Inheritance diagram for DoubleLinkedList< T >:
AbstractList< T >

Public Member Functions

 DoubleLinkedList (bool mutableList=false)
 Constructor of a DoubleLinkedList Object. More...
 
 ~DoubleLinkedList ()
 Destructor of a DoubleLinkedList Object.
 
void addAtIndex (int index, T &value) override
 Add the value to the list at the given index. The original entry at this index, and followings, will be placed directly after the new entry. More...
 
void clear () override
 Remove all elements from the List. More...
 
void remove (int index) override
 Remove the entry at the given index. More...
 
- Public Member Functions inherited from AbstractList< T >
void add (T &value)
 Add a new entry at the end of the list. More...
 
void addAll (int index, AbstractList< T > &list)
 Add all entries from the given list to this list at a specified index. The original entry at this index, and followings, will be placed directly after the entries of the given list. More...
 
void addAll (AbstractList< T > &list)
 Add all entries from the given list at the end of the list. More...
 
void addAll (int index, T *arr, const size_t arrSize)
 Add all entries from an array to this list at a specified index. The original entry at this index, and followings, will be placed directly after the entries of the given list. More...
 
void addAll (T *arr, const size_t arrSize)
 Add all entries from an array. More...
 
void addFirst (T &value)
 Add a new entry at the beginning of the list. More...
 
void addLast (T &value)
 Add a new entry at the end of the list. More...
 
get (const int index)
 Get the raw value at a specified index. More...
 
T * getMutableValue (const int index)
 Get the pointer to the mutable object at a specified index. More...
 
virtual void removeFirst ()
 Remove the first entry from the list.
 
virtual void removeLast ()
 Remove the las entry from the list.
 
void removeAll ()
 Remove all elements from the List. More...
 
int getSize () const
 Get the number how many elements are saved in the list. More...
 
bool isMutable () const
 Check if the list is mutable. More...
 
bool isEmpty () const
 Check if the list is empty. More...
 
bool equals (AbstractList< T > &other)
 Compare two lists whether their attributes and entries are equal. More...
 
operator[] (const int index)
 Get the raw value at a specified index. More...
 
bool operator== (AbstractList< T > &other)
 Compare two lists whether their attributes and entries are equal. More...
 
bool operator!= (AbstractList< T > &other)
 Opposite of '=='. More...
 
void operator+ (T &value)
 Add a new entry at the end of the list. More...
 
void operator+ (AbstractList< T > &list)
 Add all entries from the given list at the end of the list. More...
 

Protected Member Functions

T * getPointer (int index) override
 The last entry of the list. More...
 
- Protected Member Functions inherited from AbstractList< T >
 AbstractList (const bool mutableList)
 Constructor of an AbstractList Object. More...
 
void increaseSize ()
 Increase the size of the list by one. Should only be called after an insertion!
 
void decreaseSize ()
 Decrease the size of the list by one. Should only be called after an deletion!
 
void resetSize ()
 Reset the size to zero.
 
bool isIndexOutOfBounds (const int index) const
 Method to verify if the given index is out of the range of the list size. More...
 

Detailed Description

template<typename T>
class DoubleLinkedList< T >

Implementation of a double-linked list.

Template Parameters
TData Type of entries, that should be stored in the list.

Constructor & Destructor Documentation

◆ DoubleLinkedList()

template<typename T>
DoubleLinkedList< T >::DoubleLinkedList ( bool  mutableList = false)
inlineexplicit

Constructor of a DoubleLinkedList Object.

Parameters
mutableListtrue if the list should be mutable; false otherwise (default).

Member Function Documentation

◆ getPointer()

template<typename T>
T* DoubleLinkedList< T >::getPointer ( int  index)
inlineoverrideprotectedvirtual

The last entry of the list.

Get a pointer to the element, stored at specific index.

Parameters
indexThe index of the element to retrieve.
Returns
The nullptr, if the index is out of bounds, otherwise the address of the element.
Note
This is independent from the mutability of the list. It will always return the correct address (pointer) to the element.
Allowed indices are 0 to getSize() -1. If the index is out of bounds, a nullptr will be returned.

Implements AbstractList< T >.

◆ addAtIndex()

template<typename T>
void DoubleLinkedList< T >::addAtIndex ( int  index,
T &  value 
)
inlineoverridevirtual

Add the value to the list at the given index. The original entry at this index, and followings, will be placed directly after the new entry.

'Using' the addAtIndex method, to prevent name hiding of the addAtIndex method from AbstractList

Note
Allowed indices are 0 to getSize(). If the index is out of bounds, nothing will happen.
If this list is mutable, ensure, that all variables added to the lists do not go out-of-scope during all operations of the list.
Parameters
indexIndex of the entry, where the value should be added.
valueValue of the new entry.

Implements AbstractList< T >.

◆ clear()

template<typename T>
void DoubleLinkedList< T >::clear ( )
inlineoverridevirtual

Remove all elements from the List.

Implements AbstractList< T >.

◆ remove()

template<typename T>
void DoubleLinkedList< T >::remove ( int  index)
inlineoverridevirtual

Remove the entry at the given index.

Note
Allowed indices are 0 to getSize() - 1. If the index is out of bounds, nothing will happen.
Parameters
indexIndex of element to remove.

Implements AbstractList< T >.


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