]> git.donarmstrong.com Git - xournal.git/blob - src/ttsubset/list.h
Print via gtk-print instead of libgnomeprint
[xournal.git] / src / ttsubset / list.h
1 /*
2  * Copyright © 2002, 2003 Sun Microsystems, Inc.
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  *
9  * 1. Redistributions of source code must retain the above copyright
10  *    notice, this list of conditions and the following disclaimer.
11  *
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.
15  *
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.
19  *
20  * This software is provided "AS IS," without a warranty of any kind.
21  *
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.
33  *
34  */
35
36 /* $Id$ */
37 /* @(#)list.h 1.6 03/02/06 SMI */
38
39 /*
40  * @file list.h
41  * @brief Bidirectional list class header file
42  * @author Alexander Gelfenbain
43  * @version 1.0
44  *
45  */
46
47 #ifndef __CLIST_H
48 #define __CLIST_H
49
50 #ifdef __cplusplus
51 extern "C"{
52 #endif
53
54 #include <glib.h>
55
56 /*
57  * List of void * pointers
58  */
59
60 typedef struct _list *list;
61
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() */
68
69 /*- assignment */
70 list listCopy(list to, list from);
71
72 /*- queries */
73 void * listCurrent(list);
74 int    listCount(list);
75 int    listIsEmpty(list);
76 int    listAtFirst(list);
77 int    listAtLast(list);
78 int    listPosition(list);                        /* Expensive! */
79
80 /*- search */
81 int    listFind(list, void *);                    /* Returns true/false */
82
83 /*- positioning functions */
84 /*- return the number of elements by which the current position in the list changes */
85 int    listNext(list);
86 int    listPrev(list);
87 int    listSkipForward(list, int n);
88 int    listSkipBackward(list, int n);
89 int    listToFirst(list);
90 int    listToLast(list);
91 int    listPositionAt(list, int n);               /* Expensive! */
92
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 */
99                                                   
100 list   listRemove(list);                          /* removes the current element */
101 list   listClear(list);                           /* removes all elements */
102
103 /*- forall */
104 void   listForAll(list, void (*f)(void *));
105
106 /*- conversion */
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. */
110
111 #ifdef __cplusplus
112 }
113 #endif
114
115
116 #endif /* __CLIST_H */