rtxArrayList.h

Go to the documentation of this file.
00001 /*
00002  * Copyright (c) 2010 Objective Systems, Inc.
00003  *
00004  * This software is furnished under a license and may be used and copied
00005  * only in accordance with the terms of such license and with the
00006  * inclusion of the above copyright notice. This software or any other
00007  * copies thereof may not be provided or otherwise made available to any
00008  * other person. No title to and ownership of the software is hereby
00009  * transferred.
00010  *
00011  * The information in this software is subject to change without notice
00012  * and should not be construed as a commitment by Objective Systems, Inc.
00013  *
00014  * PROPRIETARY NOTICE
00015  *
00016  * This software is an unpublished work subject to a confidentiality agreement
00017  * and is protected by copyright and trade secret law.  Unauthorized copying,
00018  * redistribution or other use of this work is prohibited.
00019  *
00020  * The above notice of copyright on this source code product does not indicate
00021  * any actual or intended publication of such source code.
00022  *
00023  *****************************************************************************/
00028 #ifndef _RTXARRAYLIST_H_
00029 #define _RTXARRAYLIST_H_
00030 
00031 #include "rtxsrc/rtxContext.h"
00032 
00033 #define OSRT_ARRAYLIST_CAPACITY 10
00034 
00035 typedef struct _OSRTArrayList {
00036    OSRTDList segments;
00037    size_t    segmentSize;
00038    size_t    size;
00039    size_t    dataSize;
00040    OSBOOL    (*equalsFunc)(void*,void*,size_t);
00041 } OSRTArrayList;
00042 
00043 typedef struct _OSRTArrayListIter {
00044    OSRTArrayList* pArrayList;
00045    OSRTDListNode* pSegment;
00046    OSUINT32       index;
00047 } OSRTArrayListIter;
00048 
00049 /* Iteration is done as follows:
00050  * rtxArrayListInitIter (&iter, &arrayList, 0);
00051  * while (rtxArrayListHasNextItem (&iter)) {
00052  *    pdata = rtxArrayListNextItem (&iter);
00053  *    ...
00054  */
00055 #ifdef __cplusplus
00056 extern "C" {
00057 #endif
00058 
00065 EXTERNRT void rtxArrayListInit
00066 (OSRTArrayList* pArrayList, size_t capacity);
00067 
00077 EXTERNRT OSRTArrayList* rtxNewArrayList (OSCTXT* pctxt, size_t capacity);
00078 
00086 EXTERNRT void rtxFreeArrayList (OSCTXT* pctxt, OSRTArrayList* pArrayList);
00087 
00099 EXTERNRT int rtxArrayListAdd
00100 (OSCTXT* pctxt, OSRTArrayList* pArrayList, void* pdata, OSUINT32* pindex);
00101 
00109 EXTERNRT void rtxArrayListRemove
00110 (OSCTXT* pctxt, OSRTArrayList* pArrayList, void* pdata);
00111 
00120 EXTERNRT void rtxArrayListRemoveIndexed
00121 (OSCTXT* pctxt, OSRTArrayList* pArrayList, int index);
00122 
00133 EXTERNRT int rtxArrayListInsert
00134 (OSCTXT* pctxt, OSRTArrayList* pArrayList, void* pdata, OSUINT32 index);
00135 
00146 EXTERNRT int rtxArrayListReplace
00147 (OSRTArrayList* pArrayList, void* pdata, OSUINT32 index);
00148 
00157 EXTERNRT void* rtxArrayListGetIndexed
00158 (const OSRTArrayList* pArrayList, OSUINT32 index);
00159 
00168 EXTERNRT int rtxArrayListIndexOf (OSRTArrayList* pArrayList, void* pdata);
00169 
00170 /* Iteration */
00171 
00183 EXTERNRT int rtxArrayListInitIter
00184 (OSRTArrayListIter* piter, OSRTArrayList* pArrayList, OSUINT32 startIndex);
00185 
00193 EXTERNRT OSBOOL rtxArrayListHasNextItem (OSRTArrayListIter* piter);
00194 
00202 EXTERNRT void* rtxArrayListNextItem (OSRTArrayListIter* piter);
00203 
00204 #ifdef __cplusplus
00205 }
00206 #endif
00207 
00208 #endif