XBinder  Version 2.6.x
rtxArrayList.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2014-2018 Objective Systems, Inc.
3  *
4  * This software is furnished under a license and may be used and copied
5  * only in accordance with the terms of such license and with the
6  * inclusion of the above copyright notice. This software or any other
7  * copies thereof may not be provided or otherwise made available to any
8  * other person. No title to and ownership of the software is hereby
9  * transferred.
10  *
11  * The information in this software is subject to change without notice
12  * and should not be construed as a commitment by Objective Systems, Inc.
13  *
14  * PROPRIETARY NOTICE
15  *
16  * This software is an unpublished work subject to a confidentiality agreement
17  * and is protected by copyright and trade secret law. Unauthorized copying,
18  * redistribution or other use of this work is prohibited.
19  *
20  * The above notice of copyright on this source code product does not indicate
21  * any actual or intended publication of such source code.
22  *
23  *****************************************************************************/
28 #ifndef _RTXARRAYLIST_H_
29 #define _RTXARRAYLIST_H_
30 
31 #include "rtxsrc/rtxContext.h"
32 
33 #define OSRT_ARRAYLIST_CAPACITY 10
34 
35 typedef struct _OSRTArrayList {
36  OSRTDList segments;
37  OSSIZE segmentSize;
38  OSSIZE size;
39  OSSIZE dataSize;
40  OSBOOL (*equalsFunc)(void*,void*,OSSIZE);
41 } OSRTArrayList;
42 
43 typedef struct _OSRTArrayListIter {
44  const OSRTArrayList* pArrayList;
45  OSRTDListNode* pSegment;
46  OSSIZE index;
47 } OSRTArrayListIter;
48 
49 /* Iteration is done as follows:
50  * rtxArrayListInitIter (&iter, &arrayList, 0);
51  * while (rtxArrayListHasNextItem (&iter)) {
52  * pdata = rtxArrayListNextItem (&iter);
53  * ...
54  */
55 #ifdef __cplusplus
56 extern "C" {
57 #endif
58 
65 EXTERNRT void rtxArrayListInit
66 (OSRTArrayList* pArrayList, OSSIZE capacity);
67 
77 EXTERNRT OSRTArrayList* rtxNewArrayList (OSCTXT* pctxt, OSSIZE capacity);
78 
86 EXTERNRT void rtxFreeArrayList (OSCTXT* pctxt, OSRTArrayList* pArrayList);
87 
99 EXTERNRT int rtxArrayListAdd
100 (OSCTXT* pctxt, OSRTArrayList* pArrayList, void* pdata, OSSIZE* pindex);
101 
109 EXTERNRT void rtxArrayListRemove
110 (OSCTXT* pctxt, OSRTArrayList* pArrayList, void* pdata);
111 
120 EXTERNRT void rtxArrayListRemoveIndexed
121 (OSCTXT* pctxt, OSRTArrayList* pArrayList, OSSIZE idx);
122 
133 EXTERNRT int rtxArrayListInsert
134 (OSCTXT* pctxt, OSRTArrayList* pArrayList, void* pdata, OSSIZE idx);
135 
146 EXTERNRT int rtxArrayListReplace
147 (OSRTArrayList* pArrayList, void* pdata, OSSIZE idx);
148 
157 EXTERNRT void* rtxArrayListGetIndexed
158 (const OSRTArrayList* pArrayList, OSSIZE idx);
159 
168 EXTERNRT int rtxArrayListIndexOf (OSRTArrayList* pArrayList, void* pdata);
169 
170 /* Iteration */
171 
183 EXTERNRT int rtxArrayListInitIter (OSRTArrayListIter* piter,
184  const OSRTArrayList* pArrayList, OSSIZE startIndex);
185 
193 EXTERNRT OSBOOL rtxArrayListHasNextItem (OSRTArrayListIter* piter);
194 
202 EXTERNRT void* rtxArrayListNextItem (OSRTArrayListIter* piter);
203 
204 #ifdef __cplusplus
205 }
206 #endif
207 
208 #endif
EXTERNRT void rtxArrayListRemoveIndexed(OSCTXT *pctxt, OSRTArrayList *pArrayList, OSSIZE idx)
This function removes the element at the given index from the array list.
EXTERNRT OSRTArrayList * rtxNewArrayList(OSCTXT *pctxt, OSSIZE capacity)
This function creates a new array list to hold the initial capacity of elements.
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.
This is the main list structure.
Definition: rtxDList.h:64
EXTERNRT OSBOOL rtxArrayListHasNextItem(OSRTArrayListIter *piter)
This function determines if another element exists at the next sequential position in the array list...
Common run-time context definitions.
EXTERNRT void * rtxArrayListNextItem(OSRTArrayListIter *piter)
This function gets the next item from the array list.
EXTERNRT void rtxFreeArrayList(OSCTXT *pctxt, OSRTArrayList *pArrayList)
This function frees all dynamic memory held by the array list.
This structure is used to hold a single data item within the list.
Definition: rtxDList.h:52
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 rtxArrayListInitIter(OSRTArrayListIter *piter, const OSRTArrayList *pArrayList, OSSIZE startIndex)
This function initializes an array list iterator with the given start index.
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.
Run-time context structure.
Definition: rtxContext.h:185
EXTERNRT void rtxArrayListInit(OSRTArrayList *pArrayList, OSSIZE capacity)
This function initializes an array list structure.
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 ...