xref: /aoo42x/main/vcl/inc/list.h (revision e6b30a3d)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 /*[]---------------------------------------------------[]*/
25 /*|                                                     |*/
26 /*|  Implementation of the list data type               |*/
27 /*|                                                     |*/
28 /*|                                                     |*/
29 /*|  Author: Alexander Gelfenbain                       |*/
30 /*[]---------------------------------------------------[]*/
31 
32 #ifndef __CLIST_H
33 #define __CLIST_H
34 
35 #ifdef __cplusplus
36 extern "C"
37 {
38 #endif
39 
40 /*
41  * List of void * pointers
42  */
43 
44     typedef struct _list *list;
45     typedef void (*list_destructor)(void *);
46 
47 /*- constructors and a destructor */
48     list listNewEmpty(void);
49 #ifdef TEST
50     list listNewCopy(list);
51 #endif
52     void listDispose(list);
53     void listSetElementDtor(list, list_destructor);                     /*- this function will be executed when the element is removed via listRemove() or listClear() */
54 
55 /*- queries */
56     void * listCurrent(list);
57     int    listCount(list);
58     int    listIsEmpty(list);
59 #ifdef TEST
60     int    listAtFirst(list);
61     int    listAtLast(list);
62     int    listPosition(list);                        /* Expensive! */
63 #endif
64 /*- search */
65     int    listFind(list, void *);                    /* Returns true/false */
66 
67 /*- positioning functions */
68 /*- return the number of elements by which the current position in the list changes */
69     int    listNext(list);
70     int    listSkipForward(list, int n);
71     int    listToFirst(list);
72     int    listToLast(list);
73     int    listPositionAt(list, int n);               /* Expensive! */
74 
75 /*- adding and removing elements */
76     list   listAppend(list, void *);
77 #ifdef TEST
78     list   listPrepend(list, void *);
79     list   listInsertAfter(list, void *);
80     list   listInsertBefore(list, void *);
81 #endif
82     list   listRemove(list);                          /* removes the current element */
83     list   listClear(list);                           /* removes all elements */
84 
85 #ifdef TEST
86 /*- forall */
87     void   listForAll(list, void (*f)(void *));
88 #endif
89 
90 #ifdef __cplusplus
91 }
92 #endif
93 
94 
95 #endif /* __CLIST_H */
96