26 #ifndef LIST_ABSTRACT_LIST_HPP 27 #define LIST_ABSTRACT_LIST_HPP 39 bool mutableList =
false;
44 #define extendedIsIndexOutOfBounds(index) \ 45 ((index) != this->getSize() && this->isIndexOutOfBounds(index)) 52 T *mutableValue =
nullptr;
66 return &immutableValue;
141 #if __cplusplus >= 201103L || defined(__GXX_EXPERIMENTAL_CXX0X__) 160 virtual void addAtIndex(
int index, T &value) = 0;
162 #if __cplusplus >= 201103L || defined(__GXX_EXPERIMENTAL_CXX0X__) 167 virtual void addAtIndex(
const int index, T &&value) {
186 for (
int i = 0; i < list.
getSize(); i++) {
211 void addAll(
int index, T *arr,
const size_t arrSize) {
212 for (
size_t i = 0; i < arrSize; ++i) {
224 void addAll(T *arr,
const size_t arrSize) {
225 for (
size_t i = 0; i < arrSize; ++i) {
238 #if __cplusplus >= 201103L || defined(__GXX_EXPERIMENTAL_CXX0X__) 254 #if __cplusplus >= 201103L || defined(__GXX_EXPERIMENTAL_CXX0X__) 300 virtual void clear() = 0;
310 virtual void remove(
int index) = 0;
367 for (
int i = 0; i <
getSize(); i++) {
373 if (other.
get(i) != this->
get(i)) {
409 #if __cplusplus >= 201103L || defined(__GXX_EXPERIMENTAL_CXX0X__) 426 #endif// LIST_ABSTRACT_LIST_HPP void resetSize()
Reset the size to zero.
Definition: AbstractList.hpp:120
virtual T * getPointer(int index)=0
Get a pointer to the element, stored at specific index.
int getSize() const
Get the number how many elements are saved in the list.
Definition: AbstractList.hpp:334
bool isIndexOutOfBounds(const int index) const
Method to verify if the given index is out of the range of the list size.
Definition: AbstractList.hpp:130
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...
Definition: AbstractList.hpp:211
virtual void removeFirst()
Remove the first entry from the list.
Definition: AbstractList.hpp:315
void removeAll()
Remove all elements from the List.
Definition: AbstractList.hpp:327
void addAll(T *arr, const size_t arrSize)
Add all entries from an array.
Definition: AbstractList.hpp:224
void increaseSize()
Increase the size of the list by one. Should only be called after an insertion!
Definition: AbstractList.hpp:109
virtual void clear()=0
Remove all elements from the List.
void addAll(AbstractList< T > &list)
Add all entries from the given list at the end of the list.
Definition: AbstractList.hpp:198
void add(T &value)
Add a new entry at the end of the list.
Definition: AbstractList.hpp:139
T get(const int index)
Get the raw value at a specified index.
Definition: AbstractList.hpp:275
virtual void removeLast()
Remove the las entry from the list.
Definition: AbstractList.hpp:320
void setValue(T &val, const bool m)
Set the value.
Definition: AbstractList.hpp:75
bool operator==(AbstractList< T > &other)
Compare two lists whether their attributes and entries are equal.
Definition: AbstractList.hpp:391
Definition: AbstractList.hpp:50
bool operator!=(AbstractList< T > &other)
Opposite of '=='.
Definition: AbstractList.hpp:400
virtual void addAtIndex(int index, T &value)=0
Add the value to the list at the given index. The original entry at this index, and followings...
bool isEmpty() const
Check if the list is empty.
Definition: AbstractList.hpp:348
void addFirst(T &value)
Add a new entry at the beginning of the list.
Definition: AbstractList.hpp:236
T * getValue(const bool m)
A pointer to the raw value, assigned for mutable lists.
Definition: AbstractList.hpp:62
void decreaseSize()
Decrease the size of the list by one. Should only be called after an deletion!
Definition: AbstractList.hpp:115
bool isMutable() const
Check if the list is mutable.
Definition: AbstractList.hpp:341
T * getMutableValue(const int index)
Get the pointer to the mutable object at a specified index.
Definition: AbstractList.hpp:289
bool equals(AbstractList< T > &other)
Compare two lists whether their attributes and entries are equal.
Definition: AbstractList.hpp:358
void operator+(T &value)
Add a new entry at the end of the list.
Definition: AbstractList.hpp:407
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 ind...
Definition: AbstractList.hpp:185
T operator[](const int index)
Get the raw value at a specified index.
Definition: AbstractList.hpp:385
void addLast(T &value)
Add a new entry at the end of the list.
Definition: AbstractList.hpp:252
void operator+(AbstractList< T > &list)
Add all entries from the given list at the end of the list.
Definition: AbstractList.hpp:423
Abstract class from which all lists can be derived.
Definition: AbstractList.hpp:37