xref: /aoo42x/main/vcl/inc/list.h (revision cdf0e10c)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
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.
14  *
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).
20  *
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.
25  *
26  ************************************************************************/
27 
28 /*[]---------------------------------------------------[]*/
29 /*|                                                     |*/
30 /*|  Implementation of the list data type               |*/
31 /*|                                                     |*/
32 /*|                                                     |*/
33 /*|  Author: Alexander Gelfenbain                       |*/
34 /*[]---------------------------------------------------[]*/
35 
36 #ifndef __CLIST_H
37 #define __CLIST_H
38 
39 #ifdef __cplusplus
40 extern "C"
41 {
42 #endif
43 
44 /*
45  * List of void * pointers
46  */
47 
48     typedef struct _list *list;
49     typedef void (*list_destructor)(void *);
50 
51 /*- constructors and a destructor */
52     list listNewEmpty(void);
53 #ifdef TEST
54     list listNewCopy(list);
55 #endif
56     void listDispose(list);
57     void listSetElementDtor(list, list_destructor);                     /*- this function will be executed when the element is removed via listRemove() or listClear() */
58 
59 /*- queries */
60     void * listCurrent(list);
61     int    listCount(list);
62     int    listIsEmpty(list);
63 #ifdef TEST
64     int    listAtFirst(list);
65     int    listAtLast(list);
66     int    listPosition(list);                        /* Expensive! */
67 #endif
68 /*- search */
69     int    listFind(list, void *);                    /* Returns true/false */
70 
71 /*- positioning functions */
72 /*- return the number of elements by which the current position in the list changes */
73     int    listNext(list);
74     int    listSkipForward(list, int n);
75     int    listToFirst(list);
76     int    listToLast(list);
77     int    listPositionAt(list, int n);               /* Expensive! */
78 
79 /*- adding and removing elements */
80     list   listAppend(list, void *);
81 #ifdef TEST
82     list   listPrepend(list, void *);
83     list   listInsertAfter(list, void *);
84     list   listInsertBefore(list, void *);
85 #endif
86     list   listRemove(list);                          /* removes the current element */
87     list   listClear(list);                           /* removes all elements */
88 
89 #ifdef TEST
90 /*- forall */
91     void   listForAll(list, void (*f)(void *));
92 #endif
93 
94 #ifdef __cplusplus
95 }
96 #endif
97 
98 
99 #endif /* __CLIST_H */
100