1 | /* x-list.h -- simple list type
|
---|
2 | $Id: x-list.h,v 1.4 2005/07/01 22:43:08 daniels Exp $
|
---|
3 |
|
---|
4 | Copyright (c) 2002 Apple Computer, Inc. All rights reserved.
|
---|
5 |
|
---|
6 | Permission is hereby granted, free of charge, to any person
|
---|
7 | obtaining a copy of this software and associated documentation files
|
---|
8 | (the "Software"), to deal in the Software without restriction,
|
---|
9 | including without limitation the rights to use, copy, modify, merge,
|
---|
10 | publish, distribute, sublicense, and/or sell copies of the Software,
|
---|
11 | and to permit persons to whom the Software is furnished to do so,
|
---|
12 | subject to the following conditions:
|
---|
13 |
|
---|
14 | The above copyright notice and this permission notice shall be
|
---|
15 | included in all copies or substantial portions of the Software.
|
---|
16 |
|
---|
17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
---|
18 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
---|
19 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
---|
20 | NONINFRINGEMENT. IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT
|
---|
21 | HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
---|
22 | WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
---|
23 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
---|
24 | DEALINGS IN THE SOFTWARE.
|
---|
25 |
|
---|
26 | Except as contained in this notice, the name(s) of the above
|
---|
27 | copyright holders shall not be used in advertising or otherwise to
|
---|
28 | promote the sale, use or other dealings in this Software without
|
---|
29 | prior written authorization. */
|
---|
30 | /* $XFree86: xc/programs/Xserver/hw/darwin/quartz/xpr/x-list.h,v 1.1 2003/04/30 23:15:42 torrey Exp $ */
|
---|
31 |
|
---|
32 | #ifndef X_LIST_H
|
---|
33 | #define X_LIST_H 1
|
---|
34 |
|
---|
35 | /* This is just a cons. */
|
---|
36 |
|
---|
37 | typedef struct x_list_struct x_list;
|
---|
38 |
|
---|
39 | struct x_list_struct {
|
---|
40 | void *data;
|
---|
41 | x_list *next;
|
---|
42 | };
|
---|
43 |
|
---|
44 | #ifndef X_PFX
|
---|
45 | # define X_PFX(x) x_ ## x
|
---|
46 | #endif
|
---|
47 |
|
---|
48 | #ifndef X_EXTERN
|
---|
49 | # define X_EXTERN __private_extern__
|
---|
50 | #endif
|
---|
51 |
|
---|
52 | X_EXTERN void X_PFX (list_free_1) (x_list *node);
|
---|
53 | X_EXTERN x_list *X_PFX (list_prepend) (x_list *lst, void *data);
|
---|
54 |
|
---|
55 | X_EXTERN x_list *X_PFX (list_append) (x_list *lst, void *data);
|
---|
56 | X_EXTERN x_list *X_PFX (list_remove) (x_list *lst, void *data);
|
---|
57 | X_EXTERN void X_PFX (list_free) (x_list *lst);
|
---|
58 | X_EXTERN x_list *X_PFX (list_pop) (x_list *lst, void **data_ret);
|
---|
59 |
|
---|
60 | X_EXTERN x_list *X_PFX (list_copy) (x_list *lst);
|
---|
61 | X_EXTERN x_list *X_PFX (list_reverse) (x_list *lst);
|
---|
62 | X_EXTERN x_list *X_PFX (list_find) (x_list *lst, void *data);
|
---|
63 | X_EXTERN x_list *X_PFX (list_nth) (x_list *lst, int n);
|
---|
64 | X_EXTERN x_list *X_PFX (list_filter) (x_list *src,
|
---|
65 | int (*pred) (void *item, void *data),
|
---|
66 | void *data);
|
---|
67 | X_EXTERN x_list *X_PFX (list_map) (x_list *src,
|
---|
68 | void *(*fun) (void *item, void *data),
|
---|
69 | void *data);
|
---|
70 |
|
---|
71 | X_EXTERN unsigned int X_PFX (list_length) (x_list *lst);
|
---|
72 | X_EXTERN void X_PFX (list_foreach) (x_list *lst, void (*fun)
|
---|
73 | (void *data, void *user_data),
|
---|
74 | void *user_data);
|
---|
75 |
|
---|
76 | X_EXTERN x_list *X_PFX (list_sort) (x_list *lst, int (*less) (const void *,
|
---|
77 | const void *));
|
---|
78 |
|
---|
79 | #endif /* X_LIST_H */
|
---|