7
7
*
8
8
*
9
9
* IDENTIFICATION
10
- * $Header: /cvsroot/pgsql/src/backend/nodes/list.c,v 1.18 1999/02/22 05:26:18 momjian Exp $
10
+ * $Header: /cvsroot/pgsql/src/backend/nodes/list.c,v 1.19 1999/02/22 06:08:47 momjian Exp $
11
11
*
12
12
* NOTES
13
13
* XXX a few of the following functions are duplicated to handle
29
29
#include "utils/elog.h"
30
30
#include "utils/palloc.h"
31
31
32
+ /*
33
+ * makeList
34
+ *
35
+ * Take varargs, terminated by -1, and make a List
36
+ */
32
37
List *
33
38
makeList (void * elem ,...)
34
39
{
@@ -57,6 +62,11 @@ makeList(void *elem,...)
57
62
return retval ;
58
63
}
59
64
65
+ /*
66
+ * lcons
67
+ *
68
+ * Add obj to the front of list, or make a new list if 'list' is NIL
69
+ */
60
70
List *
61
71
lcons (void * obj , List * list )
62
72
{
@@ -67,6 +77,11 @@ lcons(void *obj, List *list)
67
77
return l ;
68
78
}
69
79
80
+ /*
81
+ * lconsi
82
+ *
83
+ * Same as lcons, but for integer data
84
+ */
70
85
List *
71
86
lconsi (int datum , List * list )
72
87
{
@@ -77,18 +92,35 @@ lconsi(int datum, List *list)
77
92
return l ;
78
93
}
79
94
95
+ /*
96
+ * lappend
97
+ *
98
+ * Add obj to the end of list, or make a new list if 'list' is NIL
99
+ *
100
+ * MORE EXPENSIVE THAN lcons
101
+ */
80
102
List *
81
103
lappend (List * list , void * obj )
82
104
{
83
105
return nconc (list , lcons (obj , NIL ));
84
106
}
85
107
108
+ /*
109
+ * lappendi
110
+ *
111
+ * Same as lappend, but for integers
112
+ */
86
113
List *
87
114
lappendi (List * list , int datum )
88
115
{
89
116
return nconc (list , lconsi (datum , NIL ));
90
117
}
91
118
119
+ /*
120
+ * nconc
121
+ *
122
+ * Concat l2 on to the end of l1
123
+ */
92
124
List *
93
125
nconc (List * l1 , List * l2 )
94
126
{
@@ -131,6 +163,9 @@ nreverse(List *list)
131
163
}
132
164
#endif
133
165
166
+ /*
167
+ * makeInteger
168
+ */
134
169
Value *
135
170
makeInteger (long i )
136
171
{
@@ -141,6 +176,9 @@ makeInteger(long i)
141
176
return v ;
142
177
}
143
178
179
+ /*
180
+ * makeFloat
181
+ */
144
182
Value *
145
183
makeFloat (double d )
146
184
{
@@ -151,6 +189,9 @@ makeFloat(double d)
151
189
return v ;
152
190
}
153
191
192
+ /*
193
+ * makeString
194
+ */
154
195
Value *
155
196
makeString (char * str )
156
197
{
@@ -161,7 +202,11 @@ makeString(char *str)
161
202
return v ;
162
203
}
163
204
164
- /* n starts with 0 */
205
+ /*
206
+ * nth
207
+ *
208
+ * Get the n'th element of the list. First element is 0th.
209
+ */
165
210
void *
166
211
nth (int n , List * l )
167
212
{
@@ -174,6 +219,11 @@ nth(int n, List *l)
174
219
return lfirst (l );
175
220
}
176
221
222
+ /*
223
+ * nthi
224
+ *
225
+ * Same as nthi, but for integers
226
+ */
177
227
int
178
228
nthi (int n , List * l )
179
229
{
@@ -200,6 +250,11 @@ set_nth(List *l, int n, void *elem)
200
250
return ;
201
251
}
202
252
253
+ /*
254
+ * length
255
+ *
256
+ * Get the length of l
257
+ */
203
258
int
204
259
length (List * l )
205
260
{
@@ -213,6 +268,11 @@ length(List *l)
213
268
return i ;
214
269
}
215
270
271
+ /*
272
+ * freeList
273
+ *
274
+ * Free the List nodes of a list
275
+ */
216
276
void
217
277
freeList (List * list )
218
278
{
@@ -415,6 +475,9 @@ lremove(void *elem, List *list)
415
475
return result ;
416
476
}
417
477
478
+ /*
479
+ * LispRemove
480
+ */
418
481
List *
419
482
LispRemove (void * elem , List * list )
420
483
{
@@ -466,6 +529,11 @@ intLispRemove(int elem, List *list)
466
529
467
530
#endif
468
531
532
+ /*
533
+ * set_difference
534
+ *
535
+ * Return l1 without the elements in l2.
536
+ */
469
537
List *
470
538
set_difference (List * l1 , List * l2 )
471
539
{
@@ -483,6 +551,11 @@ set_difference(List *l1, List *l2)
483
551
return result ;
484
552
}
485
553
554
+ /*
555
+ * set_differencei
556
+ *
557
+ * Same as set_difference, but for integers
558
+ */
486
559
List *
487
560
set_differencei (List * l1 , List * l2 )
488
561
{
0 commit comments