cdcontainers  0.1.1
Library of data containers and collections for C programming language.
data-info.h
Go to the documentation of this file.
1 // The MIT License (MIT)
2 // Copyright (c) 2017 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.
21 #ifndef CDCONTAINERS_SRC_DATA_INFO_H
22 #define CDCONTAINERS_SRC_DATA_INFO_H
23 
24 #include <cdcontainers/common.h>
25 
26 struct cdc_data_info *cdc_di_shared_ctorc(struct cdc_data_info *other);
27 void cdc_di_shared_dtor(struct cdc_data_info *info);
28 
29 #define CDC_HAS_DFREE(dinfo) (dinfo && dinfo->dfree)
30 #define CDC_HAS_CMP(dinfo) (dinfo && dinfo->cmp)
31 #define CDC_HAS_EQ(dinfo) (dinfo && dinfo->eq)
32 #define CDC_HAS_HASH(dinfo) (dinfo && dinfo->hash)
33 #define CDC_HAS_CP(dinfo) (dinfo && dinfo->cp)
34 #define CDC_HAS_SIZE(dinfo) (dinfo && dinfo->size)
35 
36 static inline int cdc_eq(int (*pred)(const void *, const void *), const void *l,
37  const void *r)
38 {
39  return !(pred(l, r) || pred(r, l));
40 }
41 
42 static inline int cdc_not_eq(int (*pred)(const void *, const void *),
43  const void *l, const void *r)
44 {
45  return pred(l, r) || pred(r, l);
46 }
47 
48 static inline int cdc_gt(int (*pred)(const void *, const void *), const void *l,
49  const void *r)
50 {
51  return pred(r, l);
52 }
53 
54 static inline int cdc_gte(int (*pred)(const void *, const void *),
55  const void *l, const void *r)
56 {
57  return !pred(l, r);
58 }
59 
60 static inline int cdc_lte(int (*pred)(const void *, const void *),
61  const void *l, const void *r)
62 {
63  return !pred(r, l);
64 }
65 
66 #endif // CDCONTAINERS_SRC_DATA_INFO_Hs
void cdc_di_shared_dtor(struct cdc_data_info *info)
static int cdc_gt(int(*pred)(const void *, const void *), const void *l, const void *r)
Definition: data-info.h:48
static int cdc_gte(int(*pred)(const void *, const void *), const void *l, const void *r)
Definition: data-info.h:54
static int cdc_not_eq(int(*pred)(const void *, const void *), const void *l, const void *r)
Definition: data-info.h:42
struct cdc_data_info * cdc_di_shared_ctorc(struct cdc_data_info *other)
static int cdc_lte(int(*pred)(const void *, const void *), const void *l, const void *r)
Definition: data-info.h:60
static int cdc_eq(int(*pred)(const void *, const void *), const void *l, const void *r)
Definition: data-info.h:36
The cdc_data_info struct used to initialize contaners.
Definition: common.h:71