rtxArrayList.h File Reference

ArrayList functions. More...

#include "rtxsrc/rtxContext.h"

Go to the source code of this file.

Functions

EXTERNRT void rtxArrayListInit (OSRTArrayList *pArrayList, OSSIZE capacity)
 This function initializes an array list structure.
EXTERNRT OSRTArrayList * rtxNewArrayList (OSCTXT *pctxt, OSSIZE capacity)
 This function creates a new array list to hold the initial capacity of elements.
EXTERNRT void rtxFreeArrayList (OSCTXT *pctxt, OSRTArrayList *pArrayList)
 This function frees all dynamic memory held by the array list.
EXTERNRT int rtxArrayListAdd (OSCTXT *pctxt, OSRTArrayList *pArrayList, void *pdata, OSSIZE *pindex)
 This function adds an element to an array list.
EXTERNRT void rtxArrayListRemove (OSCTXT *pctxt, OSRTArrayList *pArrayList, void *pdata)
 This function removes an element from an array list.
EXTERNRT void rtxArrayListRemoveIndexed (OSCTXT *pctxt, OSRTArrayList *pArrayList, OSSIZE idx)
 This function removes the element at the given index from the array list.
EXTERNRT int rtxArrayListInsert (OSCTXT *pctxt, OSRTArrayList *pArrayList, void *pdata, OSSIZE idx)
 This function inserts an element at the given position in the array list.
EXTERNRT int rtxArrayListReplace (OSRTArrayList *pArrayList, void *pdata, OSSIZE idx)
 This function replaces (overwrites) the element at the given position in the array list with the new element.
EXTERNRT void * rtxArrayListGetIndexed (const OSRTArrayList *pArrayList, OSSIZE idx)
 This function gets the indexed data item from the array list.
EXTERNRT int rtxArrayListIndexOf (OSRTArrayList *pArrayList, void *pdata)
 This function returns the index of the given data item in the list.
EXTERNRT int rtxArrayListInitIter (OSRTArrayListIter *piter, const OSRTArrayList *pArrayList, OSSIZE startIndex)
 This function initializes an array list iterator with the given start index.
EXTERNRT OSBOOL rtxArrayListHasNextItem (OSRTArrayListIter *piter)
 This function determines if another element exists at the next sequential position in the array list.
EXTERNRT void * rtxArrayListNextItem (OSRTArrayListIter *piter)
 This function gets the next item from the array list.

Detailed Description

ArrayList functions.

Definition in file rtxArrayList.h.


Function Documentation

EXTERNRT int rtxArrayListAdd ( OSCTXT pctxt,
OSRTArrayList *  pArrayList,
void *  pdata,
OSSIZE *  pindex 
)

This function adds an element to an array list.

Parameters:
pctxt Pointer to a context structure.
pArrayList Pointer to array list structure to initialize.
pdata Pointer to data item to add.
pindex Pointer to index variable to receive index at which entry was added.
Returns:
Zero if item was successfully added; a negative status code if error.
EXTERNRT void* rtxArrayListGetIndexed ( const OSRTArrayList *  pArrayList,
OSSIZE  idx 
)

This function gets the indexed data item from the array list.

Parameters:
pArrayList Pointer to array list structure to initialize.
idx Index of location where item should be inserted.
Returns:
Pointer to indexed data item or NULL if index is greater than max index in list.
EXTERNRT OSBOOL rtxArrayListHasNextItem ( OSRTArrayListIter *  piter  ) 

This function determines if another element exists at the next sequential position in the array list.

Parameters:
piter Pointer to array list iterator structure.
Returns:
True if another element exists; false otherwise.
EXTERNRT int rtxArrayListIndexOf ( OSRTArrayList *  pArrayList,
void *  pdata 
)

This function returns the index of the given data item in the list.

The 'equals' callback function is used to do comparisons.

Parameters:
pArrayList Pointer to array list structure to initialize.
pdata Pointer to data item to find in list.
Returns:
Index of item in list or -1 if not found.
EXTERNRT void rtxArrayListInit ( OSRTArrayList *  pArrayList,
OSSIZE  capacity 
)

This function initializes an array list structure.

Parameters:
pArrayList Pointer to array list structure to initialize.
capacity Initial capacity of the array or zero to use default.
EXTERNRT int rtxArrayListInitIter ( OSRTArrayListIter *  piter,
const OSRTArrayList *  pArrayList,
OSSIZE  startIndex 
)

This function initializes an array list iterator with the given start index.

Parameters:
piter Pointer to array list iterator structure.
pArrayList Pointer to array list structure.
startIndex Index from which iteration is to start.
Returns:
Zero if successfully initialized or RTERR_OUTOFBND if start index is beyond the current size of the array list.
EXTERNRT int rtxArrayListInsert ( OSCTXT pctxt,
OSRTArrayList *  pArrayList,
void *  pdata,
OSSIZE  idx 
)

This function inserts an element at the given position in the array list.

Parameters:
pctxt Pointer to a context structure.
pArrayList Pointer to array list structure to initialize.
pdata Pointer to data item to insert.
idx Index of location where item should be inserted.
Returns:
Zero if item was successfully added; a negative status code if error.
EXTERNRT void* rtxArrayListNextItem ( OSRTArrayListIter *  piter  ) 

This function gets the next item from the array list.

Parameters:
piter Pointer to array list iterator structure.
Returns:
Pointer to next item or null if beyond the end of the array.
EXTERNRT void rtxArrayListRemove ( OSCTXT pctxt,
OSRTArrayList *  pArrayList,
void *  pdata 
)

This function removes an element from an array list.

Parameters:
pctxt Pointer to a context structure.
pArrayList Pointer to array list structure to initialize.
pdata Pointer to data item to remove.
EXTERNRT void rtxArrayListRemoveIndexed ( OSCTXT pctxt,
OSRTArrayList *  pArrayList,
OSSIZE  idx 
)

This function removes the element at the given index from the array list.

Parameters:
pctxt Pointer to a context structure.
pArrayList Pointer to array list structure to initialize.
idx Index of item to remove. -1 indicates tail item should be removed.
EXTERNRT int rtxArrayListReplace ( OSRTArrayList *  pArrayList,
void *  pdata,
OSSIZE  idx 
)

This function replaces (overwrites) the element at the given position in the array list with the new element.

Parameters:
pArrayList Pointer to array list structure to initialize.
pdata Pointer to data item to insert.
idx Index of location where item should be inserted.
Returns:
Zero if item was successfully added; a negative status code if error.
EXTERNRT void rtxFreeArrayList ( OSCTXT pctxt,
OSRTArrayList *  pArrayList 
)

This function frees all dynamic memory held by the array list.

It does not free the array list structure itself, just the internal data array.

Parameters:
pctxt Pointer to a context structure.
pArrayList Pointer to array list structure.
EXTERNRT OSRTArrayList* rtxNewArrayList ( OSCTXT pctxt,
OSSIZE  capacity 
)

This function creates a new array list to hold the initial capacity of elements.

Parameters:
pctxt Pointer to a context structure.
capacity Initial capacity of the array or zero to use default.
Returns:
Allocated array list structure or NULL if insufficient dynamic memory is available to hold the structure.