qLibc
|
Vector container implementation. More...
Go to the source code of this file.
Functions | |
static void * | get_at (qvector_t *vector, int index, bool newmem) |
static bool | remove_at (qvector_t *vector, int index) |
qvector_t * | qvector (size_t max, size_t objsize, int options) |
Create new qvector_t container. | |
bool | qvector_addfirst (qvector_t *vector, const void *data) |
qvector->addfirst(): Insert a element at the beginning of this vector. | |
bool | qvector_addlast (qvector_t *vector, const void *data) |
qvector->addlast(): Insert a element at the end of this vector. | |
void * | qvector_getfirst (qvector_t *vector, bool newmem) |
qvector->addat(): Inserts a element at the specified position in this vector. | |
void * | qvector_getlast (qvector_t *vector, bool newmem) |
qvector->getlast(): Returns the last element in this vector. | |
void * | qvector_getat (qvector_t *vector, int index, bool newmem) |
qvector->getat(): Returns the element at the specified position in this vector. | |
bool | qvector_setfirst (qvector_t *vector, const void *data) |
qvector->setfirst(): Set the first element with a new value in this vector. | |
bool | qvector_setlast (qvector_t *vector, const void *data) |
qvector->setlast(): Set the last element with a new value in this vector. | |
bool | qvector_setat (qvector_t *vector, int index, const void *data) |
qvector->setat(): Set new value to the specified position in this vector. | |
void * | qvector_popfirst (qvector_t *vector) |
qvector->popfirst(): Returns and remove the first element in this vector. | |
void * | qvector_poplast (qvector_t *vector) |
qvector->poplast(): Returns the last element of this vector. | |
void * | qvector_popat (qvector_t *vector, int index) |
qvector->popat(): Returns and remove the element at specified position in this vector. | |
bool | qvector_removefirst (qvector_t *vector) |
qvector->removefirst(): Removes the first element in this vector. | |
bool | qvector_removelast (qvector_t *vector) |
qvector->removelast(): Removes the last element in this vector. | |
bool | qvector_removeat (qvector_t *vector, int index) |
qvector->removeat(): Removes the element at the specified position in this vector. | |
size_t | qvector_size (qvector_t *vector) |
qvector->size(): Get the number of elements in this vector. | |
void | qvector_lock (qvector_t *vector) |
qvector->lock(): Enters critical section. | |
void | qvector_unlock (qvector_t *vector) |
qvector->unlock(): Leaves critical section. | |
void | qvector_clear (qvector_t *vector) |
qvector->clear(): Remove all the elemnts in this vector. | |
void | qvector_free (qvector_t *vector) |
qvector->free(): Free this vector. | |
bool | qvector_debug (qvector_t *vector, FILE *out) |
qvector->debug(): Prints out stored elements for debugging purpose. | |
bool | qvector_resize (qvector_t *vector, size_t newmax) |
qvector->resize(): Changes the allocated memory space size. | |
void * | qvector_toarray (qvector_t *vector, size_t *size) |
qvector->toarray(): Returns an array contains all the elements in this vector. | |
void | qvector_reverse (qvector_t *vector) |
qvector->reverse(): Reverse the order of element in this vector. | |
bool | qvector_getnext (qvector_t *vector, qvector_obj_t *obj, bool newmem) |
qvector->getnext(): Get next element in this vector. | |
Vector container implementation.
qvector container is a vector container implementation qvector provides uniformly named methods to add, get, pop and remove an element at the beginning and end of the vector.
Definition in file qvector.c.
qvector_t * qvector | ( | size_t | max, |
size_t | objsize, | ||
int | options | ||
) |
Create new qvector_t container.
max | max number of elements |
objsize | size of each element |
options | combination of initialization options. |
errno | will be set in error condition.
|
bool qvector_addfirst | ( | qvector_t * | vector, |
const void * | data | ||
) |
qvector->addfirst(): Insert a element at the beginning of this vector.
vector | qvector_t container pointer. |
data | a pointer which points data memory |
errno | will be set in error condition. |
bool qvector_addlast | ( | qvector_t * | vector, |
const void * | data | ||
) |
qvector->addlast(): Insert a element at the end of this vector.
vector | qvector_t container pointer. |
data | a pointer which points data memory |
errno | will be set in error condition. |
void * qvector_getfirst | ( | qvector_t * | vector, |
bool | newmem | ||
) |
qvector->addat(): Inserts a element at the specified position in this vector.
vector | qvector_t container pointer |
index | index at which the specified element is to be inserted |
data | a pointer which points data memory |
errno | will be set in errno condition. |
void * qvector_getlast | ( | qvector_t * | vector, |
bool | newmem | ||
) |
qvector->getlast(): Returns the last element in this vector.
vector | qvector_t container pointer. |
newmem | whether or not to allocate memory for the element. |
errno | will be set in error condition.
|
void * qvector_getat | ( | qvector_t * | vector, |
int | index, | ||
bool | newmem | ||
) |
qvector->getat(): Returns the element at the specified position in this vector.
vector | qvector_t container pointer. |
index | index at which the specified element is to access. |
newmem | whether or not to allocate memory for the element. |
errno | will be set in error condition.
|
bool qvector_setfirst | ( | qvector_t * | vector, |
const void * | data | ||
) |
qvector->setfirst(): Set the first element with a new value in this vector.
vector | qvector_t container pointer. |
data | the pointer of new value. |
errno | will be set in error condition.
|
bool qvector_setlast | ( | qvector_t * | vector, |
const void * | data | ||
) |
qvector->setlast(): Set the last element with a new value in this vector.
vector | qvector_t container pointer. |
data | the pointer of new value. |
errno | will be set in error condition.
|
bool qvector_setat | ( | qvector_t * | vector, |
int | index, | ||
const void * | data | ||
) |
qvector->setat(): Set new value to the specified position in this vector.
vector | qvector_t container pointer |
index | index at which the specifed element is to set |
data | the pointer of new value to be set |
errno | will be set in error condition.
|
void * qvector_popfirst | ( | qvector_t * | vector | ) |
qvector->popfirst(): Returns and remove the first element in this vector.
vector | qvector_t container pointer. |
errno | will be set in error condition.
|
void * qvector_poplast | ( | qvector_t * | vector | ) |
qvector->poplast(): Returns the last element of this vector.
vector | qvector_t container pointer. |
errno | will be set in error condition.
|
void * qvector_popat | ( | qvector_t * | vector, |
int | index | ||
) |
qvector->popat(): Returns and remove the element at specified position in this vector.
vector | qvector_t container pointer. |
index | index at which the specified element is to be poped. |
errno | will be set in error condition.
|
bool qvector_removefirst | ( | qvector_t * | vector | ) |
bool qvector_removelast | ( | qvector_t * | vector | ) |
bool qvector_removeat | ( | qvector_t * | vector, |
int | index | ||
) |
qvector->removeat(): Removes the element at the specified position in this vector.
vector | qvector_t container pointer. |
index | index at which the specified element is to be removed. |
errno | will be set in error condition.
|
size_t qvector_size | ( | qvector_t * | vector | ) |
void qvector_lock | ( | qvector_t * | vector | ) |
void qvector_unlock | ( | qvector_t * | vector | ) |
void qvector_clear | ( | qvector_t * | vector | ) |
void qvector_free | ( | qvector_t * | vector | ) |
bool qvector_debug | ( | qvector_t * | vector, |
FILE * | out | ||
) |
qvector->debug(): Prints out stored elements for debugging purpose.
vector | qvector_t container pointer. |
out | output stream FILE descriptor such like stdout, stderr. |
errno | will be set in error condition.
|
bool qvector_resize | ( | qvector_t * | vector, |
size_t | newmax | ||
) |
qvector->resize(): Changes the allocated memory space size.
vector | qvector_t container pointer. |
newsize | the new max number of elements. |
errno | will be set in error condition.
|
void * qvector_toarray | ( | qvector_t * | vector, |
size_t * | size | ||
) |
qvector->toarray(): Returns an array contains all the elements in this vector.
vector | qvector_t container pointer. |
size | if size is not NULL, the number of elements will be stored. |
errno | wil be set in error condition.
|
void qvector_reverse | ( | qvector_t * | vector | ) |
bool qvector_getnext | ( | qvector_t * | vector, |
qvector_obj_t * | obj, | ||
bool | newmem | ||
) |
qvector->getnext(): Get next element in this vector.
vector | qvector_t container pointer. |
obj | found data will be stored in this structure. |
newmem | whether or not to allocate memory for element. |
errno | will be set in error condition.
|