CPPDescent 80d9539
(with uncommitted changes)
A C++ KNN-Graph creation library
|
#include <ADTVector.hpp>
Public Member Functions | |
Vector (int size, DestroyFunc destroyValue) | |
Construct a new Vector object. | |
~Vector () | |
Destroy the Vector object. | |
int | getSize () |
Get the current size of the Vector. | |
void | insertLast (Pointer value) |
Inserts a new element at the end of the vector. | |
int | removeLast () |
Removes the last element of the vector. | |
Pointer | getAt (int pos) |
Get the value at the specified position of the vector. | |
int | setAt (int pos, Pointer value) |
Set the value at the specified position of the vector. | |
Pointer | find (Pointer value, CompareFunc compare) |
Find the first element with value equal to value. | |
Pointer | binaryFind (Pointer value, CompareFunc compare) |
Find the element with value equal to value using binary search. | |
int | findPos (Pointer value, CompareFunc compare) |
Find the first element with value equal to value and return its pos. | |
DestroyFunc | setDestroyValue (DestroyFunc destroyValue) |
Set the Destroy Value. | |
vectorNode * | first () |
Get the first node of the vector. | |
vectorNode * | last () |
Get the last node of the vector. | |
vectorNode * | next (vectorNode *node) |
Get the next node of the vector, after the one given. | |
vectorNode * | previous (vectorNode *node) |
Get the previous node of the vector, before the one given. | |
Pointer | nodeValue (vectorNode *node) |
Get the value of the node. | |
vectorNode * | findNode (Pointer value, CompareFunc compare) |
Find the first node with value equal to value. | |
void | swap (int pos1, int pos2) |
Swaps the value that is saved in pos1 with the one in pos2. | |
Vector::Vector | ( | int | size, |
DestroyFunc | destroyValue | ||
) |
Pointer Vector::binaryFind | ( | Pointer | value, |
CompareFunc | compare | ||
) |
Find the element with value equal to value using binary search.
value | The value to look for. |
compare | The function to be used for comparison. |
Pointer Vector::find | ( | Pointer | value, |
CompareFunc | compare | ||
) |
Find the first element with value equal to value.
value | The value to look for. |
compare | The function to be used for comparison. |
vectorNode * Vector::findNode | ( | Pointer | value, |
CompareFunc | compare | ||
) |
Find the first node with value equal to value.
value | The value to look for. |
compare | The function to be used for comparison. |
int Vector::findPos | ( | Pointer | value, |
CompareFunc | compare | ||
) |
Find the first element with value equal to value and return its pos.
value | The value to look for. |
compare | The function to be used for comparison. |
vectorNode * Vector::first | ( | ) |
Get the first node of the vector.
Pointer Vector::getAt | ( | int | pos | ) |
Get the value at the specified position of the vector.
pos | The position to look for. |
void Vector::insertLast | ( | Pointer | value | ) |
Inserts a new element at the end of the vector.
value | The value of the new element. |
If we are at the last element, we create a new array double the size.
vectorNode * Vector::last | ( | ) |
Get the last node of the vector.
vectorNode * Vector::next | ( | vectorNode * | node | ) |
Get the next node of the vector, after the one given.
node | The node to get the next of. |
Pointer Vector::nodeValue | ( | vectorNode * | node | ) |
Get the value of the node.
node |
vectorNode * Vector::previous | ( | vectorNode * | node | ) |
Get the previous node of the vector, before the one given.
node | The node to get the previous of. |
int Vector::removeLast | ( | ) |
Removes the last element of the vector.
int Vector::setAt | ( | int | pos, |
Pointer | value | ||
) |
Set the value at the specified position of the vector.
pos | The position to edit. |
value | The new value. |
DestroyFunc Vector::setDestroyValue | ( | DestroyFunc | destroyValue | ) |
Set the Destroy Value.
destroyValue | The new destroy value function. |
void Vector::swap | ( | int | pos1, |
int | pos2 | ||
) |
Swaps the value that is saved in pos1 with the one in pos2.
pos1 | Index of the first element to be swaped. |
pos2 | Index of the second element to be swaped. |