Go to the source code of this file.
Classes | |
struct | adt_Array_t |
Array container class. More... | |
Defines | |
#define | ADT_ERROR (-1) |
Typedefs | |
typedef adt_Array_t | adt_Array |
Array container class. | |
Functions | |
adt_Array * | adt_createArray (int elemsz, int len, void *buffer) |
Constructor. | |
void | adt_destroyArray (adt_Array *) |
Destructor. | |
int | adt_getLengthArray (adt_Array *) |
Returns length of array. | |
int | adt_getElemsizeArray (adt_Array *) |
Returns array element size in bytes. | |
void * | adt_getDataArray (adt_Array *) |
Returns pointer to array buffer space. | |
void * | adt_indexArray (adt_Array *, int index) |
Index the array. | |
int | adt_updateArray (adt_Array *, int index, void *pelem) |
Update an array element. | |
int | adt_resizeArray (adt_Array *, int len) |
Resize the array. | |
int | adt_initializeArray (adt_Array *, int elemsz, int len, void *buffer) |
Alternative constructor. | |
void | adt_cleanupArray (adt_Array *) |
Alternative destructor. |
adt_Array
class provides a container for generic one-dimensional arrays whose length can be resized. Access routines perform error-checking on the index bounds. The array buffer space is by default dynamically allocated, but it is also possible to pass preallocated buffer space to be accessed, however a preallocated buffer cannot be resized.
Functions returning int
generally indicate success by returning 0 and failure by returning ADT_ERROR
. The access functions that accept an array index will terminate the program if the index is out-of-range. This means that error-checking is necessary only for calls to the constructor adt_createArray()
(or alternatively adt_initializeArray()
) and to the resize function adt_resizeArray()
.
|
Return value from failed function call. |
|
Array container class. Members should be treated as private. |
|
Alternative destructor.
Use to destroy a preallocated array object (i.e. one constructed using |
|
Constructor. Creates dynamically allocated array object.
buffer is NULL , then the array buffer space is dynamically allocated and can be resized.
If
|
|
Destructor. Frees dynamically allocated buffer space and dynamically allocated array object. |
|
Returns pointer to array buffer space.
This permits direct access of array data for efficiency. Note that resizing the array will most likely change the memory location of the buffer, invalidating earlier calls to this function. |
|
Index the array.
index length. An index out-of-range will terminate program with error message.
|
|
Alternative constructor.
Use to construct a preallocated array object. See |
|
Resize the array.
len . Fails if memory allocation is not possible. (Terminates program as a bug if len is illegal or if an attempt is made to resize a user-provided buffer.)
|
|
Update an array element.
index length. An index out-of-range will terminate program with error message.
Performs a deep copy of the value located at
|