1
/* $NetBSD: lst.h,v 1.7 1996/11/06 17:59:12 christos Exp $ */
1
/* $NetBSD: lst.h,v 1.10 2003/08/07 11:14:53 agc Exp $ */
4
4
* Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
7
* This code is derived from software contributed to Berkeley by
10
* Redistribution and use in source and binary forms, with or without
11
* modification, are permitted provided that the following conditions
13
* 1. Redistributions of source code must retain the above copyright
14
* notice, this list of conditions and the following disclaimer.
15
* 2. Redistributions in binary form must reproduce the above copyright
16
* notice, this list of conditions and the following disclaimer in the
17
* documentation and/or other materials provided with the distribution.
18
* 3. Neither the name of the University nor the names of its contributors
19
* may be used to endorse or promote products derived from this software
20
* without specific prior written permission.
22
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
23
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
26
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34
* from: @(#)lst.h 8.1 (Berkeley) 6/6/93
5
38
* Copyright (c) 1988, 1989 by Adam de Boor
6
39
* Copyright (c) 1989 by Berkeley Softworks
7
40
* All rights reserved.
78
110
* Creation/destruction functions
80
112
/* Create a new list */
81
Lst Lst_Init __P((Boolean));
113
Lst Lst_Init(Boolean);
82
114
/* Duplicate an existing list */
83
Lst Lst_Duplicate __P((Lst, ClientData (*)(ClientData)));
115
Lst Lst_Duplicate(Lst, ClientData (*)(ClientData));
84
116
/* Destroy an old one */
85
void Lst_Destroy __P((Lst, void (*)(ClientData)));
117
void Lst_Destroy(Lst, void (*)(ClientData));
86
118
/* True if list is empty */
87
Boolean Lst_IsEmpty __P((Lst));
119
Boolean Lst_IsEmpty(Lst);
90
122
* Functions to modify a list
92
124
/* Insert an element before another */
93
ReturnStatus Lst_Insert __P((Lst, LstNode, ClientData));
125
ReturnStatus Lst_Insert(Lst, LstNode, ClientData);
94
126
/* Insert an element after another */
95
ReturnStatus Lst_Append __P((Lst, LstNode, ClientData));
127
ReturnStatus Lst_Append(Lst, LstNode, ClientData);
96
128
/* Place an element at the front of a lst. */
97
ReturnStatus Lst_AtFront __P((Lst, ClientData));
129
ReturnStatus Lst_AtFront(Lst, ClientData);
98
130
/* Place an element at the end of a lst. */
99
ReturnStatus Lst_AtEnd __P((Lst, ClientData));
131
ReturnStatus Lst_AtEnd(Lst, ClientData);
100
132
/* Remove an element */
101
ReturnStatus Lst_Remove __P((Lst, LstNode));
133
ReturnStatus Lst_Remove(Lst, LstNode);
102
134
/* Replace a node with a new value */
103
ReturnStatus Lst_Replace __P((LstNode, ClientData));
135
ReturnStatus Lst_Replace(LstNode, ClientData);
104
136
/* Concatenate two lists */
105
ReturnStatus Lst_Concat __P((Lst, Lst, int));
137
ReturnStatus Lst_Concat(Lst, Lst, int);
108
140
* Node-specific functions
110
142
/* Return first element in list */
111
LstNode Lst_First __P((Lst));
143
LstNode Lst_First(Lst);
112
144
/* Return last element in list */
113
LstNode Lst_Last __P((Lst));
145
LstNode Lst_Last(Lst);
114
146
/* Return successor to given element */
115
LstNode Lst_Succ __P((LstNode));
147
LstNode Lst_Succ(LstNode);
116
148
/* Get datum from LstNode */
117
ClientData Lst_Datum __P((LstNode));
149
ClientData Lst_Datum(LstNode);
120
152
* Functions for entire lists
122
154
/* Find an element in a list */
123
LstNode Lst_Find __P((Lst, ClientData,
124
int (*)(ClientData, ClientData)));
155
LstNode Lst_Find(Lst, ClientData, int (*)(ClientData, ClientData));
125
156
/* Find an element starting from somewhere */
126
LstNode Lst_FindFrom __P((Lst, LstNode, ClientData,
127
int (*cProc)(ClientData, ClientData)));
157
LstNode Lst_FindFrom(Lst, LstNode, ClientData,
158
int (*cProc)(ClientData, ClientData));
129
160
* See if the given datum is on the list. Returns the LstNode containing
132
LstNode Lst_Member __P((Lst, ClientData));
163
LstNode Lst_Member(Lst, ClientData);
133
164
/* Apply a function to all elements of a lst */
134
void Lst_ForEach __P((Lst, int (*)(ClientData, ClientData),
165
void Lst_ForEach(Lst, int (*)(ClientData, ClientData), ClientData);
137
167
* Apply a function to all elements of a lst starting from a certain point.
138
168
* If the list is circular, the application will wrap around to the
139
169
* beginning of the list again.
141
void Lst_ForEachFrom __P((Lst, LstNode,
142
int (*)(ClientData, ClientData),
171
void Lst_ForEachFrom(Lst, LstNode, int (*)(ClientData, ClientData),
145
174
* these functions are for dealing with a list as a table, of sorts.
146
175
* An idea of the "current element" is kept and used by all the functions
147
176
* between Lst_Open() and Lst_Close().
149
178
/* Open the list */
150
ReturnStatus Lst_Open __P((Lst));
179
ReturnStatus Lst_Open(Lst);
151
180
/* Next element please */
152
LstNode Lst_Next __P((Lst));
181
LstNode Lst_Next(Lst);
154
Boolean Lst_IsAtEnd __P((Lst));
183
Boolean Lst_IsAtEnd(Lst);
155
184
/* Finish table access */
156
void Lst_Close __P((Lst));
159
188
* for using the list as a queue
161
190
/* Place an element at tail of queue */
162
ReturnStatus Lst_EnQueue __P((Lst, ClientData));
191
ReturnStatus Lst_EnQueue(Lst, ClientData);
163
192
/* Remove an element from head of queue */
164
ClientData Lst_DeQueue __P((Lst));
193
ClientData Lst_DeQueue(Lst);
166
195
#endif /* _LST_H_ */