-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathplist.h
64 lines (42 loc) · 1.64 KB
/
plist.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
/* Ken Sheedlo
* kmdata Data Structures Library
* Parallel Mapping List */
#include "tuple.h"
#define PL_ALLOW_IMBALANCE 1
#define PL_STRICT_ORDERING 2
#define PL_FREE_DATA 4
#define PL_REDUCE_COMMUTATIVE 8
#define PL_ERROR (1<<31)
typedef struct _pl_node {
void *data;
struct _pl_node *head;
struct _pl_node *next;
struct _pl_node *prev;
} pnode_t;
typedef struct {
pnode_t *head;
size_t length;
int32_t nthreads;
int32_t options;
} plist_t;
/* Initializes a new empty plist. */
void plist_init(plist_t *list, int32_t nthreads, int32_t options);
/* Initializes a parallel mapping list from a standard list. */
void plist_lstinit(plist_t *rop, list_t *op, int32_t nthreads, int32_t options);
/* Inserts a new piece of data into the list in an arbitrary position. */
void plist_insert(plist_t *list, void *data);
void plist_addfirst(plist_t *list, void *data);
void plist_addlast(plist_t *list, void *data);
void plist_insertbefore(pnode_t *node, void *data);
void plist_insertafter(pnode_t *node, void *data);
void *plist_remove(pnode_t *node);
pnode_t *plist_firstnode(plist_t *list);
pnode_t *plist_nextnode(pnode_t *node);
pnode_t *plist_prevnode(pnode_t *node);
void plist_clear(plist_t *list, int32_t options);
void plist_print(FILE *output, plist_t *lst, void (*disp)(FILE *, const void *));
void plist_map(list_t *rop, plist_t *op, void *(*map)(const void *));
void plist_filter(list_t *rop, plist_t *op, int32_t (*filt)(const void *));
void *plist_reduce(plist_t *op, void *(*rfunc)(const void *, const void *),
void *start);
void plist_to_list(list_t *rop, plist_t *op);