]> git.ipfire.org Git - people/ms/systemd.git/blame - set.c
Remove .h files from _SOURCES
[people/ms/systemd.git] / set.c
CommitLineData
60918275
LP
1/*-*- Mode: C; c-basic-offset: 8 -*-*/
2
a7334b09
LP
3/***
4 This file is part of systemd.
5
6 Copyright 2010 Lennart Poettering
7
8 systemd is free software; you can redistribute it and/or modify it
9 under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2 of the License, or
11 (at your option) any later version.
12
13 systemd is distributed in the hope that it will be useful, but
14 WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 General Public License for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with systemd; If not, see <http://www.gnu.org/licenses/>.
20***/
21
60918275
LP
22#include <stdlib.h>
23
24#include "set.h"
25#include "hashmap.h"
26
27#define MAKE_SET(h) ((Set*) (h))
28#define MAKE_HASHMAP(s) ((Hashmap*) (s))
29
30/* For now this is not much more than a wrapper around a hashmap */
31
32Set *set_new(hash_func_t hash_func, compare_func_t compare_func) {
33 return MAKE_SET(hashmap_new(hash_func, compare_func));
34}
35
36void set_free(Set* s) {
37 hashmap_free(MAKE_HASHMAP(s));
38}
39
034c6ed7
LP
40int set_ensure_allocated(Set **s, hash_func_t hash_func, compare_func_t compare_func) {
41 return hashmap_ensure_allocated((Hashmap**) s, hash_func, compare_func);
42}
43
60918275
LP
44int set_put(Set *s, void *value) {
45 return hashmap_put(MAKE_HASHMAP(s), value, value);
46}
47
f00b3eda
LP
48int set_replace(Set *s, void *value) {
49 return hashmap_replace(MAKE_HASHMAP(s), value, value);
50}
51
60918275
LP
52void *set_get(Set *s, void *value) {
53 return hashmap_get(MAKE_HASHMAP(s), value);
54}
55
56void *set_remove(Set *s, void *value) {
57 return hashmap_remove(MAKE_HASHMAP(s), value);
58}
59
101d8e63
LP
60int set_remove_and_put(Set *s, void *old_value, void *new_value) {
61 return hashmap_remove_and_put(MAKE_HASHMAP(s), old_value, new_value, new_value);
62}
63
60918275
LP
64unsigned set_size(Set *s) {
65 return hashmap_size(MAKE_HASHMAP(s));
66}
67
68bool set_isempty(Set *s) {
69 return hashmap_isempty(MAKE_HASHMAP(s));
70}
71
034c6ed7
LP
72void *set_iterate(Set *s, Iterator *i) {
73 return hashmap_iterate(MAKE_HASHMAP(s), i, NULL);
74}
75
76void *set_iterate_backwards(Set *s, Iterator *i) {
77 return hashmap_iterate_backwards(MAKE_HASHMAP(s), i, NULL);
60918275
LP
78}
79
034c6ed7
LP
80void *set_iterate_skip(Set *s, void *value, Iterator *i) {
81 return hashmap_iterate_skip(MAKE_HASHMAP(s), value, i);
60918275
LP
82}
83
84void *set_steal_first(Set *s) {
85 return hashmap_steal_first(MAKE_HASHMAP(s));
86}
87
88void* set_first(Set *s) {
89 return hashmap_first(MAKE_HASHMAP(s));
90}
91
92void* set_last(Set *s) {
93 return hashmap_last(MAKE_HASHMAP(s));
94}
91cdde8a
LP
95
96int set_merge(Set *s, Set *other) {
97 return hashmap_merge(MAKE_HASHMAP(s), MAKE_HASHMAP(other));
98}
99
101d8e63
LP
100void set_move(Set *s, Set *other) {
101 return hashmap_move(MAKE_HASHMAP(s), MAKE_HASHMAP(other));
102}
103
104int set_move_one(Set *s, Set *other, void *value) {
105 return hashmap_move_one(MAKE_HASHMAP(s), MAKE_HASHMAP(other), value);
106}
107
91cdde8a
LP
108Set* set_copy(Set *s) {
109 return MAKE_SET(hashmap_copy(MAKE_HASHMAP(s)));
110}
11dd41ce
LP
111
112void set_clear(Set *s) {
113 hashmap_clear(MAKE_HASHMAP(s));
114}