Containers
This library provides various containers. Each container has utility functions to manipulate the data it holds. This is an abstraction as to not have to manually manage and reallocate memory.
multimap.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2017-2020 Bailey Thompson
3  *
4  * Permission is hereby granted, free of charge, to any person obtaining a copy
5  * of this software and associated documentation files (the "Software"), to deal
6  * in the Software without restriction, including without limitation the rights
7  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8  * copies of the Software, and to permit persons to whom the Software is
9  * furnished to do so, subject to the following conditions:
10  *
11  * The above copyright notice and this permission notice shall be included in
12  * all copies or substantial portions of the Software.
13  *
14  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20  * SOFTWARE.
21  */
22 
23 #ifndef BKTHOMPS_CONTAINERS_MULTIMAP_H
24 #define BKTHOMPS_CONTAINERS_MULTIMAP_H
25 
26 #include "_bk_defines.h"
27 
32 typedef struct internal_multimap *multimap;
33 
34 /* Starting */
35 multimap multimap_init(size_t key_size, size_t value_size,
36  int (*key_comparator)(const void *const one,
37  const void *const two),
38  int (*value_comparator)(const void *const one,
39  const void *const two));
40 
41 /* Capacity */
42 size_t multimap_size(multimap me);
44 
45 /* Accessing */
46 bk_err multimap_put(multimap me, void *key, void *value);
47 void multimap_get_start(multimap me, void *key);
48 bk_bool multimap_get_next(void *value, multimap me);
49 size_t multimap_count(multimap me, void *key);
50 bk_bool multimap_contains(multimap me, void *key);
51 bk_bool multimap_remove(multimap me, void *key, void *value);
52 bk_bool multimap_remove_all(multimap me, void *key);
53 
54 /* Retrieval */
55 void *multimap_first(multimap me);
56 void *multimap_last(multimap me);
57 void *multimap_lower(multimap me, void *key);
58 void *multimap_higher(multimap me, void *key);
59 void *multimap_floor(multimap me, void *key);
60 void *multimap_ceiling(multimap me, void *key);
61 
62 /* Ending */
63 void multimap_clear(multimap me);
65 
66 #endif /* BKTHOMPS_CONTAINERS_MULTIMAP_H */
struct internal_multimap * multimap
Definition: multimap.h:32
void * multimap_first(multimap me)
Definition: multimap.c:922
bk_err multimap_put(multimap me, void *key, void *value)
Definition: multimap.c:367
bk_bool multimap_remove_all(multimap me, void *key)
Definition: multimap.c:903
void * multimap_last(multimap me)
Definition: multimap.c:946
bk_bool multimap_contains(multimap me, void *key)
Definition: multimap.c:554
bk_bool multimap_remove(multimap me, void *key, void *value)
Definition: multimap.c:831
void multimap_get_start(multimap me, void *key)
Definition: multimap.c:481
multimap multimap_init(size_t key_size, size_t value_size, int(*key_comparator)(const void *const one, const void *const two), int(*value_comparator)(const void *const one, const void *const two))
size_t multimap_size(multimap me)
Definition: multimap.c:103
void multimap_clear(multimap me)
Definition: multimap.c:1069
size_t multimap_count(multimap me, void *key)
Definition: multimap.c:531
void * multimap_floor(multimap me, void *key)
Definition: multimap.c:1022
int bk_bool
Definition: containers.h:49
bk_bool multimap_is_empty(multimap me)
Definition: multimap.c:115
int bk_err
Definition: containers.h:48
void * multimap_lower(multimap me, void *key)
Definition: multimap.c:970
void * multimap_higher(multimap me, void *key)
Definition: multimap.c:996
multimap multimap_destroy(multimap me)
Definition: multimap.c:1085
bk_bool multimap_get_next(void *value, multimap me)
Definition: multimap.c:505
void * multimap_ceiling(multimap me, void *key)
Definition: multimap.c:1048
struct internal_multimap * multimap
Definition: containers.h:257