LAL  7.5.0.1-b72065a
LALList.h
Go to the documentation of this file.
1 /*
2 * Copyright (C) 2016 Jolien Creighton
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with with program; see the file COPYING. If not, write to the
16 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
17 * MA 02110-1301 USA
18 */
19 
20 #ifndef _LAL_LIST_H
21 #define _LAL_LIST_H
22 
23 #include <stdio.h>
24 #include <stddef.h>
25 #include <lal/LALDatatypes.h>
26 #include <lal/LALValue.h>
27 
28 #ifdef __cplusplus
29 extern "C" {
30 #elif 0
31 } /* so that editors will match preceding brace */
32 #endif
33 
34 struct tagLALListItem;
35 typedef struct tagLALListItem LALListItem;
36 
37 struct tagLALList;
38 typedef struct tagLALList LALList;
39 
41  /* private data */
43 };
44 typedef struct tagLALListIter LALListIter;
45 
46 LALListItem *XLALListItemAlloc(size_t size);
47 LALListItem *XLALListItemRealloc(LALListItem *item, size_t size);
48 LALListItem *XLALListItemSet(LALListItem *item, const void *data, size_t size, LALTYPECODE type);
49 LALListItem *XLALListItemSetValue(LALListItem *item, const LALValue *value);
50 LALListItem *XLALListItemDuplicate(const LALListItem *item);
51 
52 const LALValue * XLALListItemGetValue(const LALListItem *item);
53 LALTYPECODE XLALListItemGetValueType(const LALListItem *item);
54 void * XLALListItemGetValueData(void * data, size_t size, LALTYPECODE type, const LALListItem *item);
55 void * XLALListItemGetBLOBValue(const LALListItem *item);
56 const char * XLALListItemGetStringValue(const LALListItem *item);
57 CHAR XLALListItemGetCHARValue(const LALListItem *item);
58 INT2 XLALListItemGetINT2Value(const LALListItem *item);
59 INT4 XLALListItemGetINT4Value(const LALListItem *item);
60 INT8 XLALListItemGetINT8Value(const LALListItem *item);
61 UCHAR XLALListItemGetUCHARValue(const LALListItem *item);
62 UINT2 XLALListItemGetUINT2Value(const LALListItem *item);
63 UINT4 XLALListItemGetUINT4Value(const LALListItem *item);
64 UINT8 XLALListItemGetUINT8Value(const LALListItem *item);
65 REAL4 XLALListItemGetREAL4Value(const LALListItem *item);
66 REAL8 XLALListItemGetREAL8Value(const LALListItem *item);
67 COMPLEX8 XLALListItemGetCOMPLEX8Value(const LALListItem *item);
68 COMPLEX16 XLALListItemGetCOMPLEX16Value(const LALListItem *item);
69 
70 REAL8 XLALListItemGetValueAsREAL8(const LALListItem *item);
71 
72 void XLALDestroyList(LALList *list);
73 LALList * XLALCreateList(void);
74 
75 LALList * XLALListDuplicate(const LALList *list);
76 int XLALListReverse(LALList *list);
77 int XLALListSort(LALList *list, int (*cmp)(const LALValue *, const LALValue *, void *), void *thunk);
78 size_t XLALListSize(const LALList *list);
79 void XLALListForeach(LALList *list, void (*func)(LALValue *, void *), void *thunk);
80 LALListItem * XLALListPop(LALList *list);
81 LALListItem * XLALListLast(LALList *list);
82 LALListItem * XLALListFind(LALList *list, int (*func)(const LALValue *, void *), void *thunk);
83 LALListItem * XLALListFindValue(LALList *list, const LALValue *value);
84 int XLALListReplace(LALList *list, int (*func)(const LALValue *, void *), void *thunk, const LALValue *replace);
85 int XLALListReplaceAll(LALList *list, int (*func)(const LALValue *, void *), void *thunk, const LALValue *replace);
86 int XLALListReplaceValue(LALList *list, const LALValue *value, const LALValue *replace);
87 int XLALListReplaceValueAll(LALList *list, const LALValue *value, const LALValue *replace);
88 int XLALListRemove(LALList *list, int (*func)(const LALValue *, void *), void *thunk);
89 int XLALListRemoveAll(LALList *list, int (*func)(const LALValue *, void *), void *thunk);
90 int XLALListRemoveValue(LALList *list, const LALValue *value);
91 int XLALListRemoveValueAll(LALList *list, const LALValue *value);
92 void XLALListIterInit(LALListIter *iter, LALList *list);
93 LALListItem * XLALListIterNext(LALListIter *iter);
94 
95 int XLALListAdd(LALList *list, const void *data, size_t size, LALTYPECODE type);
96 int XLALListAddValue(LALList *list, const LALValue *value);
97 int XLALListAddBLOBValue(LALList *list, const void *blob, size_t size);
98 int XLALListAddStringValue(LALList *list, const char *string);
99 int XLALListAddCHARValue(LALList *list, CHAR value);
100 int XLALListAddINT2Value(LALList *list, INT2 value);
101 int XLALListAddINT4Value(LALList *list, INT4 value);
102 int XLALListAddINT8Value(LALList *list, INT8 value);
103 int XLALListAddUCHARValue(LALList *list, UCHAR value);
104 int XLALListAddUINT2Value(LALList *list, UINT2 value);
105 int XLALListAddUINT4Value(LALList *list, UINT4 value);
106 int XLALListAddUINT8Value(LALList *list, UINT8 value);
107 int XLALListAddREAL4Value(LALList *list, REAL4 value);
108 int XLALListAddREAL8Value(LALList *list, REAL8 value);
109 int XLALListAddCOMPLEX8Value(LALList *list, COMPLEX8 value);
110 int XLALListAddCOMPLEX16Value(LALList *list, COMPLEX16 value);
111 
112 char * XLALListAsStringAppend(char *s, LALList *list);
113 void XLALListPrint(LALList *list, int fd);
114 
115 
116 #if 0
117 { /* so that editors will match succeeding brace */
118 #elif defined(__cplusplus)
119 }
120 #endif
121 #endif /* _LAL_LIST_H */
void XLALListPrint(LALList *list, int fd)
Definition: LALList.c:569
int XLALListAddValue(LALList *list, const LALValue *value)
Definition: LALList.c:509
LALListItem * XLALListItemRealloc(LALListItem *item, size_t size)
Definition: LALList.c:49
LALList * XLALListDuplicate(const LALList *list)
Definition: LALList.c:174
INT4 XLALListItemGetINT4Value(const LALListItem *item)
int XLALListReverse(LALList *list)
Definition: LALList.c:198
INT8 XLALListItemGetINT8Value(const LALListItem *item)
int XLALListAddCOMPLEX8Value(LALList *list, COMPLEX8 value)
LALListItem * XLALListLast(LALList *list)
Definition: LALList.c:303
UCHAR XLALListItemGetUCHARValue(const LALListItem *item)
size_t XLALListSize(const LALList *list)
Definition: LALList.c:268
int XLALListAddINT2Value(LALList *list, INT2 value)
INT2 XLALListItemGetINT2Value(const LALListItem *item)
int XLALListAddINT8Value(LALList *list, INT8 value)
int XLALListAddREAL8Value(LALList *list, REAL8 value)
UINT2 XLALListItemGetUINT2Value(const LALListItem *item)
void XLALListIterInit(LALListIter *iter, LALList *list)
Definition: LALList.c:475
const char * XLALListItemGetStringValue(const LALListItem *item)
Definition: LALList.c:113
int XLALListAddUINT2Value(LALList *list, UINT2 value)
REAL8 XLALListItemGetValueAsREAL8(const LALListItem *item)
Definition: LALList.c:145
void * XLALListItemGetValueData(void *data, size_t size, LALTYPECODE type, const LALListItem *item)
Definition: LALList.c:96
int XLALListAddINT4Value(LALList *list, INT4 value)
int XLALListRemoveValue(LALList *list, const LALValue *value)
Definition: LALList.c:463
int XLALListAddUINT4Value(LALList *list, UINT4 value)
void * XLALListItemGetBLOBValue(const LALListItem *item)
Definition: LALList.c:104
LALListItem * XLALListFind(LALList *list, int(*func)(const LALValue *, void *), void *thunk)
Definition: LALList.c:314
UINT4 XLALListItemGetUINT4Value(const LALListItem *item)
int XLALListReplaceValue(LALList *list, const LALValue *value, const LALValue *replace)
Definition: LALList.c:405
int XLALListReplaceValueAll(LALList *list, const LALValue *value, const LALValue *replace)
Definition: LALList.c:411
int XLALListSort(LALList *list, int(*cmp)(const LALValue *, const LALValue *, void *), void *thunk)
Definition: LALList.c:233
int XLALListAddStringValue(LALList *list, const char *string)
Definition: LALList.c:522
int XLALListAddUINT8Value(LALList *list, UINT8 value)
void XLALListForeach(LALList *list, void(*func)(LALValue *, void *), void *thunk)
Definition: LALList.c:281
UINT8 XLALListItemGetUINT8Value(const LALListItem *item)
int XLALListRemoveValueAll(LALList *list, const LALValue *value)
Definition: LALList.c:469
REAL4 XLALListItemGetREAL4Value(const LALListItem *item)
COMPLEX16 XLALListItemGetCOMPLEX16Value(const LALListItem *item)
int XLALListAddBLOBValue(LALList *list, const void *blob, size_t size)
Definition: LALList.c:517
LALTYPECODE XLALListItemGetValueType(const LALListItem *item)
Definition: LALList.c:88
int XLALListReplaceAll(LALList *list, int(*func)(const LALValue *, void *), void *thunk, const LALValue *replace)
Definition: LALList.c:372
REAL8 XLALListItemGetREAL8Value(const LALListItem *item)
int XLALListAdd(LALList *list, const void *data, size_t size, LALTYPECODE type)
Definition: LALList.c:489
LALListItem * XLALListItemSet(LALListItem *item, const void *data, size_t size, LALTYPECODE type)
Definition: LALList.c:60
const LALValue * XLALListItemGetValue(const LALListItem *item)
Definition: LALList.c:83
int XLALListRemoveAll(LALList *list, int(*func)(const LALValue *, void *), void *thunk)
Definition: LALList.c:438
void XLALDestroyList(LALList *list)
Definition: LALList.c:155
CHAR XLALListItemGetCHARValue(const LALListItem *item)
int XLALListAddCHARValue(LALList *list, CHAR value)
int XLALListRemove(LALList *list, int(*func)(const LALValue *, void *), void *thunk)
Definition: LALList.c:417
LALListItem * XLALListItemDuplicate(const LALListItem *item)
Definition: LALList.c:74
int XLALListAddUCHARValue(LALList *list, UCHAR value)
LALListItem * XLALListPop(LALList *list)
Definition: LALList.c:293
int XLALListAddCOMPLEX16Value(LALList *list, COMPLEX16 value)
LALListItem * XLALListIterNext(LALListIter *iter)
Definition: LALList.c:480
LALList * XLALCreateList(void)
Definition: LALList.c:169
LALListItem * XLALListItemSetValue(LALListItem *item, const LALValue *value)
Definition: LALList.c:67
int XLALListReplace(LALList *list, int(*func)(const LALValue *, void *), void *thunk, const LALValue *replace)
Definition: LALList.c:340
char * XLALListAsStringAppend(char *s, LALList *list)
Definition: LALList.c:560
COMPLEX8 XLALListItemGetCOMPLEX8Value(const LALListItem *item)
LALListItem * XLALListFindValue(LALList *list, const LALValue *value)
Definition: LALList.c:334
int XLALListAddREAL4Value(LALList *list, REAL4 value)
LALListItem * XLALListItemAlloc(size_t size)
Definition: LALList.c:39
static int replace(int c, void *param)
Definition: LALString.c:373
static int cmp(REAL4Sequence *a, REAL4Sequence *b)
Definition: SequenceTest.c:62
LALTYPECODE
Type codes: use these type codes to identify a LAL atomic data type, see Headers LAL(Atomic)Datatypes...
Definition: LALDatatypes.h:49
unsigned char UCHAR
One-byte unsigned integer, see Headers LAL(Atomic)Datatypes.h for more details.
uint64_t UINT8
Eight-byte unsigned integer; on some platforms this is equivalent to unsigned long int instead.
double complex COMPLEX16
Double-precision floating-point complex number (16 bytes total)
double REAL8
Double precision real floating-point number (8 bytes).
int16_t INT2
Two-byte signed integer.
int64_t INT8
Eight-byte signed integer; on some platforms this is equivalent to long int instead.
uint16_t UINT2
Two-byte unsigned integer.
char CHAR
One-byte signed integer, see Headers LAL(Atomic)Datatypes.h for more details.
uint32_t UINT4
Four-byte unsigned integer.
float complex COMPLEX8
Single-precision floating-point complex number (8 bytes total)
int32_t INT4
Four-byte signed integer.
float REAL4
Single precision real floating-point number (4 bytes).
struct tagLALListItem * next
Definition: LALList.h:42