Main Page   Alphabetical List   Data Structures   File List   Data Fields   Globals   Examples  

s_array Struct Reference

Data structure that defines an array handler. More...


Data Fields

void * first_element
 Pointer to the first element of the array.

int array_size
 Size of the array (maximum number of elements).

int number_of_elements
 Current number of elements in the array.

int(* copy_data )(void *src, void *dest)
 User defined function used to copy data from/to the array.

int(* remove_data )(void *target)
 User defined function used to remove an element from the array (it may be necessary to free memory for example).

int(* compare )(void *d1, void *d2)
 User defined function used to compare two elements of the array.

void *(* index )(void *start, int idx)
 User defined function that returns a pointer to the element which index is idx.

int(* init_data )(void *data)
 User defined function used to initialize data (may be a NULL pointer if no initialization is required).

int element_to_remove
 Number of elements scheduled for removing.

int * to_remove
 Pointer to an array of integers that will receive the index to remove from the array. This array is allocated during the initialization of the array. You must free the memory using the function array_free().


Detailed Description

Data structure that defines an array handler.
Examples:

test_array.c.

Definition at line 10 of file array.h.


Field Documentation

int(* s_array::compare)(void *d1, void *d2)
 

User defined function used to compare two elements of the array.

Parameters:
d1 Pointer to the first element.
d2 Pointer to the second element.
Returns:
The function must return:
  • -1 if d1 < d2
  • 0 if d1 = d2
  • +1 if d1 > d2
  • -2 if an error occured.

Referenced by array_find(), and array_init().

int(* s_array::copy_data)(void *src, void *dest)
 

User defined function used to copy data from/to the array.

Parameters:
src Pointer to the data to copy.
dest Pointer to the destination.
Returns:
Upon successful completion the function returns 0, otherwise it returns 1.
Warning:
  • data is copied from src to dest.
  • The function copy_data() MUST take care of memory management (if required).

Referenced by array_add(), array_init(), array_insert(), and array_rem().

void*(* s_array::index)(void *start, int idx)
 

User defined function that returns a pointer to the element which index is idx.

Parameters:
start Pointer to the first element of the array.
idx Index of the element.
Returns:
The function returns a pointer to the element which index is idx.
Warning:
The gap between two elements of the array depends on the type of data stored.

Referenced by array_add(), array_find(), array_init(), array_init_element(), array_insert(), and array_rem().

int(* s_array::init_data)(void *data)
 

User defined function used to initialize data (may be a NULL pointer if no initialization is required).

Parameters:
data Pointer to the data to initialize.
Returns:
Upon successful completion the function returns 0, otherwise it returns 1

Referenced by array_init(), and array_init_element().

int(* s_array::remove_data)(void *target)
 

User defined function used to remove an element from the array (it may be necessary to free memory for example).

Parameters:
target Pointer to the element to remove.
Returns:
Upon successful completion the function returns 0, otherwise it returns 1.

Referenced by array_init(), and array_rem().


The documentation for this struct was generated from the following file:
Generated on Thu Apr 3 16:23:48 2003 for Common_C_libraries by doxygen1.3-rc1