cdcontainers  0.1.1
Library of data containers and collections for C programming language.
imap.h
Go to the documentation of this file.
1 // The MIT License (MIT)
2 // Copyright (c) 2018 Maksim Andrianov
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
6 // deal in the Software without restriction, including without limitation the
7 // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
8 // sell 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
19 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
20 // IN THE SOFTWARE.
26 #ifndef CDCONTAINERS_INCLUDE_CDCONTAINERS_INTERFACES_IMAP_H
27 #define CDCONTAINERS_INCLUDE_CDCONTAINERS_INTERFACES_IMAP_H
28 
29 #include <cdcontainers/common.h>
30 #include <cdcontainers/status.h>
31 
32 #include <stdarg.h>
33 #include <stdbool.h>
34 #include <stdlib.h>
35 
42  void *(*ctor)();
43  void (*dtor)(void *it);
45  void (*next)(void *it);
46  void (*prev)(void *it);
47  bool (*has_next)(void *it);
48  bool (*has_prev)(void *it);
49  void *(*key)(void *it);
50  void *(*value)(void *it);
51  struct cdc_pair (*key_value)(void *it);
52  bool (*eq)(void *it1, void *it2);
53 };
54 
60 struct cdc_map_table {
61  enum cdc_stat (*ctor)(void **cntr, struct cdc_data_info *info);
62  enum cdc_stat (*ctorv)(void **cntr, struct cdc_data_info *info, va_list args);
63  void (*dtor)(void *cntr);
64  enum cdc_stat (*get)(void *cntr, void *key, void **value);
65  size_t (*count)(void *cntr, void *key);
66  void (*find)(void *cntr, void *key, void *it);
67  size_t (*size)(void *cntr);
68  bool (*empty)(void *cntr);
69  void (*clear)(void *cntr);
70  enum cdc_stat (*insert)(void *cntr, void *key, void *value, void *it,
71  bool *inserted);
72  enum cdc_stat (*insert_or_assign)(void *cntr, void *key, void *value,
73  void *it, bool *inserted);
74  size_t (*erase)(void *cntr, void *key);
75  void (*swap)(void *a, void *b);
76  void (*begin)(void *cntr, void *it);
77  void (*end)(void *cntr, void *it);
79 };
80 
81 extern const struct cdc_map_table *cdc_map_avl;
82 extern const struct cdc_map_table *cdc_map_splay;
83 extern const struct cdc_map_table *cdc_map_treap;
84 extern const struct cdc_map_table *cdc_map_htable;
85 
86 #endif // CDCONTAINERS_INCLUDE_CDCONTAINERS_INTERFACES_IMAP_H
bool(* has_next)(void *it)
Definition: imap.h:47
const struct cdc_map_table * cdc_map_splay
const struct cdc_map_iter_table * iter_table
Definition: imap.h:78
bool(* has_prev)(void *it)
Definition: imap.h:48
void *(* ctor)()
Definition: imap.h:42
void *(* value)(void *it)
Definition: imap.h:50
void(* next)(void *it)
Definition: imap.h:45
const struct cdc_map_table * cdc_map_treap
The cdc_map_table struct.
Definition: imap.h:60
cdc_iterator_type
Definition: common.h:115
Definition: common.h:60
The cdc_map_iter_table struct.
Definition: imap.h:41
const struct cdc_map_table * cdc_map_htable
bool(* eq)(void *it1, void *it2)
Definition: imap.h:52
cdc_stat
Definition: status.h:24
void(* dtor)(void *it)
Definition: imap.h:43
void(* prev)(void *it)
Definition: imap.h:46
void *(* key)(void *it)
Definition: imap.h:49
const struct cdc_map_table * cdc_map_avl
enum cdc_iterator_type(* type)()
Definition: imap.h:44
struct cdc_pair(* key_value)(void *it)
Definition: imap.h:51
The cdc_data_info struct used to initialize contaners.
Definition: common.h:71
size_t size
Definition: common.h:95