4
** The list object is a generic container for storing collections
14
typedef struct _HTList HTList;
22
/* Fast macro to traverse a list. Call it first with copy of the list
23
** header. It returns the first object and increments the passed list
24
** pointer. Call it with the same variable until it returns NULL.
26
#define HTList_nextObject(me) \
27
((me) && ((me) = (me)->next) ? (me)->object : NULL)
30
/* Macro to find object pointed to by the head (returns NULL
31
** if list is empty, OR if it doesn't exist - Yuk!)
33
#define HTList_lastObject(me) \
34
((me) && (me)->next ? (me)->next->object : NULL)
37
/* Macro to check if a list is empty (or doesn't exist - Yuk!)
39
#define HTList_isEmpty(me) ((me) ? ((me)->next == NULL) : YES)
44
extern HTList * HTList_new NOPARAMS;
49
extern void HTList_delete PARAMS((
54
extern HTList * HTList_reverse PARAMS((
57
/* Append two lists, making second list empty.
59
extern HTList * HTList_appendList PARAMS((
64
/* Add object to START of list (so it is pointed to by the head).
66
extern void HTList_addObject PARAMS((
71
/* Append object to END of list (furthest from the head).
73
extern void HTList_appendObject PARAMS((
78
/* Insert an object into the list at a specified position.
79
** If position is 0, this places the object at the head of the list
80
** and is equivalent to HTList_addObject().
82
extern void HTList_insertObjectAt PARAMS((
88
/* Remove specified object from list.
90
extern BOOL HTList_removeObject PARAMS((
95
/* Remove object at a given position in the list, where 0 is the
96
** object pointed to by the head (returns a pointer to the element
97
** (->object) for the object, and NULL if the list is empty, or
98
** if it doesn't exist - Yuk!).
100
extern void * HTList_removeObjectAt PARAMS((
105
/* Remove object from START of list (the Last one inserted
106
** via HTList_addObject(), and pointed to by the head).
108
extern void * HTList_removeLastObject PARAMS((
112
/* Remove object from END of list (the First one inserted
113
** via HTList_addObject(), and furthest from the head).
115
extern void * HTList_removeFirstObject PARAMS((
119
/* Determine total number of objects in the list,
120
** not counting the head.
122
extern int HTList_count PARAMS((
126
/* Determine position of an object in the list (a value of 0
127
** means it is pointed to by the head; returns -1 if not found).
129
extern int HTList_indexOf PARAMS((
134
/* Return pointer to the object at a specified position in the list,
135
** where 0 is the object pointed to by the head (returns NULL if
136
** the list is empty, or if it doesn't exist - Yuk!).
138
extern void * HTList_objectAt PARAMS((
142
/* Link object to START of list (so it is pointed to by the head).
144
* Unlike HTList_addObject(), it does not malloc memory for HTList entry,
145
* it use already allocated memory which should not be free'd by any
146
* list operations (optimization).
148
extern void HTList_linkObject PARAMS((
153
/* Unlink object from START of list (the Last one inserted
154
* via HTList_linkObject(), and pointed to by the head).
155
* It does not free memory.
157
extern void * HTList_unlinkLastObject PARAMS((
160
/* Unlink specified object from list.
161
* It does not free memory.
163
extern BOOL HTList_unlinkObject PARAMS((
167
#endif /* HTLIST_H */