1 #include <isl_hmap_map_basic_set.h>
3 struct isl_map_basic_set_pair
{
8 __isl_give isl_hmap_map_basic_set
*isl_hmap_map_basic_set_alloc(isl_ctx
*ctx
,
11 return (isl_hmap_map_basic_set
*) isl_hash_table_alloc(ctx
, min_size
);
14 static int free_pair(void **entry
, void *user
)
16 struct isl_map_basic_set_pair
*pair
= *entry
;
17 isl_map_free(pair
->key
);
18 isl_basic_set_free(pair
->val
);
24 void isl_hmap_map_basic_set_free(isl_ctx
*ctx
,
25 __isl_take isl_hmap_map_basic_set
*hmap
)
29 isl_hash_table_foreach(ctx
, &hmap
->table
, &free_pair
, NULL
);
30 isl_hash_table_free(ctx
, &hmap
->table
);
33 static int has_key(const void *entry
, const void *key
)
35 const struct isl_map_basic_set_pair
*pair
= entry
;
36 isl_map
*map
= (isl_map
*)key
;
38 return isl_map_fast_is_equal(pair
->key
, map
);
41 int isl_hmap_map_basic_set_has(isl_ctx
*ctx
,
42 __isl_keep isl_hmap_map_basic_set
*hmap
, __isl_keep isl_map
*key
)
46 hash
= isl_map_get_hash(key
);
47 return !!isl_hash_table_find(ctx
, &hmap
->table
, hash
, &has_key
, key
, 0);
50 __isl_give isl_basic_set
*isl_hmap_map_basic_set_get(isl_ctx
*ctx
,
51 __isl_keep isl_hmap_map_basic_set
*hmap
, __isl_take isl_map
*key
)
53 struct isl_hash_table_entry
*entry
;
54 struct isl_map_basic_set_pair
*pair
;
57 hash
= isl_map_get_hash(key
);
58 entry
= isl_hash_table_find(ctx
, &hmap
->table
, hash
, &has_key
, key
, 0);
66 return isl_basic_set_copy(pair
->val
);
69 int isl_hmap_map_basic_set_set(isl_ctx
*ctx
,
70 __isl_keep isl_hmap_map_basic_set
*hmap
, __isl_take isl_map
*key
,
71 __isl_take isl_basic_set
*val
)
73 struct isl_hash_table_entry
*entry
;
74 struct isl_map_basic_set_pair
*pair
;
77 hash
= isl_map_get_hash(key
);
78 entry
= isl_hash_table_find(ctx
, &hmap
->table
, hash
, &has_key
, key
, 1);
85 isl_basic_set_free(pair
->val
);
91 pair
= isl_alloc_type(ctx
, struct isl_map_basic_set_pair
);
94 isl_basic_set_free(val
);