array.h File Reference

Go to the source code of this file.

Data Structures

struct  ArrayStruct
 Array. More...

Defines

#define arrayCreate(n, type)   uArrayCreate(n,sizeof(type))
 Create an Array of n elements having type type.
#define arrayDestroy(a)   ((a) ? uArrayDestroy(a), a=NULL, 1 : 0)
 Destroy Array a.
#define arrayMax(ar)   ((ar)->max)
 Return the number of elements in the array.

Typedefs

typedef struct ArrayStructArray
 Array.

Functions

void arrayByteUniq (Array a)
 Remove byte-wise identical entries.
void arrayClear (Array a)
 Clear contents of Array a.
Array arrayCopy (Array a)
 Copies an Array a.
int arrayDoublecmp (double *dp1, double *dp2)
 Comparison function for doubles (double).
int arrayFind (Array a, void *s, int *ip, int(*order)(void *, void *))
 Finds Entry s from Array a sorted in ascending order of order().
int arrayFindInsert (Array a, void *s, int *ip, int(*order)(void *, void *))
 Try to find element s in Array a; insert it if not there.
int arrayIntcmp (int *ip1, int *ip2)
 Comparison function for integers (int).
int arrayIsEntry (Array a, int i, void *s)
 Check if s is an entry in a.
void arrayMove (Array from, int start, int end, Array to)
 Move elements from an Array to another Array.
int arrayNumber (void)
 Returns number of Arrays currently allocated.
int arrayRemove (Array a, void *s, int(*order)(void *, void *))
 Removes Entry s from Array a sorted in ascending order of order().
int arrayRemoveD (Array a, int i)
 Removes Entry with index i from Array a.
void arraySort (Array a, int(*order)(void *, void *))
 Sort an Array a according to order of order().
int arrayStrcmp (char **s1, char **s2)
 Comparison function for strings (char*).
void arrayUniq (Array a, Array b, int(*order)(void *, void *))


Detailed Description

Author:
Adapted by Lukas Habegger (lukas.habegger@yale.edu)

Definition in file array.h.


Function Documentation

void arrayByteUniq ( Array  a  ) 

Remove byte-wise identical entries.

Parameters:
[in] a Array sorted such that byte-wise identical entries are adjacent
[out] a Byte-wise identical duplicates removed
Note:
Byte-wise identical can be different from contents-wise

Use arrayUniq() for duplicate removal based on equality defined by order() function

Definition at line 259 of file array.c.

int arrayFind ( Array  a,
void *  s,
int *  ip,
int(*)(void *, void *)  order 
)

Finds Entry s from Array a sorted in ascending order of order().

Parameters:
[in] ip If NULL, then no output
[out] ip If ip is not NULL, then if found: sets *ip to index found; else: sets *ip one step left of expected index
Returns:
1 if found, else 0

Definition at line 385 of file array.c.

int arrayFindInsert ( Array  a,
void *  s,
int *  ip,
int(*)(void *, void *)  order 
)

Try to find element s in Array a; insert it if not there.

Parameters:
[in] ip Where to put the index value; if ip is NULL, the index value is not returned
[out] ip Index of s (where found or inserted)
Returns:
1 if inserted, 0 if found

Definition at line 494 of file array.c.

int arrayIsEntry ( Array  a,
int  i,
void *  s 
)

Check if s is an entry in a.

Returns:
TRUE if arru(a,i,) matches *s, else FALSE

Definition at line 365 of file array.c.

void arrayMove ( Array  from,
int  start,
int  end,
Array  to 
)

Move elements from an Array to another Array.

Move elements from[start..end] to to[m..m+end-start+1].

Parameters:
[in] from Array to cut elements out of
[in] start Start index in 'from'
[in] end End index in 'from'
[in] to Array to append cut elements to. NULL if this is not needed (only a good idea if elements don't own memory via pointers).
[out] from Elements removed; formerly used space. after end of data filled with binary zeros.
[out] to If not NULL: moved elements from 'from' appended.

Definition at line 207 of file array.c.

int arrayRemove ( Array  a,
void *  s,
int(*)(void *, void *)  order 
)

Removes Entry s from Array a sorted in ascending order of order().

Returns:
1 if found, else 0

Definition at line 442 of file array.c.

void arrayUniq ( Array  a,
Array  b,
int(*)(void *, void *)  order 
)

Parameters:
[in] a Array sorted by the same order function that is specified as the second argument
[in] b Array of same type as a, NULL ok (if one is not interested in getting the duplicates)
[out] a All duplicates which are identical according to the specified order function are moved to b
[out] b If not NULL: duplicates appended
Note:
If byte-wise equality is sufficient and array elements do not own memory outside the Array, one can use arrayByteUniq() instead of this function to save a few CPU cycles.

Definition at line 296 of file array.c.


Generated on Fri Aug 7 15:46:42 2009 for BIOS by  doxygen 1.5.7.1