1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
11 * OpenOffice.org is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License version 3
13 * only, as published by the Free Software Foundation.
15 * OpenOffice.org is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License version 3 for more details
19 * (a copy is included in the LICENSE file that accompanied this code).
21 * You should have received a copy of the GNU Lesser General Public License
22 * version 3 along with OpenOffice.org. If not, see
23 * <http://www.openoffice.org/license.html>
24 * for a copy of the LGPLv3 License.
26 ************************************************************************/
28 /*[]---------------------------------------------------[]*/
30 /*| Implementation of the list data type |*/
33 /*| Author: Alexander Gelfenbain |*/
34 /*[]---------------------------------------------------[]*/
45 * List of void * pointers
48 typedef struct _list
*list
;
49 typedef void (*list_destructor
)(void *);
51 /*- constructors and a destructor */
52 list
listNewEmpty(void);
54 list
listNewCopy(list
);
56 void listDispose(list
);
57 void listSetElementDtor(list
, list_destructor
); /*- this function will be executed when the element is removed via listRemove() or listClear() */
60 void * listCurrent(list
);
62 int listIsEmpty(list
);
64 int listAtFirst(list
);
66 int listPosition(list
); /* Expensive! */
69 int listFind(list
, void *); /* Returns true/false */
71 /*- positioning functions */
72 /*- return the number of elements by which the current position in the list changes */
74 int listSkipForward(list
, int n
);
75 int listToFirst(list
);
77 int listPositionAt(list
, int n
); /* Expensive! */
79 /*- adding and removing elements */
80 list
listAppend(list
, void *);
82 list
listPrepend(list
, void *);
83 list
listInsertAfter(list
, void *);
84 list
listInsertBefore(list
, void *);
86 list
listRemove(list
); /* removes the current element */
87 list
listClear(list
); /* removes all elements */
91 void listForAll(list
, void (*f
)(void *));
99 #endif /* __CLIST_H */