Main Page | Modules | Alphabetical List | Data Structures | Directories | File List | Data Fields | Globals

Array


Files

file  psArray.h
 Contains basic array definitions and operations.

Data Structures

struct  psArray
 An array to support primitive types. More...

Functions

bool psMemCheckArray (psPtr ptr)
 Checks the type of a particular pointer.
psArraypsArrayAlloc (long nalloc)
 Allocate an array.
psArraypsArrayRealloc (psArray *array, long nalloc)
 Reallocate an array.
psArraypsArrayAdd (psArray *array, long delta, psPtr data)
 Add an element to the end the array, expanding the array storage if necessary.
bool psArrayRemove (psArray *array, const psPtr data)
 Remove an element from the array.
void psArrayElementFree (psArray *psArr)
 Deallocate/Dereference elements of an array.
psArraypsArraySort (psArray *array, psComparePtrFunc func)
 Sort the array according to an external compare function.
bool psArraySet (psArray *array, long position, psPtr data)
 Set an element in the array.
psPtr psArrayGet (const psArray *array, long position)
 Get an element from the array.


Function Documentation

psArray* psArrayAdd psArray array,
long  delta,
psPtr  data
 

Add an element to the end the array, expanding the array storage if necessary.

Returns:
psArray* The array with the element added
Parameters:
array  array to operate on
delta  the amount to expand array, if necessary. If less than one, 10 will be used.
data  the data pointer to add to psArray

psArray* psArrayAlloc long  nalloc  ) 
 

Allocate an array.

Uses psLib memory allocation functions to create an array collection of data

Returns:
psArray* : Pointer to psArray.
Parameters:
nalloc  Total number of elements to make available.

void psArrayElementFree psArray psArr  ) 
 

Deallocate/Dereference elements of an array.

Uses psLib memory allocation functions to deallocate/dereference elements of a array of void pointers. The array psArr is not freed, and its elements will all be set to NULL.

Parameters:
psArr  Void pointer array to destroy.

psPtr psArrayGet const psArray array,
long  position
 

Get an element from the array.

Returns:
void* the element at given position.
Parameters:
array  input array to get element from
position  the element position to get

psArray* psArrayRealloc psArray array,
long  nalloc
 

Reallocate an array.

Uses psLib memory allocation functions to reallocate an array collection of data.

Returns:
psArray* : Pointer to psArray.
Parameters:
array  array to reallocate.
nalloc  Total number of elements to make available.

bool psArrayRemove psArray array,
const psPtr  data
 

Remove an element from the array.

Finds and removes the specified data pointer from the list.

Returns:
bool: TRUE if the specified data pointer was found and removed, otherwise FALSE.
Parameters:
array  array to operate on
data  the data pointer to remove from psArray

bool psArraySet psArray array,
long  position,
psPtr  data
 

Set an element in the array.

If the current element is non-NULL, the old element is freed.

Returns:
psBool TRUE if the element was set successfully, otherwise FALSE
Parameters:
array  input array to set element in
position  the element position to set
data  the value to set it to

psArray* psArraySort psArray array,
psComparePtrFunc  func
 

Sort the array according to an external compare function.

Sorts an array via the specification of a comparison function to specify how the objects on the array should be sorted.

The comparison function must return an integer less than, equal to, or greater than zero if the first argument is considered to be respectively less than, equal to, or greater than the second.

If two members compare as equal, their order in the sorted array is undefined.

Returns:
psArray* The sorted array.
Parameters:
array  input array to sort.
func  the compare function

bool psMemCheckArray psPtr  ptr  ) 
 

Checks the type of a particular pointer.

Uses the appropriate deallocation function in psMemBlock to check the ptr datatype.

Returns:
bool: True if the pointer matches a psArray structure, false otherwise.
Parameters:
ptr  the pointer whose type to check


Generated on Wed Sep 14 10:43:48 2005 for Pan-STARRS Foundation Library by  doxygen 1.4.2