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.
multiset.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_MULTISET_H
24 #define BKTHOMPS_CONTAINERS_MULTISET_H
25 
26 #include "_bk_defines.h"
27 
32 typedef struct internal_multiset *multiset;
33 
34 /* Starting */
35 multiset multiset_init(size_t key_size,
36  int (*comparator)(const void *const one,
37  const void *const two));
38 
39 /* Capacity */
40 size_t multiset_size(multiset me);
42 
43 /* Accessing */
44 bk_err multiset_put(multiset me, void *key);
45 size_t multiset_count(multiset me, void *key);
46 bk_bool multiset_contains(multiset me, void *key);
47 bk_bool multiset_remove(multiset me, void *key);
48 bk_bool multiset_remove_all(multiset me, void *key);
49 
50 /* Retrieval */
51 void *multiset_first(multiset me);
52 void *multiset_last(multiset me);
53 void *multiset_lower(multiset me, void *key);
54 void *multiset_higher(multiset me, void *key);
55 void *multiset_floor(multiset me, void *key);
56 void *multiset_ceiling(multiset me, void *key);
57 
58 /* Ending */
59 void multiset_clear(multiset me);
61 
62 #endif /* BKTHOMPS_CONTAINERS_MULTISET_H */
size_t multiset_size(multiset me)
Definition: multiset.c:85
void * multiset_last(multiset me)
Definition: multiset.c:799
void multiset_clear(multiset me)
Definition: multiset.c:922
size_t multiset_count(multiset me, void *key)
Definition: multiset.c:425
void * multiset_first(multiset me)
Definition: multiset.c:775
multiset multiset_init(size_t key_size, int(*comparator)(const void *const one, const void *const two))
multiset multiset_destroy(multiset me)
Definition: multiset.c:939
void * multiset_higher(multiset me, void *key)
Definition: multiset.c:849
void * multiset_ceiling(multiset me, void *key)
Definition: multiset.c:901
bk_bool multiset_remove_all(multiset me, void *key)
Definition: multiset.c:753
void * multiset_floor(multiset me, void *key)
Definition: multiset.c:875
struct internal_multiset * multiset
Definition: multiset.h:32
bk_bool multiset_is_empty(multiset me)
Definition: multiset.c:97
int bk_bool
Definition: containers.h:49
int bk_err
Definition: containers.h:48
bk_bool multiset_contains(multiset me, void *key)
Definition: multiset.c:448
bk_bool multiset_remove(multiset me, void *key)
Definition: multiset.c:723
bk_err multiset_put(multiset me, void *key)
Definition: multiset.c:325
void * multiset_lower(multiset me, void *key)
Definition: multiset.c:823
struct internal_multiset * multiset
Definition: containers.h:301