]>
git.proxmox.com Git - mirror_ovs.git/blob - lib/hmapx.h
2 * Copyright (c) 2011, 2016 Nicira, Inc.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at:
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
20 #include "openvswitch/hmap.h"
23 struct hmap_node hmap_node
;
27 /* A set of "void *" pointers. */
32 #define HMAPX_INITIALIZER(HMAPX) { HMAP_INITIALIZER(&(HMAPX)->map) }
35 void hmapx_init(struct hmapx
*);
36 void hmapx_destroy(struct hmapx
*);
37 void hmapx_clone(struct hmapx
*, const struct hmapx
*);
38 void hmapx_swap(struct hmapx
*, struct hmapx
*);
39 void hmapx_moved(struct hmapx
*);
42 bool hmapx_is_empty(const struct hmapx
*);
43 size_t hmapx_count(const struct hmapx
*);
46 struct hmapx_node
*hmapx_add(struct hmapx
*, void *);
47 void hmapx_add_assert(struct hmapx
*, void *);
50 void hmapx_clear(struct hmapx
*);
51 void hmapx_delete(struct hmapx
*, struct hmapx_node
*);
52 bool hmapx_find_and_delete(struct hmapx
*, const void *);
53 void hmapx_find_and_delete_assert(struct hmapx
*, const void *);
56 struct hmapx_node
*hmapx_find(const struct hmapx
*, const void *);
57 bool hmapx_contains(const struct hmapx
*, const void *);
58 bool hmapx_equals(const struct hmapx
*, const struct hmapx
*);
62 /* Iterates through every hmapx_node in HMAPX. */
63 #define HMAPX_FOR_EACH(NODE, HMAPX) \
64 HMAP_FOR_EACH_INIT(NODE, hmap_node, &(HMAPX)->map, \
65 BUILD_ASSERT_TYPE(NODE, struct hmapx_node *), \
66 BUILD_ASSERT_TYPE(HMAPX, struct hmapx *))
68 /* Safe when NODE may be freed (not needed when NODE may be removed from the
69 * hash map but its members remain accessible and intact). */
70 #define HMAPX_FOR_EACH_SAFE(NODE, NEXT, HMAPX) \
71 HMAP_FOR_EACH_SAFE_INIT(NODE, NEXT, hmap_node, &(HMAPX)->map, \
72 BUILD_ASSERT_TYPE(NODE, struct hmapx_node *), \
73 BUILD_ASSERT_TYPE(NEXT, struct hmapx_node *), \
74 BUILD_ASSERT_TYPE(HMAPX, struct hmapx *))