blob: e6be624819ec19fb1d3b699bc4640a3386bef58f (
plain)
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
|
#ifndef SPLIST_H
#define SPLIST_H
#include "util.h"
#include "list.h"
/* A sparse list is a list with its "inverse list". This can be used
to determine if a number belongs to a sparse list at constant
time. */
typedef struct splist_s splist;
splist *new_splist();
/* A sparse list is of fixed size. */
unsigned char init_splist(splist *s, NUM size);
P_ATTR NUM splist_len(CCR_MOD(splist *) s);
/* NOTE: The returned list is owned by the original splist, so don't
destroy that list or do anything that should not be done. */
P_ATTR List *splist_ls(CCR_MOD(splist *) s);
/* We assume that elements of a sparse list are of type NUM. */
unsigned char add_to_splist(splist *s, NUM element);
/* resetting a sparse list means to set its length to 0 */
void reset_splist(splist *s);
/* Constant time operation */
unsigned char splist_is_member(splist *s, NUM element);
void print_splist(splist *s);
void destroy_splist(splist *s);
#endif
|