Data Structures in C++
|
Doubly-linked ordered list implementation with dynamic memory allocation. More...
#include <OrderedList.hpp>
Public Member Functions | |
string | getName () |
Provides the name of the data structure as a string representation. More... | |
OrderedList (std::function< int(T, T)> compareFunc) | |
Creates the structure. More... | |
OrderedList (const T data[], std::function< int(T, T)> compareFunc) | |
create the structure and populate it with the data from the array More... | |
void | insert (T val) |
Insert an element at its position on the list. More... | |
void | insert (T val, int index) |
Insert an element at the specified position in the list. More... | |
int | indexOf (T val) |
Finds an element in the ordered list and returns its index. More... | |
bool | contains (T val) |
Answers whether the ordered list contains an enemy. More... | |
T | remove (int index) |
Remove an element from the list. More... | |
T | get (int index) |
Get the element at the specified position in the list, without removing it. More... | |
![]() | |
LinkedList () | |
LinkedList (T data[]) | |
create the structure and populate it with the data from the array More... | |
Iterator< T > | iterator () |
Creates an Iterator, an object that allows the sequential access of values in a Linked List without the search overhead. More... | |
![]() | |
ProtectedLinkedList () | |
~ProtectedLinkedList () | |
int | getSize () |
Outputs the number of elements stored in the structure. More... | |
bool | isEmpty () |
Check whether the structure is empty. More... | |
bool | isFull () |
Check whether the structure is full. More... | |
Private Attributes | |
function< int(T, T)> | compare |
Additional Inherited Members | |
![]() | |
Node< T > * | getNode (int index) |
ProtectedLinkedList (const T data[]) | |
create the structure and populate it with the data from the array More... | |
Node< T > * | getFirst () const |
Node< T > * | getLast () const |
Doubly-linked ordered list implementation with dynamic memory allocation.
This class searches for the appropriate place to insert an element keeping the array sorted ata ll times, much like insertion sort.
T | The type of object the data structure will contain |
Definition at line 17 of file OrderedList.hpp.
|
inlineexplicit |
Creates the structure.
compareFunc | a C++ 11 compliant function parameter that allows comparation between template objects |
Definition at line 28 of file OrderedList.hpp.
|
inlineexplicit |
create the structure and populate it with the data from the array
data | an array with data with which the structure will be initialized |
compareFunc | a C++ 11 compliant function parameter that allows comparation between template objects |
Definition at line 34 of file OrderedList.hpp.
|
inline |
Answers whether the ordered list contains an enemy.
val | the element to be found |
Definition at line 81 of file OrderedList.hpp.
|
inlinevirtual |
Get the element at the specified position in the list, without removing it.
index | index of the desired element |
Reimplemented from LinkedList< T >.
Definition at line 89 of file OrderedList.hpp.
|
inlinevirtual |
Provides the name of the data structure as a string representation.
Reimplemented from LinkedList< T >.
Definition at line 22 of file OrderedList.hpp.
|
inline |
Finds an element in the ordered list and returns its index.
val | the element to be found |
Definition at line 65 of file OrderedList.hpp.
|
inlinevirtual |
Insert an element at its position on the list.
val | the value to be inserted |
Reimplemented from LinkedList< T >.
Definition at line 43 of file OrderedList.hpp.
|
inlinevirtual |
Insert an element at the specified position in the list.
val | the value to be inserted |
index | position of the list that the element will be inserted on |
Reimplemented from LinkedList< T >.
Definition at line 58 of file OrderedList.hpp.
|
inlinevirtual |
Remove an element from the list.
index | position of the element to be removed |
Reimplemented from LinkedList< T >.
Definition at line 85 of file OrderedList.hpp.
|
private |
Definition at line 19 of file OrderedList.hpp.