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.
map.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_MAP_H
24 #define BKTHOMPS_CONTAINERS_MAP_H
25 
26 #include "_bk_defines.h"
27 
32 typedef struct internal_map *map;
33 
34 /* Starting */
35 map map_init(size_t key_size, size_t value_size,
36  int (*comparator)(const void *const one, const void *const two));
37 
38 /* Capacity */
39 size_t map_size(map me);
41 
42 /* Accessing */
43 bk_err map_put(map me, void *key, void *value);
44 bk_bool map_get(void *value, map me, void *key);
45 bk_bool map_contains(map me, void *key);
46 bk_bool map_remove(map me, void *key);
47 
48 /* Retrieval */
49 void *map_first(map me);
50 void *map_last(map me);
51 void *map_lower(map me, void *key);
52 void *map_higher(map me, void *key);
53 void *map_floor(map me, void *key);
54 void *map_ceiling(map me, void *key);
55 
56 /* Ending */
57 void map_clear(map me);
58 map map_destroy(map me);
59 
60 #endif /* BKTHOMPS_CONTAINERS_MAP_H */
struct internal_map * map
Definition: map.h:32
bk_err map_put(map me, void *key, void *value)
Definition: map.c:320
struct internal_map * map
Definition: containers.h:219
bk_bool map_get(void *value, map me, void *key)
Definition: map.c:419
void * map_lower(map me, void *key)
Definition: map.c:781
bk_bool map_is_empty(map me)
Definition: map.c:98
int bk_bool
Definition: containers.h:49
void * map_higher(map me, void *key)
Definition: map.c:807
void * map_floor(map me, void *key)
Definition: map.c:833
map map_destroy(map me)
Definition: map.c:896
void map_clear(map me)
Definition: map.c:880
void * map_first(map me)
Definition: map.c:733
int bk_err
Definition: containers.h:48
bk_bool map_remove(map me, void *key)
Definition: map.c:714
size_t map_size(map me)
Definition: map.c:86
void * map_last(map me)
Definition: map.c:757
void * map_ceiling(map me, void *key)
Definition: map.c:859
bk_bool map_contains(map me, void *key)
Definition: map.c:441
map map_init(size_t key_size, size_t value_size, int(*comparator)(const void *const one, const void *const two))