]> git.ipfire.org Git - thirdparty/systemd.git/blame - src/basic/ordered-set.h
resolved: enforce a maximum limit on both dns servers and search domains
[thirdparty/systemd.git] / src / basic / ordered-set.h
CommitLineData
4a280a7e
LP
1/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
2
3#pragma once
4
5/***
6 This file is part of systemd.
7
8 Copyright 2015 Lennart Poettering
9
10 systemd is free software; you can redistribute it and/or modify it
11 under the terms of the GNU Lesser General Public License as published by
12 the Free Software Foundation; either version 2.1 of the License, or
13 (at your option) any later version.
14
15 systemd is distributed in the hope that it will be useful, but
16 WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 Lesser General Public License for more details.
19
20 You should have received a copy of the GNU Lesser General Public License
21 along with systemd; If not, see <http://www.gnu.org/licenses/>.
22***/
23
24#include "hashmap.h"
25
26typedef struct OrderedSet OrderedSet;
27
28static inline OrderedSet* ordered_set_new(const struct hash_ops *ops) {
29 return (OrderedSet*) ordered_hashmap_new(ops);
30}
31
32static inline OrderedSet* ordered_set_free(OrderedSet *s) {
33 ordered_hashmap_free((OrderedHashmap*) s);
34 return NULL;
35}
36
37static inline OrderedSet* ordered_set_free_free(OrderedSet *s) {
38 ordered_hashmap_free_free((OrderedHashmap*) s);
39 return NULL;
40}
41
42static inline int ordered_set_put(OrderedSet *s, void *p) {
43 return ordered_hashmap_put((OrderedHashmap*) s, p, p);
44}
45
46static inline bool ordered_set_isempty(OrderedSet *s) {
47 return ordered_hashmap_isempty((OrderedHashmap*) s);
48}
49
8927b1da
DH
50static inline bool ordered_set_iterate(OrderedSet *s, Iterator *i, void **value) {
51 return ordered_hashmap_iterate((OrderedHashmap*) s, i, value, NULL);
4a280a7e
LP
52}
53
54#define ORDERED_SET_FOREACH(e, s, i) \
8927b1da 55 for ((i) = ITERATOR_FIRST; ordered_set_iterate((s), &(i), (void**)&(e)); )
4a280a7e
LP
56
57DEFINE_TRIVIAL_CLEANUP_FUNC(OrderedSet*, ordered_set_free);
58
59#define _cleanup_ordered_set_free_ _cleanup_(ordered_set_freep)