aboutsummaryrefslogtreecommitdiff
blob: 27e30ad0015290fa12d119738d7ca2ad0092df8c (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
/*
 * Copyright 2005-2019 Gentoo Foundation
 * Distributed under the terms of the GNU General Public License v2
 */

#ifndef _SET_H
#define _SET_H 1

#include <stdlib.h>
#include <stdbool.h>
#include <unistd.h>

typedef struct elem_t elem;
typedef struct set_t set;

struct elem_t {
	char *name;
	unsigned int hash;  /* FNV1a32 */
	elem *next;
};

#define _SET_HASH_SIZE 128
struct set_t {
	elem *buckets[_SET_HASH_SIZE];
	size_t len;
};

set *create_set(void);
set *add_set(const char *name, set *q);
set *add_set_unique(const char *name, set *q, bool *unique);
bool contains_set(char *s, set *q);
set *del_set(char *s, set *q, bool *removed);
size_t list_set(set *q, char ***l);
void free_set(set *q);

#endif