5 #ifndef AULA1_ORDEREDLIST_HPP 6 #define AULA1_ORDEREDLIST_HPP 22 string
getName() {
return "Ordered List"; }
35 for (
int i = 0; i <= (
sizeof(data) /
sizeof(data[0])); i ++) {
50 while (tmp != NULL && compare(val, tmp->getValue()) < 0) {
68 while (tmp != NULL && compare(val, tmp->getValue()) >= 0) {
69 if (compare(val, tmp->getValue()) == 0)
Node used inside other data structures.
function< int(T, T)> compare
Doubly-linked list implementation with dynamic memory allocation.
int indexOf(T val)
Finds an element in the ordered list and returns its index.
T get(int index)
Get the element at the specified position in the list, without removing it.
OrderedList(std::function< int(T, T)> compareFunc)
Creates the structure.
void insert(T val)
Insert an element at its position on the list.
string getName()
Provides the name of the data structure as a string representation.
bool contains(T val)
Answers whether the ordered list contains an enemy.
OrderedList(const T data[], std::function< int(T, T)> compareFunc)
create the structure and populate it with the data from the array
T remove(int index)
Remove an element from the list.
void insert(T val, int index)
Insert an element at the specified position in the list.