00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifndef CUCON_HSET_H
00019 #define CUCON_HSET_H
00020
00021 #include <cucon/hmap.h>
00022
00023 CU_BEGIN_DECLARATIONS
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035 struct cucon_hset
00036 {
00037 struct cucon_hmap impl;
00038 };
00039
00040
00041
00042 CU_SINLINE void
00043 cucon_hset_init(cucon_hset_t set,
00044 cu_clop(eq, cu_bool_t, void const *, void const *),
00045 cu_clop(hash, cu_hash_t, void const *))
00046 { cucon_hmap_init(&set->impl, eq, hash); }
00047
00048
00049
00050 CU_SINLINE cucon_hset_t
00051 cucon_hset_new(cu_clop(eq, cu_bool_t, void const *, void const *),
00052 cu_clop(hash, cu_hash_t, void const *))
00053 { return (cucon_hset_t)cucon_hmap_new(eq, hash); }
00054
00055
00056 CU_SINLINE size_t
00057 cucon_hset_card(cucon_hset_t set)
00058 { return cucon_hmap_card(&set->impl); }
00059
00060
00061 CU_SINLINE cu_bool_t
00062 cucon_hset_is_empty(cucon_hset_t set)
00063 { return cucon_hmap_is_empty(&set->impl); }
00064
00065
00066 CU_SINLINE cu_bool_t
00067 cucon_hset_contains(cucon_hset_t set, void const *key)
00068 { return cucon_hmap_find_mem(&set->impl, key) != NULL; }
00069
00070
00071
00072 CU_SINLINE cu_bool_t
00073 cucon_hset_insert(cucon_hset_t set, void const *key)
00074 {
00075 void *slot;
00076 return cucon_hmap_insert_mem(&set->impl, key, 0, &slot);
00077 }
00078
00079
00080
00081 CU_SINLINE cu_bool_t
00082 cucon_hset_erase(cucon_hset_t set, void const *key)
00083 { return cucon_hmap_erase(&set->impl, key); }
00084
00085
00086
00087 CU_SINLINE cu_bool_t
00088 cucon_hset_isocap_erase(cucon_hset_t set, void const *key)
00089 { return cucon_hmap_isocap_erase(&set->impl, key); }
00090
00091
00092
00093
00094
00095
00096 CU_SINLINE void
00097 cucon_hset_set_capacity(cucon_hset_t set, int cap)
00098 { cucon_hmap_set_capacity(&set->impl, cap); }
00099
00100 CU_SINLINE cu_bool_t
00101 cucon_hset_conj(cucon_hset_t set, cu_clop(f, cu_bool_t, void const *))
00102 { return cucon_hmap_conj_keys(&set->impl, f); }
00103
00104
00105 cu_bool_t cucon_hset_eq(cucon_hset_t S0, cucon_hset_t S1);
00106
00107
00108 cu_bool_t cucon_hset_sub(cucon_hset_t S0, cucon_hset_t S1);
00109
00110
00111 cu_bool_t cucon_hset_subeq(cucon_hset_t hs0, cucon_hset_t hs1);
00112
00113
00114
00115 #if defined(CU_COMPAT) && CU_COMPAT < 20091116
00116 # define cucon_hset_size cucon_hset_card
00117 # define cucon_hset_erase_keep_capacity cucon_hset_isocap_erase
00118 #endif
00119
00120 CU_END_DECLARATIONS
00121
00122 #endif