vector.h| Type | |
| This type defines the abstract vector type. | |
| Functions | |
Returns an empty Vector. | |
| Frees the storage associated with vector. | |
Creates a vector from an array of void * pointers. | |
Returns a NULL-terminated array with the same elements as vector. | |
Returns true if the vector is empty. | |
| Returns the number of elements in the vector. | |
| Removes all elements from the vector. | |
| Creates a copy of the vector. | |
| Gets the element at the specified index position, raising an error if the index is out of range. | |
| Sets the element at the specified index position, raising an error if the index is out of range. | |
| Adds a new value to the end of the vector. | |
| Inserts a new value before the specified index position. | |
| Deletes the element at the specified index position. | |
typedef struct VectorCDT *Vector;
Vector newVector(void);
Vector.
Usage:
vector = newVector();
void freeVector(Vector vector);
Usage:
freeVector(vector);
Vector arrayToVector(void *array[], int n);
void * pointers.
If the array argument is NULL, this
function returns NULL.
Usage:
vector = arrayToVector(array, n);
void **vectorToArray(Vector vector);
NULL-terminated array with the same
elements as vector. If vector is NULL, this
function returns NULL.
Usage:
array = vectorToArray(vector);
bool isEmpty(Vector vector);
true if the vector is empty.
Usage:
if (isEmpty(vector)) . . .
int size(Vector vector);
Usage:
n = size(vector);
void clear(Vector vector);
Usage:
clear(vector);
Vector clone(Vector vector);
clone function copies
only the first level of the structure and does not copy the individual
elements.
Usage:
newvec = clone(vector);
void *get(Vector vector, int index);
Usage:
value = get(vector, index);
void set(Vector vector, int index, void *value);
Usage:
set(vector, index, value);
void add(Vector vector, void *value);
Usage:
add(vector, value);
void insert(Vector vector, int index, void *value);
Usage:
insert(vector, index, value);
void remove(Vector vector, int index);
Usage:
remove(vector, index);