2 * Copyright © 2002, 2003 Sun Microsystems, Inc.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
16 * 3. Neither the name of Sun Microsystems, Inc. nor the names of
17 * contributors may be used to endorse or promote products derived from
18 * this software without specific prior written permission.
20 * This software is provided "AS IS," without a warranty of any kind.
22 * ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES,
23 * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A
24 * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED.
25 * SUN AND ITS LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES OR
26 * LIABILITIES SUFFERED BY LICENSEE AS A RESULT OF OR RELATING TO USE,
27 * MODIFICATION OR DISTRIBUTION OF THE SOFTWARE OR ITS DERIVATIVES.
28 * IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE,
29 * PROFIT OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL,
30 * INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE
31 * THEORY OF LIABILITY, ARISING OUT OF THE USE OF OR INABILITY TO USE
32 * SOFTWARE, EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
37 /* @(#)list.h 1.6 03/02/06 SMI */
41 * @brief Bidirectional list class header file
42 * @author Alexander Gelfenbain
57 * List of void * pointers
60 typedef struct _list *list;
62 /*- constructors and a destructor */
63 list listNewEmpty(void);
64 list listNewCopy(list);
65 list listNewConcat(list, list); /* concatenates elements in two lists and creates a new list with them */
66 void listDispose(list);
67 void listSetElementDtor(list, GDestroyNotify f); /*- this function will be executed when the element is removed via listRemove() or listClear() */
70 list listCopy(list to, list from);
73 void * listCurrent(list);
75 int listIsEmpty(list);
76 int listAtFirst(list);
78 int listPosition(list); /* Expensive! */
81 int listFind(list, void *); /* Returns true/false */
83 /*- positioning functions */
84 /*- return the number of elements by which the current position in the list changes */
87 int listSkipForward(list, int n);
88 int listSkipBackward(list, int n);
89 int listToFirst(list);
91 int listPositionAt(list, int n); /* Expensive! */
93 /*- adding and removing elements */
94 list listAppend(list, void *);
95 list listPrepend(list, void *);
96 list listInsertAfter(list, void *);
97 list listInsertBefore(list, void *);
98 list listConcat(list lhs, list rhs); /* appends all elements of rhs to lhs and returns lhs */
100 list listRemove(list); /* removes the current element */
101 list listClear(list); /* removes all elements */
104 void listForAll(list, void (*f)(void *));
107 void **listToArray(list); /* XXX listToArray does not duplicate the elements, just copies pointers to them */
108 /* so you can't call listRemove(), listClear(), or listDispose() until you are done */
109 /* with the array. */
116 #endif /* __CLIST_H */