]>
git.proxmox.com Git - mirror_ovs.git/blob - lib/simap.h
2 * Copyright (c) 2009, 2010, 2011, 2012 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.
26 /* A map from strings to unsigned integers. */
28 struct hmap map
; /* Contains "struct simap_node"s. */
32 struct hmap_node node
; /* In struct simap's 'map' hmap. */
37 #define SIMAP_INITIALIZER(SIMAP) { HMAP_INITIALIZER(&(SIMAP)->map) }
39 #define SIMAP_FOR_EACH(SIMAP_NODE, SIMAP) \
40 HMAP_FOR_EACH (SIMAP_NODE, node, &(SIMAP)->map)
42 #define SIMAP_FOR_EACH_SAFE(SIMAP_NODE, NEXT, SIMAP) \
43 HMAP_FOR_EACH_SAFE (SIMAP_NODE, NEXT, node, &(SIMAP)->map)
45 void simap_init(struct simap
*);
46 void simap_destroy(struct simap
*);
47 void simap_swap(struct simap
*, struct simap
*);
48 void simap_moved(struct simap
*);
49 void simap_clear(struct simap
*);
51 bool simap_is_empty(const struct simap
*);
52 size_t simap_count(const struct simap
*);
54 bool simap_put(struct simap
*, const char *, unsigned int);
55 unsigned int simap_increase(struct simap
*, const char *, unsigned int);
57 unsigned int simap_get(const struct simap
*, const char *);
58 struct simap_node
*simap_find(const struct simap
*, const char *);
59 struct simap_node
*simap_find_len(const struct simap
*,
60 const char *, size_t len
);
62 void simap_delete(struct simap
*, struct simap_node
*);
64 const struct simap_node
**simap_sort(const struct simap
*);