summaryrefslogtreecommitdiffstats
path: root/kxsldbg/kxsldbgpart/libxsldbg/arraylist.h
blob: f625642961a5e613b5416cc50f777b794c302b20 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295

/**************************************************************************
                          arraylist.h  -  declare the functions for 
                                        implementation of the array list
                             -------------------
    begin                : Sat Nov 10 2001
    copyright            : (C) 2001 by Keith Isdale
    email                : [email protected]
 **************************************************************************/

/**************************************************************************
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 **************************************************************************/

#ifndef ARRAYLIST_H
#define ARRAYLIST_H

#ifdef HAVE_CONFIG_H
#include "config.h"
#endif

#ifdef USE_KDE_DOCS

/**
 * Provide a fast easy to use array list. Support the basic functions of add
 *  delete, empty, count, free
 *
 * @short Array list support
 *
 * @author Keith Isdale <[email protected]> 
 */
#endif

#ifdef __cplusplus
extern "C" {
#endif

#ifdef USE_GNOME_DOCS

#else
#ifdef USE_KDE_DOCS

#endif
#endif


    typedef void (*freeItemFunc) (void *item);
    /* A dynamic structure behave like a list */
    typedef struct _arrayList arrayList;
    typedef arrayList *arrayListPtr;
    struct _arrayList {
        int size, count;
        void **data;
        freeItemFunc deleteFunction;
    };

/* what size of the list do we stop automatic doubling of capacity
    if array list size growth is needed */
#define DOUBLE_SIZE_MAX_ITEM 10



#ifdef USE_GNOME_DOCS

/**
 * arrayListNew:
 * @initialSize: The initial size of list
 * @deleteFunction: The function to call to free items in the list
 *
 * Create a new list with a size of @initialSize
 *
 * Returns Non-null on success,
 *         NULL otherwise
 */
#else
#ifdef USE_KDE_DOCS

/**
 * Create a new list with a size of @p initialSize
 *
 * @returns Non-null on success,
 *          NULL otherwise
 *
 * @param initial The initial size of list
 * @param deleteFunction the Function to call to free items in the list
 */
#endif
#endif
    arrayListPtr arrayListNew(int initialSize,
                              freeItemFunc deleteFunction);



#ifdef USE_GNOME_DOCS

/**
 * arrayListFree:
 * @list: A valid list
 *
 * Free memory assocated with array list, if the array list 
 *   has a valid deleteFunction then content with be freed with 
 *    using that deleteFunction
 */
#else
#ifdef USE_KDE_DOCS

/**
 * Free memory assocated with array list, if the array list 
 *   has a valid deleteFunction then content with be freed with 
 *    using that deleteFunction
 *
 * @param list A valid list
 */
#endif
#endif
    void arrayListFree(arrayListPtr list);



#ifdef USE_GNOME_DOCS

/**
 * arrayListEmpty:
 * @list: A valid list
 *
 * Empties the list of its content
 *
 * Returns 1 on success,
 *         0 otherwise
 */
#else
#ifdef USE_KDE_DOCS

/**
 * Empties the list of its content
 *
 * @returns 1 on success,
 *          0 otherwise
 *
 * @param list A valid list
 */
#endif
#endif
    int arrayListEmpty(arrayListPtr list);



#ifdef USE_GNOME_DOCS

/**
 * arrayListSize:
 * @list: A valid list
 *
 * Return The maximum number elements this list can contain
 *
 * Returns The maximum number elements this list can contain
 */
#else
#ifdef USE_KDE_DOCS

/**
 * Return the maximum number elements this list can contain
 *
 * @returns The maximum number elements this list can contain
 *
 * @param list A valid list
 */
#endif
#endif
    int arrayListSize(arrayListPtr list);



#ifdef USE_GNOME_DOCS

/**
 * arrayListCount:
 * @list: A valid list
 *
 * Return the count of number items in list
 *
 * Returns The count of number items in list
 */
#else
#ifdef USE_KDE_DOCS

/**
 * Return the count of number items in list
 * @returns The count of number items in list
 *
 * @param list A valid list
 */
#endif
#endif

    int arrayListCount(arrayListPtr list);



#ifdef USE_GNOME_DOCS

/**
 * arrayListAdd:
 * @list: A valid list
 * @item:A valid item
 *
 * Add @item to @list
 *
 * Returns 1 if able to add @item to end of @list,
 *         0 otherwise
 */
#else
#ifdef USE_KDE_DOCS

/**
 * Add @p item to @p list
 *
 * @returns 1 if able to add @p item to end of @p list,
 *          0 otherwise
 *
 * @param list A valid list
 * @param item A valid item
 */
#endif
#endif
    int arrayListAdd(arrayListPtr list, void *item);



#ifdef USE_GNOME_DOCS

/**
 * arrayListDelete:
 * @list: A valid list
 * @position: 0 =< @position < arrayListCount(@list)
 *
 * Delete item at position @position from @list
 *
 * Returns 1 if able to delete element in @list at position @position,
 *         0 otherwise 
 */
#else
#ifdef USE_KDE_DOCS

/**
 * @returns 1 if able to delete element in @p list at position @p position,
 *          0 otherwise 
 *
 * @param list A valid list
 * @param position  0 =< @p position < arrayListCount(@p list)
 */
#endif
#endif
    int arrayListDelete(arrayListPtr list, int position);



#ifdef USE_GNOME_DOCS

/**
 * arrayListGet:
 * @list: A valid list
 * @position: 0 =< @position < arrayListCount(@list)
 *
 * Get item at position @position from @list
 *
 * Returns Non-null if able to retrieve element in @list at position
 *            @position,
 *         NULL otherwise
 */
#else
#ifdef USE_KDE_DOCS

/**
 * @returns Non-null if able to retrieve element in @p list at position
 *          @p position,
 *         NULL otherwise
 *
 * @param list A valid list
 * @param position  0 =< @p position < arrayListCount(@p list)
 */
#endif
#endif
    void *arrayListGet(arrayListPtr list, int position);


#ifdef __cplusplus
}
#endif
#endif