Simplified name for functions table ftab_key to fkey and ftab_val to fval

This commit is contained in:
Leonardo committed 2020-04-14 23:18:56 -03:00
1 parent 5e13c7ba91
commit eb13fcad01
46 files changed
+841 -856

No files matched your search

+12 -12
View File
@@ -86,10 +86,10 @@ static const char *cmc_string_fmt_bidimap = "struct %s<%s, %s> "
int flag; \
\
/* Key function table */ \
struct SNAME##_ftab_key *f_key; \
struct SNAME##_fkey *f_key; \
\
/* Value function table */ \
struct SNAME##_ftab_val *f_val; \
struct SNAME##_fval *f_val; \
\
/* Custom allocation functions */ \
struct cmc_alloc_node *alloc; \
@@ -128,7 +128,7 @@ static const char *cmc_string_fmt_bidimap = "struct %s<%s, %s> "
}; \
\
/* Key struct function table */ \
struct SNAME##_ftab_key \
struct SNAME##_fkey \
{ \
/* Comparator function */ \
int (*cmp)(K, K); \
@@ -150,7 +150,7 @@ static const char *cmc_string_fmt_bidimap = "struct %s<%s, %s> "
}; \
\
/* Value struct function table */ \
struct SNAME##_ftab_val \
struct SNAME##_fval \
{ \
/* Comparator function */ \
int (*cmp)(V, V); \
@@ -199,11 +199,11 @@ static const char *cmc_string_fmt_bidimap = "struct %s<%s, %s> "
/* Collection Functions */ \
/* Collection Allocation and Deallocation */ \
struct SNAME *PFX##_new(size_t capacity, double load, \
struct SNAME##_ftab_key *f_key, \
struct SNAME##_ftab_val *f_val); \
struct SNAME##_fkey *f_key, \
struct SNAME##_fval *f_val); \
struct SNAME *PFX##_new_custom( \
size_t capacity, double load, struct SNAME##_ftab_key *f_key, \
struct SNAME##_ftab_val *f_val, struct cmc_alloc_node *alloc, \
size_t capacity, double load, struct SNAME##_fkey *f_key, \
struct SNAME##_fval *f_val, struct cmc_alloc_node *alloc, \
struct cmc_callbacks *callbacks); \
void PFX##_clear(struct SNAME *_map_); \
void PFX##_free(struct SNAME *_map_); \
@@ -280,8 +280,8 @@ static const char *cmc_string_fmt_bidimap = "struct %s<%s, %s> "
static struct SNAME##_iter PFX##_impl_it_end(struct SNAME *_map_); \
\
struct SNAME *PFX##_new(size_t capacity, double load, \
struct SNAME##_ftab_key *f_key, \
struct SNAME##_ftab_val *f_val) \
struct SNAME##_fkey *f_key, \
struct SNAME##_fval *f_val) \
{ \
struct cmc_alloc_node *alloc = &cmc_alloc_node_default; \
\
@@ -327,8 +327,8 @@ static const char *cmc_string_fmt_bidimap = "struct %s<%s, %s> "
} \
\
struct SNAME *PFX##_new_custom( \
size_t capacity, double load, struct SNAME##_ftab_key *f_key, \
struct SNAME##_ftab_val *f_val, struct cmc_alloc_node *alloc, \
size_t capacity, double load, struct SNAME##_fkey *f_key, \
struct SNAME##_fval *f_val, struct cmc_alloc_node *alloc, \
struct cmc_callbacks *callbacks) \
{ \
if (capacity == 0 || load <= 0 || load >= 1) \
+6 -6
View File
@@ -88,7 +88,7 @@ static const char *cmc_string_fmt_deque = "struct %s<%s> "
/* Flags indicating errors or success */ \
int flag; \
\
struct SNAME##_ftab_val *f_val; \
struct SNAME##_fval *f_val; \
\
/* Custom allocation functions */ \
struct cmc_alloc_node *alloc; \
@@ -103,7 +103,7 @@ static const char *cmc_string_fmt_deque = "struct %s<%s> "
struct SNAME##_iter (*it_end)(struct SNAME *); \
}; \
\
struct SNAME##_ftab_val \
struct SNAME##_fval \
{ \
/* Comparator function */ \
int (*cmp)(V, V); \
@@ -145,9 +145,9 @@ static const char *cmc_string_fmt_deque = "struct %s<%s> "
\
/* Collection Functions */ \
/* Collection Allocation and Deallocation */ \
struct SNAME *PFX##_new(size_t capacity, struct SNAME##_ftab_val *f_val); \
struct SNAME *PFX##_new(size_t capacity, struct SNAME##_fval *f_val); \
struct SNAME *PFX##_new_custom( \
size_t capacity, struct SNAME##_ftab_val *f_val, \
size_t capacity, struct SNAME##_fval *f_val, \
struct cmc_alloc_node *alloc, struct cmc_callbacks *callbacks); \
void PFX##_clear(struct SNAME *_deque_); \
void PFX##_free(struct SNAME *_deque_); \
@@ -207,7 +207,7 @@ static const char *cmc_string_fmt_deque = "struct %s<%s> "
static struct SNAME##_iter PFX##_impl_it_start(struct SNAME *_deque_); \
static struct SNAME##_iter PFX##_impl_it_end(struct SNAME *_deque_); \
\
struct SNAME *PFX##_new(size_t capacity, struct SNAME##_ftab_val *f_val) \
struct SNAME *PFX##_new(size_t capacity, struct SNAME##_fval *f_val) \
{ \
struct cmc_alloc_node *alloc = &cmc_alloc_node_default; \
\
@@ -245,7 +245,7 @@ static const char *cmc_string_fmt_deque = "struct %s<%s> "
} \
\
struct SNAME *PFX##_new_custom( \
size_t capacity, struct SNAME##_ftab_val *f_val, \
size_t capacity, struct SNAME##_fval *f_val, \
struct cmc_alloc_node *alloc, struct cmc_callbacks *callbacks) \
{ \
if (capacity < 1) \
+12 -12
View File
@@ -79,10 +79,10 @@ static const char *cmc_string_fmt_hashmap = "struct %s<%s, %s> "
int flag; \
\
/* Key function table */ \
struct SNAME##_ftab_key *f_key; \
struct SNAME##_fkey *f_key; \
\
/* Value function table */ \
struct SNAME##_ftab_val *f_val; \
struct SNAME##_fval *f_val; \
\
/* Custom allocation functions */ \
struct cmc_alloc_node *alloc; \
@@ -115,7 +115,7 @@ static const char *cmc_string_fmt_hashmap = "struct %s<%s, %s> "
}; \
\
/* Key struct function table */ \
struct SNAME##_ftab_key \
struct SNAME##_fkey \
{ \
/* Comparator function */ \
int (*cmp)(K, K); \
@@ -137,7 +137,7 @@ static const char *cmc_string_fmt_hashmap = "struct %s<%s, %s> "
}; \
\
/* Value struct function table */ \
struct SNAME##_ftab_val \
struct SNAME##_fval \
{ \
/* Comparator function */ \
int (*cmp)(V, V); \
@@ -186,11 +186,11 @@ static const char *cmc_string_fmt_hashmap = "struct %s<%s, %s> "
/* Collection Functions */ \
/* Collection Allocation and Deallocation */ \
struct SNAME *PFX##_new(size_t capacity, double load, \
struct SNAME##_ftab_key *f_key, \
struct SNAME##_ftab_val *f_val); \
struct SNAME##_fkey *f_key, \
struct SNAME##_fval *f_val); \
struct SNAME *PFX##_new_custom( \
size_t capacity, double load, struct SNAME##_ftab_key *f_key, \
struct SNAME##_ftab_val *f_val, struct cmc_alloc_node *alloc, \
size_t capacity, double load, struct SNAME##_fkey *f_key, \
struct SNAME##_fval *f_val, struct cmc_alloc_node *alloc, \
struct cmc_callbacks *callbacks); \
void PFX##_clear(struct SNAME *_map_); \
void PFX##_free(struct SNAME *_map_); \
@@ -257,8 +257,8 @@ static const char *cmc_string_fmt_hashmap = "struct %s<%s, %s> "
static struct SNAME##_iter PFX##_impl_it_end(struct SNAME *_map_); \
\
struct SNAME *PFX##_new(size_t capacity, double load, \
struct SNAME##_ftab_key *f_key, \
struct SNAME##_ftab_val *f_val) \
struct SNAME##_fkey *f_key, \
struct SNAME##_fval *f_val) \
{ \
struct cmc_alloc_node *alloc = &cmc_alloc_node_default; \
\
@@ -303,8 +303,8 @@ static const char *cmc_string_fmt_hashmap = "struct %s<%s, %s> "
} \
\
struct SNAME *PFX##_new_custom( \
size_t capacity, double load, struct SNAME##_ftab_key *f_key, \
struct SNAME##_ftab_val *f_val, struct cmc_alloc_node *alloc, \
size_t capacity, double load, struct SNAME##_fkey *f_key, \
struct SNAME##_fval *f_val, struct cmc_alloc_node *alloc, \
struct cmc_callbacks *callbacks) \
{ \
if (capacity == 0 || load <= 0 || load >= 1) \
+6 -6
View File
@@ -78,7 +78,7 @@ static const char *cmc_string_fmt_hashset = "struct %s<%s> "
int flag; \
\
/* Value function table */ \
struct SNAME##_ftab_val *f_val; \
struct SNAME##_fval *f_val; \
\
/* Custom allocation functions */ \
struct cmc_alloc_node *alloc; \
@@ -107,7 +107,7 @@ static const char *cmc_string_fmt_hashset = "struct %s<%s> "
}; \
\
/* Value struct function table */ \
struct SNAME##_ftab_val \
struct SNAME##_fval \
{ \
/* Comparator function */ \
int (*cmp)(V, V); \
@@ -156,9 +156,9 @@ static const char *cmc_string_fmt_hashset = "struct %s<%s> "
/* Collection Functions */ \
/* Collection Allocation and Deallocation */ \
struct SNAME *PFX##_new(size_t capacity, double load, \
struct SNAME##_ftab_val *f_val); \
struct SNAME##_fval *f_val); \
struct SNAME *PFX##_new_custom( \
size_t capacity, double load, struct SNAME##_ftab_val *f_val, \
size_t capacity, double load, struct SNAME##_fval *f_val, \
struct cmc_alloc_node *alloc, struct cmc_callbacks *callbacks); \
void PFX##_clear(struct SNAME *_set_); \
void PFX##_free(struct SNAME *_set_); \
@@ -234,7 +234,7 @@ static const char *cmc_string_fmt_hashset = "struct %s<%s> "
static struct SNAME##_iter PFX##_impl_it_end(struct SNAME *_set_); \
\
struct SNAME *PFX##_new(size_t capacity, double load, \
struct SNAME##_ftab_val *f_val) \
struct SNAME##_fval *f_val) \
{ \
struct cmc_alloc_node *alloc = &cmc_alloc_node_default; \
\
@@ -278,7 +278,7 @@ static const char *cmc_string_fmt_hashset = "struct %s<%s> "
} \
\
struct SNAME *PFX##_new_custom( \
size_t capacity, double load, struct SNAME##_ftab_val *f_val, \
size_t capacity, double load, struct SNAME##_fval *f_val, \
struct cmc_alloc_node *alloc, struct cmc_callbacks *callbacks) \
{ \
if (capacity == 0 || load <= 0 || load >= 1) \
+10 -12
View File
@@ -100,7 +100,7 @@ static const char *cmc_string_fmt_heap = "struct %s<%s> "
int flag; \
\
/* Value function table */ \
struct SNAME##_ftab_val *f_val; \
struct SNAME##_fval *f_val; \
\
/* Custom allocation functions */ \
struct cmc_alloc_node *alloc; \
@@ -116,7 +116,7 @@ static const char *cmc_string_fmt_heap = "struct %s<%s> "
}; \
\
/* Value struct function table */ \
struct SNAME##_ftab_val \
struct SNAME##_fval \
{ \
/* Comparator function */ \
int (*cmp)(V, V); \
@@ -156,11 +156,10 @@ static const char *cmc_string_fmt_heap = "struct %s<%s> "
/* Collection Functions */ \
/* Collection Allocation and Deallocation */ \
struct SNAME *PFX##_new(size_t capacity, enum cmc_heap_order HO, \
struct SNAME##_ftab_val *f_val); \
struct SNAME *PFX##_new_custom(size_t capacity, enum cmc_heap_order HO, \
struct SNAME##_ftab_val *f_val, \
struct cmc_alloc_node *alloc, \
struct cmc_callbacks *callbacks); \
struct SNAME##_fval *f_val); \
struct SNAME *PFX##_new_custom( \
size_t capacity, enum cmc_heap_order HO, struct SNAME##_fval *f_val, \
struct cmc_alloc_node *alloc, struct cmc_callbacks *callbacks); \
void PFX##_clear(struct SNAME *_heap_); \
void PFX##_free(struct SNAME *_heap_); \
/* Customization of Allocation and Callbacks */ \
@@ -218,7 +217,7 @@ static const char *cmc_string_fmt_heap = "struct %s<%s> "
static struct SNAME##_iter PFX##_impl_it_end(struct SNAME *_heap_); \
\
struct SNAME *PFX##_new(size_t capacity, enum cmc_heap_order HO, \
struct SNAME##_ftab_val *f_val) \
struct SNAME##_fval *f_val) \
{ \
struct cmc_alloc_node *alloc = &cmc_alloc_node_default; \
\
@@ -257,10 +256,9 @@ static const char *cmc_string_fmt_heap = "struct %s<%s> "
return _heap_; \
} \
\
struct SNAME *PFX##_new_custom(size_t capacity, enum cmc_heap_order HO, \
struct SNAME##_ftab_val *f_val, \
struct cmc_alloc_node *alloc, \
struct cmc_callbacks *callbacks) \
struct SNAME *PFX##_new_custom( \
size_t capacity, enum cmc_heap_order HO, struct SNAME##_fval *f_val, \
struct cmc_alloc_node *alloc, struct cmc_callbacks *callbacks) \
{ \
if (capacity < 1) \
return NULL; \
+138 -138
View File
@@ -54,142 +54,142 @@ static const char *cmc_string_fmt_intervalheap = "struct %s<%s> "
/* -------------------------------------------------------------------------
* Header
* ------------------------------------------------------------------------- */
#define CMC_GENERATE_INTERVALHEAP_HEADER(PFX, SNAME, V) \
\
/* Heap Structure */ \
struct SNAME \
{ \
/* Dynamic array of nodes */ \
struct SNAME##_node *buffer; \
\
/* Current array capacity (how many nodes can be stored) */ \
size_t capacity; \
\
/* Current amount of nodes in the dynamic array */ \
size_t size; \
\
/* Current amount of elements in the heap */ \
size_t count; \
\
/* Flags indicating errors or success */ \
int flag; \
\
/* Value function table */ \
struct SNAME##_ftab_val *f_val; \
\
/* Function that returns an iterator to the start of the heap */ \
struct SNAME##_iter (*it_start)(struct SNAME *); \
\
/* Function that returns an iterator to the end of the heap */ \
struct SNAME##_iter (*it_end)(struct SNAME *); \
\
/* Custom allocation functions */ \
struct cmc_alloc_node *alloc; \
\
/* Custom callback functions */ \
struct cmc_callbacks *callbacks; \
}; \
\
/* Heap Node */ \
struct SNAME##_node \
{ \
/* 0 - Value belonging to the MinHeap */ \
/* 1 - Value belonging to the MaxHeap */ \
V data[2]; \
}; \
\
/* Value struct function table */ \
struct SNAME##_ftab_val \
{ \
/* Comparator function */ \
int (*cmp)(V, V); \
\
/* Copy function */ \
V (*cpy)(V); \
\
/* To string function */ \
bool (*str)(FILE *, V); \
\
/* Free from memory function */ \
void (*free)(V); \
\
/* Hash function */ \
size_t (*hash)(V); \
\
/* Priority function */ \
int (*pri)(V, V); \
}; \
\
/* Heap Iterator */ \
struct SNAME##_iter \
{ \
/* Target heap */ \
struct SNAME *target; \
\
/* Cursor's position (index) */ \
size_t cursor; \
\
/* If the iterator has reached the start of the iteration */ \
bool start; \
\
/* If the iterator has reached the end of the iteration */ \
bool end; \
}; \
\
/* Collection Functions */ \
/* Collection Allocation and Deallocation */ \
struct SNAME *PFX##_new(size_t capacity, struct SNAME##_ftab_val *f_val); \
struct SNAME *PFX##_new_custom( \
size_t capacity, struct SNAME##_ftab_val *f_val, \
struct cmc_alloc_node *alloc, struct cmc_callbacks *callbacks); \
void PFX##_clear(struct SNAME *_heap_); \
void PFX##_free(struct SNAME *_heap_); \
/* Customization of Allocation and Callbacks */ \
void PFX##_customize(struct SNAME *_heap_, struct cmc_alloc_node *alloc, \
struct cmc_callbacks *callbacks); \
/* Collection Input and Output */ \
bool PFX##_insert(struct SNAME *_heap_, V element); \
bool PFX##_remove_max(struct SNAME *_heap_); \
bool PFX##_remove_min(struct SNAME *_heap_); \
/* Collection Update */ \
bool PFX##_update_max(struct SNAME *_heap_, V element); \
bool PFX##_update_min(struct SNAME *_heap_, V element); \
/* Element Access */ \
V PFX##_max(struct SNAME *_heap_); \
V PFX##_min(struct SNAME *_heap_); \
/* Collection State */ \
bool PFX##_contains(struct SNAME *_heap_, V element); \
bool PFX##_empty(struct SNAME *_heap_); \
bool PFX##_full(struct SNAME *_heap_); \
size_t PFX##_count(struct SNAME *_heap_); \
size_t PFX##_capacity(struct SNAME *_heap_); \
int PFX##_flag(struct SNAME *_heap_); \
/* Collection Utility */ \
bool PFX##_resize(struct SNAME *_heap_, size_t capacity); \
struct SNAME *PFX##_copy_of(struct SNAME *_set_); \
bool PFX##_equals(struct SNAME *_heap1_, struct SNAME *_heap2_); \
struct cmc_string PFX##_to_string(struct SNAME *_heap_); \
bool PFX##_print(struct SNAME *_heap_, FILE *fptr); \
\
/* Iterator Functions */ \
/* Iterator Allocation and Deallocation */ \
struct SNAME##_iter *PFX##_iter_new(struct SNAME *target); \
void PFX##_iter_free(struct SNAME##_iter *iter); \
/* Iterator Initialization */ \
void PFX##_iter_init(struct SNAME##_iter *iter, struct SNAME *target); \
/* Iterator State */ \
bool PFX##_iter_start(struct SNAME##_iter *iter); \
bool PFX##_iter_end(struct SNAME##_iter *iter); \
/* Iterator Movement */ \
void PFX##_iter_to_start(struct SNAME##_iter *iter); \
void PFX##_iter_to_end(struct SNAME##_iter *iter); \
bool PFX##_iter_next(struct SNAME##_iter *iter); \
bool PFX##_iter_prev(struct SNAME##_iter *iter); \
bool PFX##_iter_advance(struct SNAME##_iter *iter, size_t steps); \
bool PFX##_iter_rewind(struct SNAME##_iter *iter, size_t steps); \
bool PFX##_iter_go_to(struct SNAME##_iter *iter, size_t index); \
/* Iterator Access */ \
V PFX##_iter_value(struct SNAME##_iter *iter); \
#define CMC_GENERATE_INTERVALHEAP_HEADER(PFX, SNAME, V) \
\
/* Heap Structure */ \
struct SNAME \
{ \
/* Dynamic array of nodes */ \
struct SNAME##_node *buffer; \
\
/* Current array capacity (how many nodes can be stored) */ \
size_t capacity; \
\
/* Current amount of nodes in the dynamic array */ \
size_t size; \
\
/* Current amount of elements in the heap */ \
size_t count; \
\
/* Flags indicating errors or success */ \
int flag; \
\
/* Value function table */ \
struct SNAME##_fval *f_val; \
\
/* Function that returns an iterator to the start of the heap */ \
struct SNAME##_iter (*it_start)(struct SNAME *); \
\
/* Function that returns an iterator to the end of the heap */ \
struct SNAME##_iter (*it_end)(struct SNAME *); \
\
/* Custom allocation functions */ \
struct cmc_alloc_node *alloc; \
\
/* Custom callback functions */ \
struct cmc_callbacks *callbacks; \
}; \
\
/* Heap Node */ \
struct SNAME##_node \
{ \
/* 0 - Value belonging to the MinHeap */ \
/* 1 - Value belonging to the MaxHeap */ \
V data[2]; \
}; \
\
/* Value struct function table */ \
struct SNAME##_fval \
{ \
/* Comparator function */ \
int (*cmp)(V, V); \
\
/* Copy function */ \
V (*cpy)(V); \
\
/* To string function */ \
bool (*str)(FILE *, V); \
\
/* Free from memory function */ \
void (*free)(V); \
\
/* Hash function */ \
size_t (*hash)(V); \
\
/* Priority function */ \
int (*pri)(V, V); \
}; \
\
/* Heap Iterator */ \
struct SNAME##_iter \
{ \
/* Target heap */ \
struct SNAME *target; \
\
/* Cursor's position (index) */ \
size_t cursor; \
\
/* If the iterator has reached the start of the iteration */ \
bool start; \
\
/* If the iterator has reached the end of the iteration */ \
bool end; \
}; \
\
/* Collection Functions */ \
/* Collection Allocation and Deallocation */ \
struct SNAME *PFX##_new(size_t capacity, struct SNAME##_fval *f_val); \
struct SNAME *PFX##_new_custom( \
size_t capacity, struct SNAME##_fval *f_val, \
struct cmc_alloc_node *alloc, struct cmc_callbacks *callbacks); \
void PFX##_clear(struct SNAME *_heap_); \
void PFX##_free(struct SNAME *_heap_); \
/* Customization of Allocation and Callbacks */ \
void PFX##_customize(struct SNAME *_heap_, struct cmc_alloc_node *alloc, \
struct cmc_callbacks *callbacks); \
/* Collection Input and Output */ \
bool PFX##_insert(struct SNAME *_heap_, V element); \
bool PFX##_remove_max(struct SNAME *_heap_); \
bool PFX##_remove_min(struct SNAME *_heap_); \
/* Collection Update */ \
bool PFX##_update_max(struct SNAME *_heap_, V element); \
bool PFX##_update_min(struct SNAME *_heap_, V element); \
/* Element Access */ \
V PFX##_max(struct SNAME *_heap_); \
V PFX##_min(struct SNAME *_heap_); \
/* Collection State */ \
bool PFX##_contains(struct SNAME *_heap_, V element); \
bool PFX##_empty(struct SNAME *_heap_); \
bool PFX##_full(struct SNAME *_heap_); \
size_t PFX##_count(struct SNAME *_heap_); \
size_t PFX##_capacity(struct SNAME *_heap_); \
int PFX##_flag(struct SNAME *_heap_); \
/* Collection Utility */ \
bool PFX##_resize(struct SNAME *_heap_, size_t capacity); \
struct SNAME *PFX##_copy_of(struct SNAME *_set_); \
bool PFX##_equals(struct SNAME *_heap1_, struct SNAME *_heap2_); \
struct cmc_string PFX##_to_string(struct SNAME *_heap_); \
bool PFX##_print(struct SNAME *_heap_, FILE *fptr); \
\
/* Iterator Functions */ \
/* Iterator Allocation and Deallocation */ \
struct SNAME##_iter *PFX##_iter_new(struct SNAME *target); \
void PFX##_iter_free(struct SNAME##_iter *iter); \
/* Iterator Initialization */ \
void PFX##_iter_init(struct SNAME##_iter *iter, struct SNAME *target); \
/* Iterator State */ \
bool PFX##_iter_start(struct SNAME##_iter *iter); \
bool PFX##_iter_end(struct SNAME##_iter *iter); \
/* Iterator Movement */ \
void PFX##_iter_to_start(struct SNAME##_iter *iter); \
void PFX##_iter_to_end(struct SNAME##_iter *iter); \
bool PFX##_iter_next(struct SNAME##_iter *iter); \
bool PFX##_iter_prev(struct SNAME##_iter *iter); \
bool PFX##_iter_advance(struct SNAME##_iter *iter, size_t steps); \
bool PFX##_iter_rewind(struct SNAME##_iter *iter, size_t steps); \
bool PFX##_iter_go_to(struct SNAME##_iter *iter, size_t index); \
/* Iterator Access */ \
V PFX##_iter_value(struct SNAME##_iter *iter); \
size_t PFX##_iter_index(struct SNAME##_iter *iter);
/* -------------------------------------------------------------------------
@@ -205,7 +205,7 @@ static const char *cmc_string_fmt_intervalheap = "struct %s<%s> "
static struct SNAME##_iter PFX##_impl_it_start(struct SNAME *_heap_); \
static struct SNAME##_iter PFX##_impl_it_end(struct SNAME *_heap_); \
\
struct SNAME *PFX##_new(size_t capacity, struct SNAME##_ftab_val *f_val) \
struct SNAME *PFX##_new(size_t capacity, struct SNAME##_fval *f_val) \
{ \
struct cmc_alloc_node *alloc = &cmc_alloc_node_default; \
\
@@ -247,7 +247,7 @@ static const char *cmc_string_fmt_intervalheap = "struct %s<%s> "
} \
\
struct SNAME *PFX##_new_custom( \
size_t capacity, struct SNAME##_ftab_val *f_val, \
size_t capacity, struct SNAME##_fval *f_val, \
struct cmc_alloc_node *alloc, struct cmc_callbacks *callbacks) \
{ \
if (capacity == 0 || capacity == UINTMAX_MAX) \
+6 -6
View File
@@ -78,7 +78,7 @@ static const char *cmc_string_fmt_linkedlist = "struct %s<%s> "
int flag; \
\
/* Value function table */ \
struct SNAME##_ftab_val *f_val; \
struct SNAME##_fval *f_val; \
\
/* Custom allocation functions */ \
struct cmc_alloc_node *alloc; \
@@ -107,7 +107,7 @@ static const char *cmc_string_fmt_linkedlist = "struct %s<%s> "
}; \
\
/* Value struct function table */ \
struct SNAME##_ftab_val \
struct SNAME##_fval \
{ \
/* Comparator function */ \
int (*cmp)(V, V); \
@@ -149,8 +149,8 @@ static const char *cmc_string_fmt_linkedlist = "struct %s<%s> "
\
/* Collection Functions */ \
/* Collection Allocation and Deallocation */ \
struct SNAME *PFX##_new(struct SNAME##_ftab_val *f_val); \
struct SNAME *PFX##_new_custom(struct SNAME##_ftab_val *f_val, \
struct SNAME *PFX##_new(struct SNAME##_fval *f_val); \
struct SNAME *PFX##_new_custom(struct SNAME##_fval *f_val, \
struct cmc_alloc_node *alloc, \
struct cmc_callbacks *callbacks); \
void PFX##_clear(struct SNAME *_list_); \
@@ -233,7 +233,7 @@ static const char *cmc_string_fmt_linkedlist = "struct %s<%s> "
static struct SNAME##_iter PFX##_impl_it_start(struct SNAME *_list_); \
static struct SNAME##_iter PFX##_impl_it_end(struct SNAME *_list_); \
\
struct SNAME *PFX##_new(struct SNAME##_ftab_val *f_val) \
struct SNAME *PFX##_new(struct SNAME##_fval *f_val) \
{ \
if (!f_val) \
return NULL; \
@@ -258,7 +258,7 @@ static const char *cmc_string_fmt_linkedlist = "struct %s<%s> "
return _list_; \
} \
\
struct SNAME *PFX##_new_custom(struct SNAME##_ftab_val *f_val, \
struct SNAME *PFX##_new_custom(struct SNAME##_fval *f_val, \
struct cmc_alloc_node *alloc, \
struct cmc_callbacks *callbacks) \
{ \
+6 -6
View File
@@ -93,7 +93,7 @@ static const char *cmc_string_fmt_list = "struct %s<%s> "
int flag; \
\
/* Value function table */ \
struct SNAME##_ftab_val *f_val; \
struct SNAME##_fval *f_val; \
\
/* Function that returns an iterator to the start of the list */ \
struct SNAME##_iter (*it_start)(struct SNAME *); \
@@ -109,7 +109,7 @@ static const char *cmc_string_fmt_list = "struct %s<%s> "
}; \
\
/* Value struct function table */ \
struct SNAME##_ftab_val \
struct SNAME##_fval \
{ \
/* Comparator function */ \
int (*cmp)(V, V); \
@@ -148,9 +148,9 @@ static const char *cmc_string_fmt_list = "struct %s<%s> "
\
/* Collection Functions */ \
/* Collection Allocation and Deallocation */ \
struct SNAME *PFX##_new(size_t capacity, struct SNAME##_ftab_val *f_val); \
struct SNAME *PFX##_new(size_t capacity, struct SNAME##_fval *f_val); \
struct SNAME *PFX##_new_custom( \
size_t capacity, struct SNAME##_ftab_val *f_val, \
size_t capacity, struct SNAME##_fval *f_val, \
struct cmc_alloc_node *alloc, struct cmc_callbacks *callbacks); \
void PFX##_clear(struct SNAME *_list_); \
void PFX##_free(struct SNAME *_list_); \
@@ -224,7 +224,7 @@ static const char *cmc_string_fmt_list = "struct %s<%s> "
static struct SNAME##_iter PFX##_impl_it_start(struct SNAME *_list_); \
static struct SNAME##_iter PFX##_impl_it_end(struct SNAME *_list_); \
\
struct SNAME *PFX##_new(size_t capacity, struct SNAME##_ftab_val *f_val) \
struct SNAME *PFX##_new(size_t capacity, struct SNAME##_fval *f_val) \
{ \
struct cmc_alloc_node *alloc = &cmc_alloc_node_default; \
\
@@ -257,7 +257,7 @@ static const char *cmc_string_fmt_list = "struct %s<%s> "
} \
\
struct SNAME *PFX##_new_custom( \
size_t capacity, struct SNAME##_ftab_val *f_val, \
size_t capacity, struct SNAME##_fval *f_val, \
struct cmc_alloc_node *alloc, struct cmc_callbacks *callbacks) \
{ \
if (capacity < 1) \
+12 -12
View File
@@ -103,10 +103,10 @@ static const char *cmc_string_fmt_multimap = "struct %s<%s, %s> "
int flag; \
\
/* Key function table */ \
struct SNAME##_ftab_key *f_key; \
struct SNAME##_fkey *f_key; \
\
/* Value function table */ \
struct SNAME##_ftab_val *f_val; \
struct SNAME##_fval *f_val; \
\
/* Custom allocation functions */ \
struct cmc_alloc_node *alloc; \
@@ -138,7 +138,7 @@ static const char *cmc_string_fmt_multimap = "struct %s<%s, %s> "
}; \
\
/* Key struct function table */ \
struct SNAME##_ftab_key \
struct SNAME##_fkey \
{ \
/* Comparator function */ \
int (*cmp)(K, K); \
@@ -160,7 +160,7 @@ static const char *cmc_string_fmt_multimap = "struct %s<%s, %s> "
}; \
\
/* Value struct function table */ \
struct SNAME##_ftab_val \
struct SNAME##_fval \
{ \
/* Comparator function */ \
int (*cmp)(V, V); \
@@ -211,11 +211,11 @@ static const char *cmc_string_fmt_multimap = "struct %s<%s, %s> "
/* Collection Functions */ \
/* Collection Allocation and Deallocation */ \
struct SNAME *PFX##_new(size_t capacity, double load, \
struct SNAME##_ftab_key *f_key, \
struct SNAME##_ftab_val *f_val); \
struct SNAME##_fkey *f_key, \
struct SNAME##_fval *f_val); \
struct SNAME *PFX##_new_custom( \
size_t capacity, double load, struct SNAME##_ftab_key *f_key, \
struct SNAME##_ftab_val *f_val, struct cmc_alloc_node *alloc, \
size_t capacity, double load, struct SNAME##_fkey *f_key, \
struct SNAME##_fval *f_val, struct cmc_alloc_node *alloc, \
struct cmc_callbacks *callbacks); \
void PFX##_clear(struct SNAME *_map_); \
void PFX##_free(struct SNAME *_map_); \
@@ -288,8 +288,8 @@ static const char *cmc_string_fmt_multimap = "struct %s<%s, %s> "
static struct SNAME##_iter PFX##_impl_it_end(struct SNAME *_map_); \
\
struct SNAME *PFX##_new(size_t capacity, double load, \
struct SNAME##_ftab_key *f_key, \
struct SNAME##_ftab_val *f_val) \
struct SNAME##_fkey *f_key, \
struct SNAME##_fval *f_val) \
{ \
struct cmc_alloc_node *alloc = &cmc_alloc_node_default; \
\
@@ -334,8 +334,8 @@ static const char *cmc_string_fmt_multimap = "struct %s<%s, %s> "
} \
\
struct SNAME *PFX##_new_custom( \
size_t capacity, double load, struct SNAME##_ftab_key *f_key, \
struct SNAME##_ftab_val *f_val, struct cmc_alloc_node *alloc, \
size_t capacity, double load, struct SNAME##_fkey *f_key, \
struct SNAME##_fval *f_val, struct cmc_alloc_node *alloc, \
struct cmc_callbacks *callbacks) \
{ \
if (capacity == 0 || load <= 0) \
+6 -6
View File
@@ -84,7 +84,7 @@ static const char *cmc_string_fmt_multiset = "struct %s<%s> "
int flag; \
\
/* Key function table */ \
struct SNAME##_ftab_val *f_val; \
struct SNAME##_fval *f_val; \
\
/* Custom allocation functions */ \
struct cmc_alloc_node *alloc; \
@@ -116,7 +116,7 @@ static const char *cmc_string_fmt_multiset = "struct %s<%s> "
}; \
\
/* Value struct function table */ \
struct SNAME##_ftab_val \
struct SNAME##_fval \
{ \
/* Comparator function */ \
int (*cmp)(V, V); \
@@ -165,9 +165,9 @@ static const char *cmc_string_fmt_multiset = "struct %s<%s> "
/* Collection Functions */ \
/* Collection Allocation and Deallocation */ \
struct SNAME *PFX##_new(size_t capacity, double load, \
struct SNAME##_ftab_val *f_val); \
struct SNAME##_fval *f_val); \
struct SNAME *PFX##_new_custom( \
size_t capacity, double load, struct SNAME##_ftab_val *f_val, \
size_t capacity, double load, struct SNAME##_fval *f_val, \
struct cmc_alloc_node *alloc, struct cmc_callbacks *callbacks); \
void PFX##_clear(struct SNAME *_set_); \
void PFX##_free(struct SNAME *_set_); \
@@ -253,7 +253,7 @@ static const char *cmc_string_fmt_multiset = "struct %s<%s> "
static struct SNAME##_iter PFX##_impl_it_end(struct SNAME *_set_); \
\
struct SNAME *PFX##_new(size_t capacity, double load, \
struct SNAME##_ftab_val *f_val) \
struct SNAME##_fval *f_val) \
{ \
struct cmc_alloc_node *alloc = &cmc_alloc_node_default; \
\
@@ -298,7 +298,7 @@ static const char *cmc_string_fmt_multiset = "struct %s<%s> "
} \
\
struct SNAME *PFX##_new_custom( \
size_t capacity, double load, struct SNAME##_ftab_val *f_val, \
size_t capacity, double load, struct SNAME##_fval *f_val, \
struct cmc_alloc_node *alloc, struct cmc_callbacks *callbacks) \
{ \
if (capacity == 0 || load <= 0 || load >= 1) \
+6 -6
View File
@@ -101,7 +101,7 @@ static const char *cmc_string_fmt_queue = "struct %s<%s> "
int flag; \
\
/* Value function table */ \
struct SNAME##_ftab_val *f_val; \
struct SNAME##_fval *f_val; \
\
/* Custom allocation functions */ \
struct cmc_alloc_node *alloc; \
@@ -117,7 +117,7 @@ static const char *cmc_string_fmt_queue = "struct %s<%s> "
}; \
\
/* Value struct function table */ \
struct SNAME##_ftab_val \
struct SNAME##_fval \
{ \
/* Comparator function */ \
int (*cmp)(V, V); \
@@ -159,9 +159,9 @@ static const char *cmc_string_fmt_queue = "struct %s<%s> "
\
/* Collection Functions */ \
/* Collection Allocation and Deallocation */ \
struct SNAME *PFX##_new(size_t capacity, struct SNAME##_ftab_val *f_val); \
struct SNAME *PFX##_new(size_t capacity, struct SNAME##_fval *f_val); \
struct SNAME *PFX##_new_custom( \
size_t capacity, struct SNAME##_ftab_val *f_val, \
size_t capacity, struct SNAME##_fval *f_val, \
struct cmc_alloc_node *alloc, struct cmc_callbacks *callbacks); \
void PFX##_clear(struct SNAME *_queue_); \
void PFX##_free(struct SNAME *_queue_); \
@@ -218,7 +218,7 @@ static const char *cmc_string_fmt_queue = "struct %s<%s> "
static struct SNAME##_iter PFX##_impl_it_start(struct SNAME *_queue_); \
static struct SNAME##_iter PFX##_impl_it_end(struct SNAME *_queue_); \
\
struct SNAME *PFX##_new(size_t capacity, struct SNAME##_ftab_val *f_val) \
struct SNAME *PFX##_new(size_t capacity, struct SNAME##_fval *f_val) \
{ \
struct cmc_alloc_node *alloc = &cmc_alloc_node_default; \
\
@@ -256,7 +256,7 @@ static const char *cmc_string_fmt_queue = "struct %s<%s> "
} \
\
struct SNAME *PFX##_new_custom( \
size_t capacity, struct SNAME##_ftab_val *f_val, \
size_t capacity, struct SNAME##_fval *f_val, \
struct cmc_alloc_node *alloc, struct cmc_callbacks *callbacks) \
{ \
if (capacity < 1) \
+129 -129
View File
@@ -55,133 +55,133 @@ static const char *cmc_string_fmt_sortedlist = "struct %s<%s> "
/* -------------------------------------------------------------------------
* Header
* ------------------------------------------------------------------------- */
#define CMC_GENERATE_SORTEDLIST_HEADER(PFX, SNAME, V) \
\
/* List Structure */ \
struct SNAME \
{ \
/* Dynamic array of elements */ \
V *buffer; \
\
/* Current array capacity */ \
size_t capacity; \
\
/* Current amount of elements */ \
size_t count; \
\
/* Flag if the list is sorted or not, used by lazy evaluation */ \
bool is_sorted; \
\
/* Flags indicating errors or success */ \
int flag; \
\
/* Value function table */ \
struct SNAME##_ftab_val *f_val; \
\
/* Custom allocation functions */ \
struct cmc_alloc_node *alloc; \
\
/* Custom callback functions */ \
struct cmc_callbacks *callbacks; \
\
/* Function that returns an iterator to the start of the list */ \
struct SNAME##_iter (*it_start)(struct SNAME *); \
\
/* Function that returns an iterator to the end of the list */ \
struct SNAME##_iter (*it_end)(struct SNAME *); \
}; \
\
/* Value struct function table */ \
struct SNAME##_ftab_val \
{ \
/* Comparator function */ \
int (*cmp)(V, V); \
\
/* Copy function */ \
V (*cpy)(V); \
\
/* To string function */ \
bool (*str)(FILE *, V); \
\
/* Free from memory function */ \
void (*free)(V); \
\
/* Hash function */ \
size_t (*hash)(V); \
\
/* Priority function */ \
int (*pri)(V, V); \
}; \
\
/* List Iterator */ \
struct SNAME##_iter \
{ \
/* Target list */ \
struct SNAME *target; \
\
/* Cursor's position (index) */ \
size_t cursor; \
\
/* If the iterator has reached the start of the iteration */ \
bool start; \
\
/* If the iterator has reached the end of the iteration */ \
bool end; \
}; \
\
/* Collection Functions */ \
/* Collection Allocation and Deallocation */ \
struct SNAME *PFX##_new(size_t capacity, struct SNAME##_ftab_val *f_val); \
struct SNAME *PFX##_new_custom( \
size_t capacity, struct SNAME##_ftab_val *f_val, \
struct cmc_alloc_node *alloc, struct cmc_callbacks *callbacks); \
void PFX##_clear(struct SNAME *_list_); \
void PFX##_free(struct SNAME *_list_); \
/* Customization of Allocation and Callbacks */ \
void PFX##_customize(struct SNAME *_list_, struct cmc_alloc_node *alloc, \
struct cmc_callbacks *callbacks); \
/* Collection Input and Output */ \
bool PFX##_insert(struct SNAME *_list_, V element); \
bool PFX##_remove(struct SNAME *_list_, size_t index); \
/* Element Access */ \
V PFX##_max(struct SNAME *_list_); \
V PFX##_min(struct SNAME *_list_); \
V PFX##_get(struct SNAME *_list_, size_t index); \
size_t PFX##_index_of(struct SNAME *_list_, V element, bool from_start); \
/* Collection State */ \
bool PFX##_contains(struct SNAME *_list_, V element); \
bool PFX##_empty(struct SNAME *_list_); \
bool PFX##_full(struct SNAME *_list_); \
size_t PFX##_count(struct SNAME *_list_); \
size_t PFX##_capacity(struct SNAME *_list_); \
int PFX##_flag(struct SNAME *_list_); \
/* Collection Utility */ \
bool PFX##_resize(struct SNAME *_list_, size_t capacity); \
void PFX##_sort(struct SNAME *_list_); \
struct SNAME *PFX##_copy_of(struct SNAME *_list_); \
bool PFX##_equals(struct SNAME *_list1_, struct SNAME *_list2_); \
struct cmc_string PFX##_to_string(struct SNAME *_list_); \
bool PFX##_print(struct SNAME *_list_, FILE *fptr); \
\
/* Iterator Functions */ \
/* Iterator Allocation and Deallocation */ \
struct SNAME##_iter *PFX##_iter_new(struct SNAME *target); \
void PFX##_iter_free(struct SNAME##_iter *iter); \
/* Iterator Initialization */ \
void PFX##_iter_init(struct SNAME##_iter *iter, struct SNAME *target); \
/* Iterator State */ \
bool PFX##_iter_start(struct SNAME##_iter *iter); \
bool PFX##_iter_end(struct SNAME##_iter *iter); \
/* Iterator Movement */ \
void PFX##_iter_to_start(struct SNAME##_iter *iter); \
void PFX##_iter_to_end(struct SNAME##_iter *iter); \
bool PFX##_iter_next(struct SNAME##_iter *iter); \
bool PFX##_iter_prev(struct SNAME##_iter *iter); \
bool PFX##_iter_advance(struct SNAME##_iter *iter, size_t steps); \
bool PFX##_iter_rewind(struct SNAME##_iter *iter, size_t steps); \
bool PFX##_iter_go_to(struct SNAME##_iter *iter, size_t index); \
/* Iterator Access */ \
V PFX##_iter_value(struct SNAME##_iter *iter); \
#define CMC_GENERATE_SORTEDLIST_HEADER(PFX, SNAME, V) \
\
/* List Structure */ \
struct SNAME \
{ \
/* Dynamic array of elements */ \
V *buffer; \
\
/* Current array capacity */ \
size_t capacity; \
\
/* Current amount of elements */ \
size_t count; \
\
/* Flag if the list is sorted or not, used by lazy evaluation */ \
bool is_sorted; \
\
/* Flags indicating errors or success */ \
int flag; \
\
/* Value function table */ \
struct SNAME##_fval *f_val; \
\
/* Custom allocation functions */ \
struct cmc_alloc_node *alloc; \
\
/* Custom callback functions */ \
struct cmc_callbacks *callbacks; \
\
/* Function that returns an iterator to the start of the list */ \
struct SNAME##_iter (*it_start)(struct SNAME *); \
\
/* Function that returns an iterator to the end of the list */ \
struct SNAME##_iter (*it_end)(struct SNAME *); \
}; \
\
/* Value struct function table */ \
struct SNAME##_fval \
{ \
/* Comparator function */ \
int (*cmp)(V, V); \
\
/* Copy function */ \
V (*cpy)(V); \
\
/* To string function */ \
bool (*str)(FILE *, V); \
\
/* Free from memory function */ \
void (*free)(V); \
\
/* Hash function */ \
size_t (*hash)(V); \
\
/* Priority function */ \
int (*pri)(V, V); \
}; \
\
/* List Iterator */ \
struct SNAME##_iter \
{ \
/* Target list */ \
struct SNAME *target; \
\
/* Cursor's position (index) */ \
size_t cursor; \
\
/* If the iterator has reached the start of the iteration */ \
bool start; \
\
/* If the iterator has reached the end of the iteration */ \
bool end; \
}; \
\
/* Collection Functions */ \
/* Collection Allocation and Deallocation */ \
struct SNAME *PFX##_new(size_t capacity, struct SNAME##_fval *f_val); \
struct SNAME *PFX##_new_custom( \
size_t capacity, struct SNAME##_fval *f_val, \
struct cmc_alloc_node *alloc, struct cmc_callbacks *callbacks); \
void PFX##_clear(struct SNAME *_list_); \
void PFX##_free(struct SNAME *_list_); \
/* Customization of Allocation and Callbacks */ \
void PFX##_customize(struct SNAME *_list_, struct cmc_alloc_node *alloc, \
struct cmc_callbacks *callbacks); \
/* Collection Input and Output */ \
bool PFX##_insert(struct SNAME *_list_, V element); \
bool PFX##_remove(struct SNAME *_list_, size_t index); \
/* Element Access */ \
V PFX##_max(struct SNAME *_list_); \
V PFX##_min(struct SNAME *_list_); \
V PFX##_get(struct SNAME *_list_, size_t index); \
size_t PFX##_index_of(struct SNAME *_list_, V element, bool from_start); \
/* Collection State */ \
bool PFX##_contains(struct SNAME *_list_, V element); \
bool PFX##_empty(struct SNAME *_list_); \
bool PFX##_full(struct SNAME *_list_); \
size_t PFX##_count(struct SNAME *_list_); \
size_t PFX##_capacity(struct SNAME *_list_); \
int PFX##_flag(struct SNAME *_list_); \
/* Collection Utility */ \
bool PFX##_resize(struct SNAME *_list_, size_t capacity); \
void PFX##_sort(struct SNAME *_list_); \
struct SNAME *PFX##_copy_of(struct SNAME *_list_); \
bool PFX##_equals(struct SNAME *_list1_, struct SNAME *_list2_); \
struct cmc_string PFX##_to_string(struct SNAME *_list_); \
bool PFX##_print(struct SNAME *_list_, FILE *fptr); \
\
/* Iterator Functions */ \
/* Iterator Allocation and Deallocation */ \
struct SNAME##_iter *PFX##_iter_new(struct SNAME *target); \
void PFX##_iter_free(struct SNAME##_iter *iter); \
/* Iterator Initialization */ \
void PFX##_iter_init(struct SNAME##_iter *iter, struct SNAME *target); \
/* Iterator State */ \
bool PFX##_iter_start(struct SNAME##_iter *iter); \
bool PFX##_iter_end(struct SNAME##_iter *iter); \
/* Iterator Movement */ \
void PFX##_iter_to_start(struct SNAME##_iter *iter); \
void PFX##_iter_to_end(struct SNAME##_iter *iter); \
bool PFX##_iter_next(struct SNAME##_iter *iter); \
bool PFX##_iter_prev(struct SNAME##_iter *iter); \
bool PFX##_iter_advance(struct SNAME##_iter *iter, size_t steps); \
bool PFX##_iter_rewind(struct SNAME##_iter *iter, size_t steps); \
bool PFX##_iter_go_to(struct SNAME##_iter *iter, size_t index); \
/* Iterator Access */ \
V PFX##_iter_value(struct SNAME##_iter *iter); \
size_t PFX##_iter_index(struct SNAME##_iter *iter);
/* -------------------------------------------------------------------------
@@ -201,7 +201,7 @@ static const char *cmc_string_fmt_sortedlist = "struct %s<%s> "
static struct SNAME##_iter PFX##_impl_it_start(struct SNAME *_list_); \
static struct SNAME##_iter PFX##_impl_it_end(struct SNAME *_list_); \
\
struct SNAME *PFX##_new(size_t capacity, struct SNAME##_ftab_val *f_val) \
struct SNAME *PFX##_new(size_t capacity, struct SNAME##_fval *f_val) \
{ \
struct cmc_alloc_node *alloc = &cmc_alloc_node_default; \
\
@@ -238,7 +238,7 @@ static const char *cmc_string_fmt_sortedlist = "struct %s<%s> "
} \
\
struct SNAME *PFX##_new_custom( \
size_t capacity, struct SNAME##_ftab_val *f_val, \
size_t capacity, struct SNAME##_fval *f_val, \
struct cmc_alloc_node *alloc, struct cmc_callbacks *callbacks) \
{ \
if (capacity < 1) \
+6 -6
View File
@@ -78,7 +78,7 @@ static const char *cmc_string_fmt_stack = "struct %s<%s> "
int flag; \
\
/* Value function table */ \
struct SNAME##_ftab_val *f_val; \
struct SNAME##_fval *f_val; \
\
/* Custom allocation functions */ \
struct cmc_alloc_node *alloc; \
@@ -94,7 +94,7 @@ static const char *cmc_string_fmt_stack = "struct %s<%s> "
}; \
\
/* Value struct function table */ \
struct SNAME##_ftab_val \
struct SNAME##_fval \
{ \
/* Comparator function */ \
int (*cmp)(V, V); \
@@ -133,9 +133,9 @@ static const char *cmc_string_fmt_stack = "struct %s<%s> "
\
/* Collection Functions */ \
/* Collection Allocation and Deallocation */ \
struct SNAME *PFX##_new(size_t capacity, struct SNAME##_ftab_val *f_val); \
struct SNAME *PFX##_new(size_t capacity, struct SNAME##_fval *f_val); \
struct SNAME *PFX##_new_custom( \
size_t capacity, struct SNAME##_ftab_val *f_val, \
size_t capacity, struct SNAME##_fval *f_val, \
struct cmc_alloc_node *alloc, struct cmc_callbacks *callbacks); \
void PFX##_clear(struct SNAME *_stack_); \
void PFX##_free(struct SNAME *_stack_); \
@@ -192,7 +192,7 @@ static const char *cmc_string_fmt_stack = "struct %s<%s> "
static struct SNAME##_iter PFX##_impl_it_start(struct SNAME *_stack_); \
static struct SNAME##_iter PFX##_impl_it_end(struct SNAME *_stack_); \
\
struct SNAME *PFX##_new(size_t capacity, struct SNAME##_ftab_val *f_val) \
struct SNAME *PFX##_new(size_t capacity, struct SNAME##_fval *f_val) \
{ \
struct cmc_alloc_node *alloc = &cmc_alloc_node_default; \
\
@@ -228,7 +228,7 @@ static const char *cmc_string_fmt_stack = "struct %s<%s> "
} \
\
struct SNAME *PFX##_new_custom( \
size_t capacity, struct SNAME##_ftab_val *f_val, \
size_t capacity, struct SNAME##_fval *f_val, \
struct cmc_alloc_node *alloc, struct cmc_callbacks *callbacks) \
{ \
if (capacity < 1) \
+10 -10
View File
@@ -66,10 +66,10 @@ static const char *cmc_string_fmt_treemap = "struct %s<%s, %s> "
int flag; \
\
/* Key function table */ \
struct SNAME##_ftab_key *f_key; \
struct SNAME##_fkey *f_key; \
\
/* Value function table */ \
struct SNAME##_ftab_val *f_val; \
struct SNAME##_fval *f_val; \
\
/* Custom allocation functions */ \
struct cmc_alloc_node *alloc; \
@@ -107,7 +107,7 @@ static const char *cmc_string_fmt_treemap = "struct %s<%s, %s> "
}; \
\
/* Key struct function table */ \
struct SNAME##_ftab_key \
struct SNAME##_fkey \
{ \
/* Comparator function */ \
int (*cmp)(K, K); \
@@ -129,7 +129,7 @@ static const char *cmc_string_fmt_treemap = "struct %s<%s, %s> "
}; \
\
/* Value struct function table */ \
struct SNAME##_ftab_val \
struct SNAME##_fval \
{ \
/* Comparator function */ \
int (*cmp)(V, V); \
@@ -177,10 +177,10 @@ static const char *cmc_string_fmt_treemap = "struct %s<%s, %s> "
\
/* Collection Functions */ \
/* Collection Allocation and Deallocation */ \
struct SNAME *PFX##_new(struct SNAME##_ftab_key *f_key, \
struct SNAME##_ftab_val *f_val); \
struct SNAME *PFX##_new(struct SNAME##_fkey *f_key, \
struct SNAME##_fval *f_val); \
struct SNAME *PFX##_new_custom( \
struct SNAME##_ftab_key *f_key, struct SNAME##_ftab_val *f_val, \
struct SNAME##_fkey *f_key, struct SNAME##_fval *f_val, \
struct cmc_alloc_node *alloc, struct cmc_callbacks *callbacks); \
void PFX##_clear(struct SNAME *_map_); \
void PFX##_free(struct SNAME *_map_); \
@@ -249,8 +249,8 @@ static const char *cmc_string_fmt_treemap = "struct %s<%s, %s> "
static struct SNAME##_iter PFX##_impl_it_start(struct SNAME *_map_); \
static struct SNAME##_iter PFX##_impl_it_end(struct SNAME *_map_); \
\
struct SNAME *PFX##_new(struct SNAME##_ftab_key *f_key, \
struct SNAME##_ftab_val *f_val) \
struct SNAME *PFX##_new(struct SNAME##_fkey *f_key, \
struct SNAME##_fval *f_val) \
{ \
if (!f_key || !f_val) \
return NULL; \
@@ -276,7 +276,7 @@ static const char *cmc_string_fmt_treemap = "struct %s<%s, %s> "
} \
\
struct SNAME *PFX##_new_custom( \
struct SNAME##_ftab_key *f_key, struct SNAME##_ftab_val *f_val, \
struct SNAME##_fkey *f_key, struct SNAME##_fval *f_val, \
struct cmc_alloc_node *alloc, struct cmc_callbacks *callbacks) \
{ \
if (!f_key || !f_val) \
+6 -6
View File
@@ -65,7 +65,7 @@ static const char *cmc_string_fmt_treeset = "struct %s<%s> "
int flag; \
\
/* Value function table */ \
struct SNAME##_ftab_val *f_val; \
struct SNAME##_fval *f_val; \
\
/* Custom allocation functions */ \
struct cmc_alloc_node *alloc; \
@@ -100,7 +100,7 @@ static const char *cmc_string_fmt_treeset = "struct %s<%s> "
}; \
\
/* Value struct function table */ \
struct SNAME##_ftab_val \
struct SNAME##_fval \
{ \
/* Comparator function */ \
int (*cmp)(V, V); \
@@ -148,8 +148,8 @@ static const char *cmc_string_fmt_treeset = "struct %s<%s> "
\
/* Collection Functions */ \
/* Collection Allocation and Deallocation */ \
struct SNAME *PFX##_new(struct SNAME##_ftab_val *f_val); \
struct SNAME *PFX##_new_custom(struct SNAME##_ftab_val *f_val, \
struct SNAME *PFX##_new(struct SNAME##_fval *f_val); \
struct SNAME *PFX##_new_custom(struct SNAME##_fval *f_val, \
struct cmc_alloc_node *alloc, \
struct cmc_callbacks *callbacks); \
void PFX##_clear(struct SNAME *_set_); \
@@ -238,7 +238,7 @@ static const char *cmc_string_fmt_treeset = "struct %s<%s> "
static struct SNAME##_iter PFX##_impl_it_start(struct SNAME *_set_); \
static struct SNAME##_iter PFX##_impl_it_end(struct SNAME *_set_); \
\
struct SNAME *PFX##_new(struct SNAME##_ftab_val *f_val) \
struct SNAME *PFX##_new(struct SNAME##_fval *f_val) \
{ \
if (!f_val) \
return NULL; \
@@ -262,7 +262,7 @@ static const char *cmc_string_fmt_treeset = "struct %s<%s> "
return _set_; \
} \
\
struct SNAME *PFX##_new_custom(struct SNAME##_ftab_val *f_val, \
struct SNAME *PFX##_new_custom(struct SNAME##_fval *f_val, \
struct cmc_alloc_node *alloc, \
struct cmc_callbacks *callbacks) \
{ \
+1 -1
View File
@@ -46,5 +46,5 @@ int main(void)
printf("| Total Running Time : %14.0lf milliseconds |\n", timer.result);
printf("+--------------------------------------------------+\n");
return 0;
return failed;
}
+12 -14
View File
@@ -7,8 +7,8 @@ struct bidimap
size_t count;
double load;
int flag;
struct bidimap_ftab_key *f_key;
struct bidimap_ftab_val *f_val;
struct bidimap_fkey *f_key;
struct bidimap_fval *f_val;
struct cmc_alloc_node *alloc;
struct cmc_callbacks *callbacks;
struct bidimap_iter (*it_start)(struct bidimap *);
@@ -21,7 +21,7 @@ struct bidimap_entry
size_t dist[2];
struct bidimap_entry **ref[2];
};
struct bidimap_ftab_key
struct bidimap_fkey
{
int (*cmp)(size_t, size_t);
size_t (*cpy)(size_t);
@@ -30,7 +30,7 @@ struct bidimap_ftab_key
size_t (*hash)(size_t);
int (*pri)(size_t, size_t);
};
struct bidimap_ftab_val
struct bidimap_fval
{
int (*cmp)(size_t, size_t);
size_t (*cpy)(size_t);
@@ -49,12 +49,11 @@ struct bidimap_iter
_Bool start;
_Bool end;
};
struct bidimap *bm_new(size_t capacity, double load,
struct bidimap_ftab_key *f_key,
struct bidimap_ftab_val *f_val);
struct bidimap *bm_new(size_t capacity, double load, struct bidimap_fkey *f_key,
struct bidimap_fval *f_val);
struct bidimap *bm_new_custom(size_t capacity, double load,
struct bidimap_ftab_key *f_key,
struct bidimap_ftab_val *f_val,
struct bidimap_fkey *f_key,
struct bidimap_fval *f_val,
struct cmc_alloc_node *alloc,
struct cmc_callbacks *callbacks);
void bm_clear(struct bidimap *_map_);
@@ -111,9 +110,8 @@ bm_impl_add_entry_to_val(struct bidimap *_map_, struct bidimap_entry *entry);
static size_t bm_impl_calculate_size(size_t required);
static struct bidimap_iter bm_impl_it_start(struct bidimap *_map_);
static struct bidimap_iter bm_impl_it_end(struct bidimap *_map_);
struct bidimap *bm_new(size_t capacity, double load,
struct bidimap_ftab_key *f_key,
struct bidimap_ftab_val *f_val)
struct bidimap *bm_new(size_t capacity, double load, struct bidimap_fkey *f_key,
struct bidimap_fval *f_val)
{
struct cmc_alloc_node *alloc = &cmc_alloc_node_default;
if (capacity == 0 || load <= 0 || load >= 1)
@@ -147,8 +145,8 @@ struct bidimap *bm_new(size_t capacity, double load,
return _map_;
}
struct bidimap *bm_new_custom(size_t capacity, double load,
struct bidimap_ftab_key *f_key,
struct bidimap_ftab_val *f_val,
struct bidimap_fkey *f_key,
struct bidimap_fval *f_val,
struct cmc_alloc_node *alloc,
struct cmc_callbacks *callbacks)
{
+6 -6
View File
@@ -8,13 +8,13 @@ struct deque
size_t front;
size_t back;
int flag;
struct deque_ftab_val *f_val;
struct deque_fval *f_val;
struct cmc_alloc_node *alloc;
struct cmc_callbacks *callbacks;
struct deque_iter (*it_start)(struct deque *);
struct deque_iter (*it_end)(struct deque *);
};
struct deque_ftab_val
struct deque_fval
{
int (*cmp)(size_t, size_t);
size_t (*cpy)(size_t);
@@ -31,8 +31,8 @@ struct deque_iter
_Bool start;
_Bool end;
};
struct deque *d_new(size_t capacity, struct deque_ftab_val *f_val);
struct deque *d_new_custom(size_t capacity, struct deque_ftab_val *f_val,
struct deque *d_new(size_t capacity, struct deque_fval *f_val);
struct deque *d_new_custom(size_t capacity, struct deque_fval *f_val,
struct cmc_alloc_node *alloc,
struct cmc_callbacks *callbacks);
void d_clear(struct deque *_deque_);
@@ -73,7 +73,7 @@ size_t *d_iter_rvalue(struct deque_iter *iter);
size_t d_iter_index(struct deque_iter *iter);
static struct deque_iter d_impl_it_start(struct deque *_deque_);
static struct deque_iter d_impl_it_end(struct deque *_deque_);
struct deque *d_new(size_t capacity, struct deque_ftab_val *f_val)
struct deque *d_new(size_t capacity, struct deque_fval *f_val)
{
struct cmc_alloc_node *alloc = &cmc_alloc_node_default;
if (capacity < 1)
@@ -101,7 +101,7 @@ struct deque *d_new(size_t capacity, struct deque_ftab_val *f_val)
_deque_->it_end = d_impl_it_end;
return _deque_;
}
struct deque *d_new_custom(size_t capacity, struct deque_ftab_val *f_val,
struct deque *d_new_custom(size_t capacity, struct deque_fval *f_val,
struct cmc_alloc_node *alloc,
struct cmc_callbacks *callbacks)
{
+12 -14
View File
@@ -7,8 +7,8 @@ struct hashmap
size_t count;
double load;
int flag;
struct hashmap_ftab_key *f_key;
struct hashmap_ftab_val *f_val;
struct hashmap_fkey *f_key;
struct hashmap_fval *f_val;
struct cmc_alloc_node *alloc;
struct cmc_callbacks *callbacks;
struct hashmap_iter (*it_start)(struct hashmap *);
@@ -21,7 +21,7 @@ struct hashmap_entry
size_t dist;
enum cmc_entry_state state;
};
struct hashmap_ftab_key
struct hashmap_fkey
{
int (*cmp)(size_t, size_t);
size_t (*cpy)(size_t);
@@ -30,7 +30,7 @@ struct hashmap_ftab_key
size_t (*hash)(size_t);
int (*pri)(size_t, size_t);
};
struct hashmap_ftab_val
struct hashmap_fval
{
int (*cmp)(size_t, size_t);
size_t (*cpy)(size_t);
@@ -49,12 +49,11 @@ struct hashmap_iter
_Bool start;
_Bool end;
};
struct hashmap *hm_new(size_t capacity, double load,
struct hashmap_ftab_key *f_key,
struct hashmap_ftab_val *f_val);
struct hashmap *hm_new(size_t capacity, double load, struct hashmap_fkey *f_key,
struct hashmap_fval *f_val);
struct hashmap *hm_new_custom(size_t capacity, double load,
struct hashmap_ftab_key *f_key,
struct hashmap_ftab_val *f_val,
struct hashmap_fkey *f_key,
struct hashmap_fval *f_val,
struct cmc_alloc_node *alloc,
struct cmc_callbacks *callbacks);
void hm_clear(struct hashmap *_map_);
@@ -102,9 +101,8 @@ static struct hashmap_entry *hm_impl_get_entry(struct hashmap *_map_,
static size_t hm_impl_calculate_size(size_t required);
static struct hashmap_iter hm_impl_it_start(struct hashmap *_map_);
static struct hashmap_iter hm_impl_it_end(struct hashmap *_map_);
struct hashmap *hm_new(size_t capacity, double load,
struct hashmap_ftab_key *f_key,
struct hashmap_ftab_val *f_val)
struct hashmap *hm_new(size_t capacity, double load, struct hashmap_fkey *f_key,
struct hashmap_fval *f_val)
{
struct cmc_alloc_node *alloc = &cmc_alloc_node_default;
if (capacity == 0 || load <= 0 || load >= 1)
@@ -136,8 +134,8 @@ struct hashmap *hm_new(size_t capacity, double load,
return _map_;
}
struct hashmap *hm_new_custom(size_t capacity, double load,
struct hashmap_ftab_key *f_key,
struct hashmap_ftab_val *f_val,
struct hashmap_fkey *f_key,
struct hashmap_fval *f_val,
struct cmc_alloc_node *alloc,
struct cmc_callbacks *callbacks)
{
+6 -7
View File
@@ -7,7 +7,7 @@ struct hashset
size_t count;
double load;
int flag;
struct hashset_ftab_val *f_val;
struct hashset_fval *f_val;
struct cmc_alloc_node *alloc;
struct cmc_callbacks *callbacks;
struct hashset_iter (*it_start)(struct hashset *);
@@ -19,7 +19,7 @@ struct hashset_entry
size_t dist;
enum cmc_entry_state state;
};
struct hashset_ftab_val
struct hashset_fval
{
int (*cmp)(size_t, size_t);
size_t (*cpy)(size_t);
@@ -39,9 +39,9 @@ struct hashset_iter
_Bool end;
};
struct hashset *hs_new(size_t capacity, double load,
struct hashset_ftab_val *f_val);
struct hashset_fval *f_val);
struct hashset *hs_new_custom(size_t capacity, double load,
struct hashset_ftab_val *f_val,
struct hashset_fval *f_val,
struct cmc_alloc_node *alloc,
struct cmc_callbacks *callbacks);
void hs_clear(struct hashset *_set_);
@@ -93,8 +93,7 @@ static struct hashset_entry *hs_impl_get_entry(struct hashset *_set_,
static size_t hs_impl_calculate_size(size_t required);
static struct hashset_iter hs_impl_it_start(struct hashset *_set_);
static struct hashset_iter hs_impl_it_end(struct hashset *_set_);
struct hashset *hs_new(size_t capacity, double load,
struct hashset_ftab_val *f_val)
struct hashset *hs_new(size_t capacity, double load, struct hashset_fval *f_val)
{
struct cmc_alloc_node *alloc = &cmc_alloc_node_default;
if (capacity == 0 || load <= 0 || load >= 1)
@@ -125,7 +124,7 @@ struct hashset *hs_new(size_t capacity, double load,
return _set_;
}
struct hashset *hs_new_custom(size_t capacity, double load,
struct hashset_ftab_val *f_val,
struct hashset_fval *f_val,
struct cmc_alloc_node *alloc,
struct cmc_callbacks *callbacks)
{
+6 -8
View File
@@ -7,13 +7,13 @@ struct heap
size_t count;
enum cmc_heap_order HO;
int flag;
struct heap_ftab_val *f_val;
struct heap_fval *f_val;
struct cmc_alloc_node *alloc;
struct cmc_callbacks *callbacks;
struct heap_iter (*it_start)(struct heap *);
struct heap_iter (*it_end)(struct heap *);
};
struct heap_ftab_val
struct heap_fval
{
int (*cmp)(size_t, size_t);
size_t (*cpy)(size_t);
@@ -30,10 +30,9 @@ struct heap_iter
_Bool end;
};
struct heap *h_new(size_t capacity, enum cmc_heap_order HO,
struct heap_ftab_val *f_val);
struct heap_fval *f_val);
struct heap *h_new_custom(size_t capacity, enum cmc_heap_order HO,
struct heap_ftab_val *f_val,
struct cmc_alloc_node *alloc,
struct heap_fval *f_val, struct cmc_alloc_node *alloc,
struct cmc_callbacks *callbacks);
void h_clear(struct heap *_heap_);
void h_free(struct heap *_heap_);
@@ -72,7 +71,7 @@ static void h_impl_float_down(struct heap *_heap_, size_t index);
static struct heap_iter h_impl_it_start(struct heap *_heap_);
static struct heap_iter h_impl_it_end(struct heap *_heap_);
struct heap *h_new(size_t capacity, enum cmc_heap_order HO,
struct heap_ftab_val *f_val)
struct heap_fval *f_val)
{
struct cmc_alloc_node *alloc = &cmc_alloc_node_default;
if (capacity < 1)
@@ -102,8 +101,7 @@ struct heap *h_new(size_t capacity, enum cmc_heap_order HO,
return _heap_;
}
struct heap *h_new_custom(size_t capacity, enum cmc_heap_order HO,
struct heap_ftab_val *f_val,
struct cmc_alloc_node *alloc,
struct heap_fval *f_val, struct cmc_alloc_node *alloc,
struct cmc_callbacks *callbacks)
{
if (capacity < 1)
+6 -8
View File
@@ -7,7 +7,7 @@ struct intervalheap
size_t size;
size_t count;
int flag;
struct intervalheap_ftab_val *f_val;
struct intervalheap_fval *f_val;
struct intervalheap_iter (*it_start)(struct intervalheap *);
struct intervalheap_iter (*it_end)(struct intervalheap *);
struct cmc_alloc_node *alloc;
@@ -17,7 +17,7 @@ struct intervalheap_node
{
size_t data[2];
};
struct intervalheap_ftab_val
struct intervalheap_fval
{
int (*cmp)(size_t, size_t);
size_t (*cpy)(size_t);
@@ -33,10 +33,9 @@ struct intervalheap_iter
_Bool start;
_Bool end;
};
struct intervalheap *ih_new(size_t capacity,
struct intervalheap_ftab_val *f_val);
struct intervalheap *ih_new(size_t capacity, struct intervalheap_fval *f_val);
struct intervalheap *ih_new_custom(size_t capacity,
struct intervalheap_ftab_val *f_val,
struct intervalheap_fval *f_val,
struct cmc_alloc_node *alloc,
struct cmc_callbacks *callbacks);
void ih_clear(struct intervalheap *_heap_);
@@ -81,8 +80,7 @@ static void ih_impl_float_down_max(struct intervalheap *_heap_);
static void ih_impl_float_down_min(struct intervalheap *_heap_);
static struct intervalheap_iter ih_impl_it_start(struct intervalheap *_heap_);
static struct intervalheap_iter ih_impl_it_end(struct intervalheap *_heap_);
struct intervalheap *ih_new(size_t capacity,
struct intervalheap_ftab_val *f_val)
struct intervalheap *ih_new(size_t capacity, struct intervalheap_fval *f_val)
{
struct cmc_alloc_node *alloc = &cmc_alloc_node_default;
if (capacity == 0 || capacity == 0xffffffffffffffffULL)
@@ -111,7 +109,7 @@ struct intervalheap *ih_new(size_t capacity,
return _heap_;
}
struct intervalheap *ih_new_custom(size_t capacity,
struct intervalheap_ftab_val *f_val,
struct intervalheap_fval *f_val,
struct cmc_alloc_node *alloc,
struct cmc_callbacks *callbacks)
{
+6 -6
View File
@@ -6,7 +6,7 @@ struct linkedlist
struct linkedlist_node *tail;
size_t count;
int flag;
struct linkedlist_ftab_val *f_val;
struct linkedlist_fval *f_val;
struct cmc_alloc_node *alloc;
struct cmc_callbacks *callbacks;
struct linkedlist_iter (*it_start)(struct linkedlist *);
@@ -18,7 +18,7 @@ struct linkedlist_node
struct linkedlist_node *next;
struct linkedlist_node *prev;
};
struct linkedlist_ftab_val
struct linkedlist_fval
{
int (*cmp)(size_t, size_t);
size_t (*cpy)(size_t);
@@ -35,8 +35,8 @@ struct linkedlist_iter
_Bool start;
_Bool end;
};
struct linkedlist *ll_new(struct linkedlist_ftab_val *f_val);
struct linkedlist *ll_new_custom(struct linkedlist_ftab_val *f_val,
struct linkedlist *ll_new(struct linkedlist_fval *f_val);
struct linkedlist *ll_new_custom(struct linkedlist_fval *f_val,
struct cmc_alloc_node *alloc,
struct cmc_callbacks *callbacks);
void ll_clear(struct linkedlist *_list_);
@@ -93,7 +93,7 @@ size_t ll_iter_index(struct linkedlist_iter *iter);
struct linkedlist_node *ll_iter_node(struct linkedlist_iter *iter);
static struct linkedlist_iter ll_impl_it_start(struct linkedlist *_list_);
static struct linkedlist_iter ll_impl_it_end(struct linkedlist *_list_);
struct linkedlist *ll_new(struct linkedlist_ftab_val *f_val)
struct linkedlist *ll_new(struct linkedlist_fval *f_val)
{
if (!f_val)
return ((void *)0);
@@ -112,7 +112,7 @@ struct linkedlist *ll_new(struct linkedlist_ftab_val *f_val)
_list_->it_end = ll_impl_it_end;
return _list_;
}
struct linkedlist *ll_new_custom(struct linkedlist_ftab_val *f_val,
struct linkedlist *ll_new_custom(struct linkedlist_fval *f_val,
struct cmc_alloc_node *alloc,
struct cmc_callbacks *callbacks)
{
+6 -6
View File
@@ -6,13 +6,13 @@ struct list
size_t capacity;
size_t count;
int flag;
struct list_ftab_val *f_val;
struct list_fval *f_val;
struct list_iter (*it_start)(struct list *);
struct list_iter (*it_end)(struct list *);
struct cmc_alloc_node *alloc;
struct cmc_callbacks *callbacks;
};
struct list_ftab_val
struct list_fval
{
int (*cmp)(size_t, size_t);
size_t (*cpy)(size_t);
@@ -28,8 +28,8 @@ struct list_iter
_Bool start;
_Bool end;
};
struct list *l_new(size_t capacity, struct list_ftab_val *f_val);
struct list *l_new_custom(size_t capacity, struct list_ftab_val *f_val,
struct list *l_new(size_t capacity, struct list_fval *f_val);
struct list *l_new_custom(size_t capacity, struct list_fval *f_val,
struct cmc_alloc_node *alloc,
struct cmc_callbacks *callbacks);
void l_clear(struct list *_list_);
@@ -82,7 +82,7 @@ size_t *l_iter_rvalue(struct list_iter *iter);
size_t l_iter_index(struct list_iter *iter);
static struct list_iter l_impl_it_start(struct list *_list_);
static struct list_iter l_impl_it_end(struct list *_list_);
struct list *l_new(size_t capacity, struct list_ftab_val *f_val)
struct list *l_new(size_t capacity, struct list_fval *f_val)
{
struct cmc_alloc_node *alloc = &cmc_alloc_node_default;
if (capacity < 1)
@@ -106,7 +106,7 @@ struct list *l_new(size_t capacity, struct list_ftab_val *f_val)
_list_->it_end = l_impl_it_end;
return _list_;
}
struct list *l_new_custom(size_t capacity, struct list_ftab_val *f_val,
struct list *l_new_custom(size_t capacity, struct list_fval *f_val,
struct cmc_alloc_node *alloc,
struct cmc_callbacks *callbacks)
{
+12 -12
View File
@@ -7,8 +7,8 @@ struct multimap
size_t count;
double load;
int flag;
struct multimap_ftab_key *f_key;
struct multimap_ftab_val *f_val;
struct multimap_fkey *f_key;
struct multimap_fval *f_val;
struct cmc_alloc_node *alloc;
struct cmc_callbacks *callbacks;
struct multimap_iter (*it_start)(struct multimap *);
@@ -21,7 +21,7 @@ struct multimap_entry
struct multimap_entry *next;
struct multimap_entry *prev;
};
struct multimap_ftab_key
struct multimap_fkey
{
int (*cmp)(size_t, size_t);
size_t (*cpy)(size_t);
@@ -30,7 +30,7 @@ struct multimap_ftab_key
size_t (*hash)(size_t);
int (*pri)(size_t, size_t);
};
struct multimap_ftab_val
struct multimap_fval
{
int (*cmp)(size_t, size_t);
size_t (*cpy)(size_t);
@@ -51,11 +51,11 @@ struct multimap_iter
_Bool end;
};
struct multimap *mm_new(size_t capacity, double load,
struct multimap_ftab_key *f_key,
struct multimap_ftab_val *f_val);
struct multimap_fkey *f_key,
struct multimap_fval *f_val);
struct multimap *mm_new_custom(size_t capacity, double load,
struct multimap_ftab_key *f_key,
struct multimap_ftab_val *f_val,
struct multimap_fkey *f_key,
struct multimap_fval *f_val,
struct cmc_alloc_node *alloc,
struct cmc_callbacks *callbacks);
void mm_clear(struct multimap *_map_);
@@ -110,8 +110,8 @@ size_t mm_impl_calculate_size(size_t required);
static struct multimap_iter mm_impl_it_start(struct multimap *_map_);
static struct multimap_iter mm_impl_it_end(struct multimap *_map_);
struct multimap *mm_new(size_t capacity, double load,
struct multimap_ftab_key *f_key,
struct multimap_ftab_val *f_val)
struct multimap_fkey *f_key,
struct multimap_fval *f_val)
{
struct cmc_alloc_node *alloc = &cmc_alloc_node_default;
if (capacity == 0 || load <= 0)
@@ -144,8 +144,8 @@ struct multimap *mm_new(size_t capacity, double load,
return _map_;
}
struct multimap *mm_new_custom(size_t capacity, double load,
struct multimap_ftab_key *f_key,
struct multimap_ftab_val *f_val,
struct multimap_fkey *f_key,
struct multimap_fval *f_val,
struct cmc_alloc_node *alloc,
struct cmc_callbacks *callbacks)
{
+6 -6
View File
@@ -8,7 +8,7 @@ struct multiset
size_t cardinality;
double load;
int flag;
struct multiset_ftab_val *f_val;
struct multiset_fval *f_val;
struct cmc_alloc_node *alloc;
struct cmc_callbacks *callbacks;
struct multiset_iter (*it_start)(struct multiset *);
@@ -21,7 +21,7 @@ struct multiset_entry
size_t dist;
enum cmc_entry_state state;
};
struct multiset_ftab_val
struct multiset_fval
{
int (*cmp)(size_t, size_t);
size_t (*cpy)(size_t);
@@ -41,9 +41,9 @@ struct multiset_iter
_Bool end;
};
struct multiset *ms_new(size_t capacity, double load,
struct multiset_ftab_val *f_val);
struct multiset_fval *f_val);
struct multiset *ms_new_custom(size_t capacity, double load,
struct multiset_ftab_val *f_val,
struct multiset_fval *f_val,
struct cmc_alloc_node *alloc,
struct cmc_callbacks *callbacks);
void ms_clear(struct multiset *_set_);
@@ -109,7 +109,7 @@ static size_t ms_impl_calculate_size(size_t required);
static struct multiset_iter ms_impl_it_start(struct multiset *_set_);
static struct multiset_iter ms_impl_it_end(struct multiset *_set_);
struct multiset *ms_new(size_t capacity, double load,
struct multiset_ftab_val *f_val)
struct multiset_fval *f_val)
{
struct cmc_alloc_node *alloc = &cmc_alloc_node_default;
if (capacity == 0 || load <= 0 || load >= 1)
@@ -141,7 +141,7 @@ struct multiset *ms_new(size_t capacity, double load,
return _set_;
}
struct multiset *ms_new_custom(size_t capacity, double load,
struct multiset_ftab_val *f_val,
struct multiset_fval *f_val,
struct cmc_alloc_node *alloc,
struct cmc_callbacks *callbacks)
{
+6 -6
View File
@@ -8,13 +8,13 @@ struct queue
size_t front;
size_t back;
int flag;
struct queue_ftab_val *f_val;
struct queue_fval *f_val;
struct cmc_alloc_node *alloc;
struct cmc_callbacks *callbacks;
struct queue_iter (*it_start)(struct queue *);
struct queue_iter (*it_end)(struct queue *);
};
struct queue_ftab_val
struct queue_fval
{
int (*cmp)(size_t, size_t);
size_t (*cpy)(size_t);
@@ -31,8 +31,8 @@ struct queue_iter
_Bool start;
_Bool end;
};
struct queue *q_new(size_t capacity, struct queue_ftab_val *f_val);
struct queue *q_new_custom(size_t capacity, struct queue_ftab_val *f_val,
struct queue *q_new(size_t capacity, struct queue_fval *f_val);
struct queue *q_new_custom(size_t capacity, struct queue_fval *f_val,
struct cmc_alloc_node *alloc,
struct cmc_callbacks *callbacks);
void q_clear(struct queue *_queue_);
@@ -70,7 +70,7 @@ size_t *q_iter_rvalue(struct queue_iter *iter);
size_t q_iter_index(struct queue_iter *iter);
static struct queue_iter q_impl_it_start(struct queue *_queue_);
static struct queue_iter q_impl_it_end(struct queue *_queue_);
struct queue *q_new(size_t capacity, struct queue_ftab_val *f_val)
struct queue *q_new(size_t capacity, struct queue_fval *f_val)
{
struct cmc_alloc_node *alloc = &cmc_alloc_node_default;
if (capacity < 1)
@@ -98,7 +98,7 @@ struct queue *q_new(size_t capacity, struct queue_ftab_val *f_val)
_queue_->it_end = q_impl_it_end;
return _queue_;
}
struct queue *q_new_custom(size_t capacity, struct queue_ftab_val *f_val,
struct queue *q_new_custom(size_t capacity, struct queue_fval *f_val,
struct cmc_alloc_node *alloc,
struct cmc_callbacks *callbacks)
{
+6 -8
View File
@@ -7,13 +7,13 @@ struct sortedlist
size_t count;
_Bool is_sorted;
int flag;
struct sortedlist_ftab_val *f_val;
struct sortedlist_fval *f_val;
struct cmc_alloc_node *alloc;
struct cmc_callbacks *callbacks;
struct sortedlist_iter (*it_start)(struct sortedlist *);
struct sortedlist_iter (*it_end)(struct sortedlist *);
};
struct sortedlist_ftab_val
struct sortedlist_fval
{
int (*cmp)(size_t, size_t);
size_t (*cpy)(size_t);
@@ -29,9 +29,8 @@ struct sortedlist_iter
_Bool start;
_Bool end;
};
struct sortedlist *sl_new(size_t capacity, struct sortedlist_ftab_val *f_val);
struct sortedlist *sl_new_custom(size_t capacity,
struct sortedlist_ftab_val *f_val,
struct sortedlist *sl_new(size_t capacity, struct sortedlist_fval *f_val);
struct sortedlist *sl_new_custom(size_t capacity, struct sortedlist_fval *f_val,
struct cmc_alloc_node *alloc,
struct cmc_callbacks *callbacks);
void sl_clear(struct sortedlist *_list_);
@@ -80,7 +79,7 @@ void sl_impl_sort_insertion(size_t *array, int (*cmp)(size_t, size_t),
size_t low, size_t high);
static struct sortedlist_iter sl_impl_it_start(struct sortedlist *_list_);
static struct sortedlist_iter sl_impl_it_end(struct sortedlist *_list_);
struct sortedlist *sl_new(size_t capacity, struct sortedlist_ftab_val *f_val)
struct sortedlist *sl_new(size_t capacity, struct sortedlist_fval *f_val)
{
struct cmc_alloc_node *alloc = &cmc_alloc_node_default;
if (capacity < 1)
@@ -107,8 +106,7 @@ struct sortedlist *sl_new(size_t capacity, struct sortedlist_ftab_val *f_val)
_list_->it_end = sl_impl_it_end;
return _list_;
}
struct sortedlist *sl_new_custom(size_t capacity,
struct sortedlist_ftab_val *f_val,
struct sortedlist *sl_new_custom(size_t capacity, struct sortedlist_fval *f_val,
struct cmc_alloc_node *alloc,
struct cmc_callbacks *callbacks)
{
+6 -6
View File
@@ -6,13 +6,13 @@ struct stack
size_t capacity;
size_t count;
int flag;
struct stack_ftab_val *f_val;
struct stack_fval *f_val;
struct cmc_alloc_node *alloc;
struct cmc_callbacks *callbacks;
struct stack_iter (*it_start)(struct stack *);
struct stack_iter (*it_end)(struct stack *);
};
struct stack_ftab_val
struct stack_fval
{
int (*cmp)(size_t, size_t);
size_t (*cpy)(size_t);
@@ -28,8 +28,8 @@ struct stack_iter
_Bool start;
_Bool end;
};
struct stack *s_new(size_t capacity, struct stack_ftab_val *f_val);
struct stack *s_new_custom(size_t capacity, struct stack_ftab_val *f_val,
struct stack *s_new(size_t capacity, struct stack_fval *f_val);
struct stack *s_new_custom(size_t capacity, struct stack_fval *f_val,
struct cmc_alloc_node *alloc,
struct cmc_callbacks *callbacks);
void s_clear(struct stack *_stack_);
@@ -67,7 +67,7 @@ size_t *s_iter_rvalue(struct stack_iter *iter);
size_t s_iter_index(struct stack_iter *iter);
static struct stack_iter s_impl_it_start(struct stack *_stack_);
static struct stack_iter s_impl_it_end(struct stack *_stack_);
struct stack *s_new(size_t capacity, struct stack_ftab_val *f_val)
struct stack *s_new(size_t capacity, struct stack_fval *f_val)
{
struct cmc_alloc_node *alloc = &cmc_alloc_node_default;
if (capacity < 1)
@@ -93,7 +93,7 @@ struct stack *s_new(size_t capacity, struct stack_ftab_val *f_val)
_stack_->it_end = s_impl_it_end;
return _stack_;
}
struct stack *s_new_custom(size_t capacity, struct stack_ftab_val *f_val,
struct stack *s_new_custom(size_t capacity, struct stack_fval *f_val,
struct cmc_alloc_node *alloc,
struct cmc_callbacks *callbacks)
{
+10 -12
View File
@@ -5,8 +5,8 @@ struct treemap
struct treemap_node *root;
size_t count;
int flag;
struct treemap_ftab_key *f_key;
struct treemap_ftab_val *f_val;
struct treemap_fkey *f_key;
struct treemap_fval *f_val;
struct cmc_alloc_node *alloc;
struct cmc_callbacks *callbacks;
struct treemap_iter (*it_start)(struct treemap *);
@@ -21,7 +21,7 @@ struct treemap_node
struct treemap_node *left;
struct treemap_node *parent;
};
struct treemap_ftab_key
struct treemap_fkey
{
int (*cmp)(size_t, size_t);
size_t (*cpy)(size_t);
@@ -30,7 +30,7 @@ struct treemap_ftab_key
size_t (*hash)(size_t);
int (*pri)(size_t, size_t);
};
struct treemap_ftab_val
struct treemap_fval
{
int (*cmp)(size_t, size_t);
size_t (*cpy)(size_t);
@@ -49,10 +49,9 @@ struct treemap_iter
_Bool start;
_Bool end;
};
struct treemap *tm_new(struct treemap_ftab_key *f_key,
struct treemap_ftab_val *f_val);
struct treemap *tm_new_custom(struct treemap_ftab_key *f_key,
struct treemap_ftab_val *f_val,
struct treemap *tm_new(struct treemap_fkey *f_key, struct treemap_fval *f_val);
struct treemap *tm_new_custom(struct treemap_fkey *f_key,
struct treemap_fval *f_val,
struct cmc_alloc_node *alloc,
struct cmc_callbacks *callbacks);
void tm_clear(struct treemap *_map_);
@@ -101,8 +100,7 @@ static void tm_impl_rotate_left(struct treemap_node **Z);
static void tm_impl_rebalance(struct treemap *_map_, struct treemap_node *node);
static struct treemap_iter tm_impl_it_start(struct treemap *_map_);
static struct treemap_iter tm_impl_it_end(struct treemap *_map_);
struct treemap *tm_new(struct treemap_ftab_key *f_key,
struct treemap_ftab_val *f_val)
struct treemap *tm_new(struct treemap_fkey *f_key, struct treemap_fval *f_val)
{
if (!f_key || !f_val)
return ((void *)0);
@@ -121,8 +119,8 @@ struct treemap *tm_new(struct treemap_ftab_key *f_key,
_map_->it_end = tm_impl_it_end;
return _map_;
}
struct treemap *tm_new_custom(struct treemap_ftab_key *f_key,
struct treemap_ftab_val *f_val,
struct treemap *tm_new_custom(struct treemap_fkey *f_key,
struct treemap_fval *f_val,
struct cmc_alloc_node *alloc,
struct cmc_callbacks *callbacks)
{
+6 -6
View File
@@ -5,7 +5,7 @@ struct treeset
struct treeset_node *root;
size_t count;
int flag;
struct treeset_ftab_val *f_val;
struct treeset_fval *f_val;
struct cmc_alloc_node *alloc;
struct cmc_callbacks *callbacks;
struct treeset_iter (*it_start)(struct treeset *);
@@ -19,7 +19,7 @@ struct treeset_node
struct treeset_node *left;
struct treeset_node *parent;
};
struct treeset_ftab_val
struct treeset_fval
{
int (*cmp)(size_t, size_t);
size_t (*cpy)(size_t);
@@ -38,8 +38,8 @@ struct treeset_iter
_Bool start;
_Bool end;
};
struct treeset *ts_new(struct treeset_ftab_val *f_val);
struct treeset *ts_new_custom(struct treeset_ftab_val *f_val,
struct treeset *ts_new(struct treeset_fval *f_val);
struct treeset *ts_new_custom(struct treeset_fval *f_val,
struct cmc_alloc_node *alloc,
struct cmc_callbacks *callbacks);
void ts_clear(struct treeset *_set_);
@@ -99,7 +99,7 @@ static void ts_impl_rotate_left(struct treeset_node **Z);
static void ts_impl_rebalance(struct treeset *_set_, struct treeset_node *node);
static struct treeset_iter ts_impl_it_start(struct treeset *_set_);
static struct treeset_iter ts_impl_it_end(struct treeset *_set_);
struct treeset *ts_new(struct treeset_ftab_val *f_val)
struct treeset *ts_new(struct treeset_fval *f_val)
{
if (!f_val)
return ((void *)0);
@@ -117,7 +117,7 @@ struct treeset *ts_new(struct treeset_ftab_val *f_val)
_set_->it_end = ts_impl_it_end;
return _set_;
}
struct treeset *ts_new_custom(struct treeset_ftab_val *f_val,
struct treeset *ts_new_custom(struct treeset_fval *f_val,
struct cmc_alloc_node *alloc,
struct cmc_callbacks *callbacks)
{
+40 -40
View File
@@ -5,32 +5,32 @@
#include "../src/bidimap.c"
struct bidimap_ftab_key *bm_ftab_key =
&(struct bidimap_ftab_key){ .cmp = cmp,
struct bidimap_fkey *bm_fkey =
&(struct bidimap_fkey){ .cmp = cmp,
.cpy = copy,
.str = str,
.free = custom_free,
.hash = hash,
.pri = pri };
struct bidimap_ftab_val *bm_ftab_val =
&(struct bidimap_ftab_val){ .cmp = cmp,
struct bidimap_fval *bm_fval =
&(struct bidimap_fval){ .cmp = cmp,
.cpy = copy,
.str = str,
.free = custom_free,
.hash = hash,
.pri = pri };
struct bidimap_ftab_key *bm_ftab_key_counter =
&(struct bidimap_ftab_key){ .cmp = k_c_cmp,
struct bidimap_fkey *bm_fkey_counter =
&(struct bidimap_fkey){ .cmp = k_c_cmp,
.cpy = k_c_cpy,
.str = k_c_str,
.free = k_c_free,
.hash = k_c_hash,
.pri = k_c_pri };
struct bidimap_ftab_val *bm_ftab_val_counter =
&(struct bidimap_ftab_val){ .cmp = v_c_cmp,
struct bidimap_fval *bm_fval_counter =
&(struct bidimap_fval){ .cmp = v_c_cmp,
.cpy = v_c_cpy,
.str = v_c_str,
.free = v_c_free,
@@ -39,7 +39,7 @@ struct bidimap_ftab_val *bm_ftab_val_counter =
CMC_CREATE_UNIT(bidimap_test, true, {
CMC_CREATE_TEST(new, {
struct bidimap *map = bm_new(100, 0.6, bm_ftab_key, bm_ftab_val);
struct bidimap *map = bm_new(100, 0.6, bm_fkey, bm_fval);
cmc_assert_not_equals(ptr, NULL, map);
@@ -49,7 +49,7 @@ CMC_CREATE_UNIT(bidimap_test, true, {
});
CMC_CREATE_TEST(new[null buffer], {
struct bidimap *map = bm_new(100, 0.6, bm_ftab_key, bm_ftab_val);
struct bidimap *map = bm_new(100, 0.6, bm_fkey, bm_fval);
cmc_assert_not_equals(ptr, NULL, map);
@@ -64,7 +64,7 @@ CMC_CREATE_UNIT(bidimap_test, true, {
CMC_CREATE_TEST(new_custom, {
struct bidimap *map =
bm_new_custom(100, 0.6, bm_ftab_key, bm_ftab_val,
bm_new_custom(100, 0.6, bm_fkey, bm_fval,
&(struct cmc_alloc_node){ .malloc = malloc,
.calloc = calloc,
.realloc = realloc,
@@ -78,7 +78,7 @@ CMC_CREATE_UNIT(bidimap_test, true, {
CMC_CREATE_TEST(new_custom[insert remove], {
struct bidimap *map =
bm_new_custom(500, 0.6, bm_ftab_key, bm_ftab_val,
bm_new_custom(500, 0.6, bm_fkey, bm_fval,
&(struct cmc_alloc_node){ .malloc = malloc,
.calloc = calloc,
.realloc = realloc,
@@ -111,7 +111,7 @@ CMC_CREATE_UNIT(bidimap_test, true, {
CMC_CREATE_TEST(clear[ftab free calls], {
struct bidimap *map =
bm_new(1000, 0.6, bm_ftab_key_counter, bm_ftab_val_counter);
bm_new(1000, 0.6, bm_fkey_counter, bm_fval_counter);
cmc_assert_not_equals(ptr, NULL, map);
@@ -131,7 +131,7 @@ CMC_CREATE_UNIT(bidimap_test, true, {
cmc_assert_equals(int32_t, 1000, k_total_free);
cmc_assert_equals(int32_t, 1000, v_total_free);
bm_ftab_val_counter->free = NULL;
bm_fval_counter->free = NULL;
for (size_t i = 0; i < 1000; i++)
cmc_assert(bm_insert(map, i, i));
@@ -141,8 +141,8 @@ CMC_CREATE_UNIT(bidimap_test, true, {
cmc_assert_equals(int32_t, 2000, k_total_free);
cmc_assert_equals(int32_t, 1000, v_total_free);
bm_ftab_val_counter->free = v_c_free;
bm_ftab_key_counter->free = NULL;
bm_fval_counter->free = v_c_free;
bm_fkey_counter->free = NULL;
for (size_t i = 0; i < 1000; i++)
cmc_assert(bm_insert(map, i, i));
@@ -152,7 +152,7 @@ CMC_CREATE_UNIT(bidimap_test, true, {
cmc_assert_equals(int32_t, 2000, k_total_free);
cmc_assert_equals(int32_t, 2000, v_total_free);
bm_ftab_key_counter->free = k_c_free;
bm_fkey_counter->free = k_c_free;
bm_free(map);
@@ -161,7 +161,7 @@ CMC_CREATE_UNIT(bidimap_test, true, {
});
CMC_CREATE_TEST(clear[count], {
struct bidimap *map = bm_new(100, 0.6, bm_ftab_key, bm_ftab_val);
struct bidimap *map = bm_new(100, 0.6, bm_fkey, bm_fval);
cmc_assert_not_equals(ptr, NULL, map);
@@ -179,7 +179,7 @@ CMC_CREATE_UNIT(bidimap_test, true, {
CMC_CREATE_TEST(customize, {
struct bidimap *map =
bm_new_custom(100, 0.6, bm_ftab_key, bm_ftab_val, NULL, NULL);
bm_new_custom(100, 0.6, bm_fkey, bm_fval, NULL, NULL);
cmc_assert_not_equals(ptr, NULL, map);
@@ -195,7 +195,7 @@ CMC_CREATE_UNIT(bidimap_test, true, {
node.calloc = calloc;
map =
bm_new_custom(100, 0.6, bm_ftab_key, bm_ftab_val, &node, callbacks);
bm_new_custom(100, 0.6, bm_fkey, bm_fval, &node, callbacks);
cmc_assert_not_equals(ptr, NULL, map);
@@ -206,7 +206,7 @@ CMC_CREATE_UNIT(bidimap_test, true, {
});
CMC_CREATE_TEST(buffer_growth[capacity = 1], {
struct bidimap *map = bm_new(1, 0.7, bm_ftab_key, bm_ftab_val);
struct bidimap *map = bm_new(1, 0.7, bm_fkey, bm_fval);
cmc_assert_not_equals(ptr, NULL, map);
@@ -229,7 +229,7 @@ CMC_CREATE_UNIT(bidimap_test, true, {
});
CMC_CREATE_TEST(insert, {
struct bidimap *map = bm_new(100, 0.7, bm_ftab_key, bm_ftab_val);
struct bidimap *map = bm_new(100, 0.7, bm_fkey, bm_fval);
cmc_assert_not_equals(ptr, NULL, map);
@@ -243,7 +243,7 @@ CMC_CREATE_UNIT(bidimap_test, true, {
});
CMC_CREATE_TEST(insert[duplicate], {
struct bidimap *map = bm_new(100, 0.7, bm_ftab_key, bm_ftab_val);
struct bidimap *map = bm_new(100, 0.7, bm_fkey, bm_fval);
cmc_assert_not_equals(ptr, NULL, map);
@@ -259,7 +259,7 @@ CMC_CREATE_UNIT(bidimap_test, true, {
});
CMC_CREATE_TEST(insert[references], {
struct bidimap *map = bm_new(500, 0.7, bm_ftab_key, bm_ftab_val);
struct bidimap *map = bm_new(500, 0.7, bm_fkey, bm_fval);
cmc_assert_not_equals(ptr, NULL, map);
@@ -281,7 +281,7 @@ CMC_CREATE_UNIT(bidimap_test, true, {
});
CMC_CREATE_TEST(insert[growth remove clear], {
struct bidimap *map = bm_new(100, 0.7, bm_ftab_key, bm_ftab_val);
struct bidimap *map = bm_new(100, 0.7, bm_fkey, bm_fval);
cmc_assert_not_equals(ptr, NULL, map);
@@ -315,7 +315,7 @@ CMC_CREATE_UNIT(bidimap_test, true, {
CMC_CREATE_TEST(insert[ftab hash calls], {
struct bidimap *map =
bm_new(100, 0.7, bm_ftab_key_counter, bm_ftab_val_counter);
bm_new(100, 0.7, bm_fkey_counter, bm_fval_counter);
cmc_assert_not_equals(ptr, NULL, map);
@@ -335,7 +335,7 @@ CMC_CREATE_UNIT(bidimap_test, true, {
});
CMC_CREATE_TEST(update_key, {
struct bidimap *map = bm_new(100, 0.7, bm_ftab_key, bm_ftab_val);
struct bidimap *map = bm_new(100, 0.7, bm_fkey, bm_fval);
cmc_assert_not_equals(ptr, NULL, map);
@@ -358,7 +358,7 @@ CMC_CREATE_UNIT(bidimap_test, true, {
});
CMC_CREATE_TEST(update_key[empty], {
struct bidimap *map = bm_new(100, 0.7, bm_ftab_key, bm_ftab_val);
struct bidimap *map = bm_new(100, 0.7, bm_fkey, bm_fval);
cmc_assert_not_equals(ptr, NULL, map);
@@ -372,7 +372,7 @@ CMC_CREATE_UNIT(bidimap_test, true, {
});
CMC_CREATE_TEST(update_key[not_found duplicate], {
struct bidimap *map = bm_new(100, 0.7, bm_ftab_key, bm_ftab_val);
struct bidimap *map = bm_new(100, 0.7, bm_fkey, bm_fval);
cmc_assert_not_equals(ptr, NULL, map);
@@ -402,7 +402,7 @@ CMC_CREATE_UNIT(bidimap_test, true, {
});
CMC_CREATE_TEST(update_val, {
struct bidimap *map = bm_new(100, 0.7, bm_ftab_key, bm_ftab_val);
struct bidimap *map = bm_new(100, 0.7, bm_fkey, bm_fval);
cmc_assert_not_equals(ptr, NULL, map);
@@ -425,7 +425,7 @@ CMC_CREATE_UNIT(bidimap_test, true, {
});
CMC_CREATE_TEST(update_val[empty], {
struct bidimap *map = bm_new(100, 0.7, bm_ftab_key, bm_ftab_val);
struct bidimap *map = bm_new(100, 0.7, bm_fkey, bm_fval);
cmc_assert_not_equals(ptr, NULL, map);
@@ -439,7 +439,7 @@ CMC_CREATE_UNIT(bidimap_test, true, {
});
CMC_CREATE_TEST(update_val[not_found duplicate], {
struct bidimap *map = bm_new(100, 0.7, bm_ftab_key, bm_ftab_val);
struct bidimap *map = bm_new(100, 0.7, bm_fkey, bm_fval);
cmc_assert_not_equals(ptr, NULL, map);
@@ -470,7 +470,7 @@ CMC_CREATE_UNIT(bidimap_test, true, {
CMC_CREATE_TEST(remove_by_key[cleanup custom], {
struct bidimap *map =
bm_new_custom(10000, 0.6, bm_ftab_key, bm_ftab_val,
bm_new_custom(10000, 0.6, bm_fkey, bm_fval,
&(struct cmc_alloc_node){ .malloc = malloc,
.calloc = calloc,
.realloc = realloc,
@@ -503,7 +503,7 @@ CMC_CREATE_UNIT(bidimap_test, true, {
CMC_CREATE_TEST(remove_by_val[cleanup custom], {
struct bidimap *map =
bm_new_custom(10000, 0.6, bm_ftab_key, bm_ftab_val,
bm_new_custom(10000, 0.6, bm_fkey, bm_fval,
&(struct cmc_alloc_node){ .malloc = malloc,
.calloc = calloc,
.realloc = realloc,
@@ -535,7 +535,7 @@ CMC_CREATE_UNIT(bidimap_test, true, {
});
CMC_CREATE_TEST(copy_of, {
struct bidimap *map1 = bm_new(100, 0.7, bm_ftab_key, bm_ftab_val);
struct bidimap *map1 = bm_new(100, 0.7, bm_fkey, bm_fval);
for (size_t i = 0; i < 100; i++)
cmc_assert(bm_insert(map1, i, i));
@@ -556,8 +556,8 @@ CMC_CREATE_UNIT(bidimap_test, true, {
});
CMC_CREATE_TEST(equals, {
struct bidimap *map1 = bm_new(100, 0.7, bm_ftab_key, bm_ftab_val);
struct bidimap *map2 = bm_new(1000, 0.9, bm_ftab_key, bm_ftab_val);
struct bidimap *map1 = bm_new(100, 0.7, bm_fkey, bm_fval);
struct bidimap *map2 = bm_new(1000, 0.9, bm_fkey, bm_fval);
for (size_t i = 0; i < 100; i++)
{
@@ -580,7 +580,7 @@ CMC_CREATE_UNIT(bidimap_test, true, {
});
CMC_CREATE_TEST(equals[from copy], {
struct bidimap *map1 = bm_new(100, 0.7, bm_ftab_key, bm_ftab_val);
struct bidimap *map1 = bm_new(100, 0.7, bm_fkey, bm_fval);
for (size_t i = 0; i < 100; i++)
cmc_assert(bm_insert(map1, i, i));
@@ -596,7 +596,7 @@ CMC_CREATE_UNIT(bidimap_test, true, {
});
CMC_CREATE_TEST(flags, {
struct bidimap *map = bm_new(100, 0.7, bm_ftab_key, bm_ftab_val);
struct bidimap *map = bm_new(100, 0.7, bm_fkey, bm_fval);
cmc_assert_not_equals(ptr, NULL, map);
cmc_assert_equals(int32_t, cmc_flags.OK, bm_flag(map));
@@ -733,7 +733,7 @@ CMC_CREATE_UNIT(bidimap_test, true, {
CMC_CREATE_TEST(callbacks, {
struct bidimap *map =
bm_new_custom(100, 0.7, bm_ftab_key, bm_ftab_val, NULL, callbacks);
bm_new_custom(100, 0.7, bm_fkey, bm_fval, NULL, callbacks);
cmc_assert_not_equals(ptr, NULL, map);
cmc_assert_equals(ptr, callbacks, map->callbacks);
+37 -37
View File
@@ -5,8 +5,8 @@
#include "../src/deque.c"
struct deque_ftab_val *d_ftab_val =
&(struct deque_ftab_val){ .cmp = cmp,
struct deque_fval *d_fval =
&(struct deque_fval){ .cmp = cmp,
.cpy = copy,
.str = str,
.free = custom_free,
@@ -15,7 +15,7 @@ struct deque_ftab_val *d_ftab_val =
CMC_CREATE_UNIT(deque_test, true, {
CMC_CREATE_TEST(new, {
struct deque *d = d_new(1000000, d_ftab_val);
struct deque *d = d_new(1000000, d_fval);
cmc_assert_not_equals(ptr, NULL, d);
cmc_assert_not_equals(ptr, NULL, d->buffer);
@@ -26,19 +26,19 @@ CMC_CREATE_UNIT(deque_test, true, {
});
CMC_CREATE_TEST(new[capacity = 0], {
struct deque *d = d_new(0, d_ftab_val);
struct deque *d = d_new(0, d_fval);
cmc_assert_equals(ptr, NULL, d);
});
CMC_CREATE_TEST(new[capacity = UINT64_MAX], {
struct deque *d = d_new(UINT64_MAX, d_ftab_val);
struct deque *d = d_new(UINT64_MAX, d_fval);
cmc_assert_equals(ptr, NULL, d);
});
CMC_CREATE_TEST(clear[count capacity], {
struct deque *d = d_new(100, d_ftab_val);
struct deque *d = d_new(100, d_fval);
cmc_assert_not_equals(ptr, NULL, d);
@@ -56,7 +56,7 @@ CMC_CREATE_UNIT(deque_test, true, {
});
CMC_CREATE_TEST(buffer_growth[capacity = 1], {
struct deque *d = d_new(1, d_ftab_val);
struct deque *d = d_new(1, d_fval);
cmc_assert_not_equals(ptr, NULL, d);
@@ -70,7 +70,7 @@ CMC_CREATE_UNIT(deque_test, true, {
});
CMC_CREATE_TEST(buffer_growth[item preservation], {
struct deque *d = d_new(100, d_ftab_val);
struct deque *d = d_new(100, d_fval);
cmc_assert_not_equals(ptr, NULL, d);
@@ -94,7 +94,7 @@ CMC_CREATE_UNIT(deque_test, true, {
});
CMC_CREATE_TEST(push_front[count capacity], {
struct deque *d = d_new(100, d_ftab_val);
struct deque *d = d_new(100, d_fval);
cmc_assert_not_equals(ptr, NULL, d);
@@ -108,7 +108,7 @@ CMC_CREATE_UNIT(deque_test, true, {
});
CMC_CREATE_TEST(push_front[item preservation], {
struct deque *d = d_new(100, d_ftab_val);
struct deque *d = d_new(100, d_fval);
cmc_assert_not_equals(ptr, NULL, d);
@@ -129,7 +129,7 @@ CMC_CREATE_UNIT(deque_test, true, {
});
CMC_CREATE_TEST(push_back[count capacity], {
struct deque *d = d_new(100, d_ftab_val);
struct deque *d = d_new(100, d_fval);
cmc_assert_not_equals(ptr, NULL, d);
@@ -143,7 +143,7 @@ CMC_CREATE_UNIT(deque_test, true, {
});
CMC_CREATE_TEST(push_back[item preservation], {
struct deque *d = d_new(100, d_ftab_val);
struct deque *d = d_new(100, d_fval);
cmc_assert_not_equals(ptr, NULL, d);
@@ -164,7 +164,7 @@ CMC_CREATE_UNIT(deque_test, true, {
});
CMC_CREATE_TEST(pop_front[count capacity], {
struct deque *d = d_new(100, d_ftab_val);
struct deque *d = d_new(100, d_fval);
cmc_assert_not_equals(ptr, NULL, d);
@@ -182,7 +182,7 @@ CMC_CREATE_UNIT(deque_test, true, {
});
CMC_CREATE_TEST(pop_front[item preservation], {
struct deque *d = d_new(100, d_ftab_val);
struct deque *d = d_new(100, d_fval);
cmc_assert_not_equals(ptr, NULL, d);
@@ -206,7 +206,7 @@ CMC_CREATE_UNIT(deque_test, true, {
});
CMC_CREATE_TEST(pop_back[count capacity], {
struct deque *d = d_new(100, d_ftab_val);
struct deque *d = d_new(100, d_fval);
cmc_assert_not_equals(ptr, NULL, d);
@@ -224,7 +224,7 @@ CMC_CREATE_UNIT(deque_test, true, {
});
CMC_CREATE_TEST(pop_back[item preservation], {
struct deque *d = d_new(100, d_ftab_val);
struct deque *d = d_new(100, d_fval);
cmc_assert_not_equals(ptr, NULL, d);
@@ -248,7 +248,7 @@ CMC_CREATE_UNIT(deque_test, true, {
});
CMC_CREATE_TEST(Mixed IO, {
struct deque *d = d_new(100, d_ftab_val);
struct deque *d = d_new(100, d_fval);
cmc_assert_not_equals(ptr, NULL, d);
@@ -312,7 +312,7 @@ CMC_CREATE_UNIT(deque_test, true, {
});
CMC_CREATE_TEST(front[count = 0], {
struct deque *d = d_new(100, d_ftab_val);
struct deque *d = d_new(100, d_fval);
cmc_assert_not_equals(ptr, NULL, d);
@@ -324,7 +324,7 @@ CMC_CREATE_UNIT(deque_test, true, {
});
CMC_CREATE_TEST(front[sum], {
struct deque *d = d_new(100, d_ftab_val);
struct deque *d = d_new(100, d_fval);
cmc_assert_not_equals(ptr, NULL, d);
@@ -353,7 +353,7 @@ CMC_CREATE_UNIT(deque_test, true, {
});
CMC_CREATE_TEST(back[count = 0], {
struct deque *d = d_new(100, d_ftab_val);
struct deque *d = d_new(100, d_fval);
cmc_assert_not_equals(ptr, NULL, d);
@@ -365,7 +365,7 @@ CMC_CREATE_UNIT(deque_test, true, {
});
CMC_CREATE_TEST(back[sum], {
struct deque *d = d_new(100, d_ftab_val);
struct deque *d = d_new(100, d_fval);
cmc_assert_not_equals(ptr, NULL, d);
@@ -394,7 +394,7 @@ CMC_CREATE_UNIT(deque_test, true, {
});
CMC_CREATE_TEST(contains, {
struct deque *d = d_new(100, d_ftab_val);
struct deque *d = d_new(100, d_fval);
cmc_assert_not_equals(ptr, NULL, d);
@@ -416,7 +416,7 @@ CMC_CREATE_UNIT(deque_test, true, {
});
CMC_CREATE_TEST(contains[count = 0], {
struct deque *d = d_new(100, d_ftab_val);
struct deque *d = d_new(100, d_fval);
cmc_assert_not_equals(ptr, NULL, d);
@@ -426,7 +426,7 @@ CMC_CREATE_UNIT(deque_test, true, {
});
CMC_CREATE_TEST(contains[count = 1], {
struct deque *d = d_new(100, d_ftab_val);
struct deque *d = d_new(100, d_fval);
cmc_assert_not_equals(ptr, NULL, d);
@@ -447,7 +447,7 @@ CMC_CREATE_UNIT(deque_test, true, {
});
CMC_CREATE_TEST(empty, {
struct deque *d = d_new(100, d_ftab_val);
struct deque *d = d_new(100, d_fval);
cmc_assert_not_equals(ptr, NULL, d);
@@ -461,7 +461,7 @@ CMC_CREATE_UNIT(deque_test, true, {
});
CMC_CREATE_TEST(full, {
struct deque *d = d_new(100, d_ftab_val);
struct deque *d = d_new(100, d_fval);
cmc_assert_not_equals(ptr, NULL, d);
@@ -476,7 +476,7 @@ CMC_CREATE_UNIT(deque_test, true, {
});
CMC_CREATE_TEST(count, {
struct deque *d = d_new(100, d_ftab_val);
struct deque *d = d_new(100, d_fval);
cmc_assert_not_equals(ptr, NULL, d);
@@ -491,7 +491,7 @@ CMC_CREATE_UNIT(deque_test, true, {
});
CMC_CREATE_TEST(capacity, {
struct deque *d = d_new(100, d_ftab_val);
struct deque *d = d_new(100, d_fval);
cmc_assert_not_equals(ptr, NULL, d);
@@ -501,7 +501,7 @@ CMC_CREATE_UNIT(deque_test, true, {
});
CMC_CREATE_TEST(resize, {
struct deque *d = d_new(100, d_ftab_val);
struct deque *d = d_new(100, d_fval);
cmc_assert_not_equals(ptr, NULL, d);
@@ -521,7 +521,7 @@ CMC_CREATE_UNIT(deque_test, true, {
});
CMC_CREATE_TEST(resize[item preservation], {
struct deque *d = d_new(100, d_ftab_val);
struct deque *d = d_new(100, d_fval);
cmc_assert_not_equals(ptr, NULL, d);
@@ -549,7 +549,7 @@ CMC_CREATE_UNIT(deque_test, true, {
});
CMC_CREATE_TEST(copy_of, {
struct deque *d1 = d_new(100, d_ftab_val);
struct deque *d1 = d_new(100, d_fval);
cmc_assert_not_equals(ptr, NULL, d1);
@@ -586,8 +586,8 @@ CMC_CREATE_UNIT(deque_test, true, {
});
CMC_CREATE_TEST(equals, {
struct deque *d1 = d_new(100, d_ftab_val);
struct deque *d2 = d_new(100, d_ftab_val);
struct deque *d1 = d_new(100, d_fval);
struct deque *d2 = d_new(100, d_fval);
cmc_assert_not_equals(ptr, NULL, d1);
cmc_assert_not_equals(ptr, NULL, d2);
@@ -613,7 +613,7 @@ CMC_CREATE_UNIT(deque_test, true, {
});
CMC_CREATE_TEST(equals[from copy], {
struct deque *d1 = d_new(100, d_ftab_val);
struct deque *d1 = d_new(100, d_fval);
cmc_assert_not_equals(ptr, NULL, d1);
@@ -636,7 +636,7 @@ CMC_CREATE_UNIT(deque_test, true, {
});
CMC_CREATE_TEST(equals[count = 0], {
struct deque *d1 = d_new(100, d_ftab_val);
struct deque *d1 = d_new(100, d_fval);
cmc_assert_not_equals(ptr, NULL, d1);
@@ -651,7 +651,7 @@ CMC_CREATE_UNIT(deque_test, true, {
});
CMC_CREATE_TEST(flags, {
struct deque *d = d_new(100, d_ftab_val);
struct deque *d = d_new(100, d_fval);
cmc_assert_not_equals(ptr, NULL, d);
cmc_assert_equals(int32_t, cmc_flags.OK, d_flag(d));
@@ -736,7 +736,7 @@ CMC_CREATE_UNIT(deque_test, true, {
});
CMC_CREATE_TEST(callbacks, {
struct deque *d = d_new_custom(100, d_ftab_val, NULL, callbacks);
struct deque *d = d_new_custom(100, d_fval, NULL, callbacks);
total_create = 0;
total_read = 0;
+47 -47
View File
@@ -5,16 +5,16 @@
#include "../src/hashmap.c"
struct hashmap_ftab_key *hm_ftab_key =
&(struct hashmap_ftab_key){ .cmp = cmp,
struct hashmap_fkey *hm_fkey =
&(struct hashmap_fkey){ .cmp = cmp,
.cpy = copy,
.str = str,
.free = custom_free,
.hash = hash,
.pri = pri };
struct hashmap_ftab_val *hm_ftab_val =
&(struct hashmap_ftab_val){ .cmp = cmp,
struct hashmap_fval *hm_fval =
&(struct hashmap_fval){ .cmp = cmp,
.cpy = copy,
.str = str,
.free = custom_free,
@@ -23,7 +23,7 @@ struct hashmap_ftab_val *hm_ftab_val =
CMC_CREATE_UNIT(hashmap_test, true, {
CMC_CREATE_TEST(new, {
struct hashmap *map = hm_new(943722, 0.6, hm_ftab_key, hm_ftab_val);
struct hashmap *map = hm_new(943722, 0.6, hm_fkey, hm_fval);
cmc_assert_not_equals(ptr, NULL, map);
cmc_assert_not_equals(ptr, NULL, map->buffer);
@@ -34,20 +34,20 @@ CMC_CREATE_UNIT(hashmap_test, true, {
});
CMC_CREATE_TEST(new[capacity = 0], {
struct hashmap *map = hm_new(0, 0.6, hm_ftab_key, hm_ftab_val);
struct hashmap *map = hm_new(0, 0.6, hm_fkey, hm_fval);
cmc_assert_equals(ptr, NULL, map);
});
CMC_CREATE_TEST(new[capacity = UINT64_MAX], {
struct hashmap *map =
hm_new(UINT64_MAX, 0.99, hm_ftab_key, hm_ftab_val);
hm_new(UINT64_MAX, 0.99, hm_fkey, hm_fval);
cmc_assert_equals(ptr, NULL, map);
});
CMC_CREATE_TEST(clear[count capacity], {
struct hashmap *map = hm_new(100, 0.6, hm_ftab_key, hm_ftab_val);
struct hashmap *map = hm_new(100, 0.6, hm_fkey, hm_fval);
cmc_assert_not_equals(ptr, NULL, map);
@@ -64,7 +64,7 @@ CMC_CREATE_UNIT(hashmap_test, true, {
});
CMC_CREATE_TEST(insert, {
struct hashmap *map = hm_new(100, 0.6, hm_ftab_key, hm_ftab_val);
struct hashmap *map = hm_new(100, 0.6, hm_fkey, hm_fval);
cmc_assert_not_equals(ptr, NULL, map);
@@ -75,7 +75,7 @@ CMC_CREATE_UNIT(hashmap_test, true, {
});
CMC_CREATE_TEST(insert[smallest capacity], {
struct hashmap *map = hm_new(1, 0.99, hm_ftab_key, hm_ftab_val);
struct hashmap *map = hm_new(1, 0.99, hm_fkey, hm_fval);
cmc_assert_not_equals(ptr, NULL, map);
@@ -86,11 +86,11 @@ CMC_CREATE_UNIT(hashmap_test, true, {
});
CMC_CREATE_TEST(insert[element position], {
struct hashmap *map = hm_new(1, 0.99, hm_ftab_key, hm_ftab_val);
struct hashmap *map = hm_new(1, 0.99, hm_fkey, hm_fval);
// Temporary change
// Using the numhash the key is the hash itself
hm_ftab_key->hash = numhash;
hm_fkey->hash = numhash;
cmc_assert_not_equals(ptr, NULL, map);
@@ -104,16 +104,16 @@ CMC_CREATE_UNIT(hashmap_test, true, {
cmc_assert_equals(size_t, capacity - 1, map->buffer[capacity - 1].key);
cmc_assert_equals(size_t, capacity, map->buffer[0].key);
hm_ftab_key->hash = hash;
hm_fkey->hash = hash;
hm_free(map);
});
CMC_CREATE_TEST(insert[distance], {
struct hashmap *map = hm_new(500, 0.6, hm_ftab_key, hm_ftab_val);
struct hashmap *map = hm_new(500, 0.6, hm_fkey, hm_fval);
// Temporary change
hm_ftab_key->hash = hash0;
hm_fkey->hash = hash0;
cmc_assert_not_equals(ptr, NULL, map);
@@ -125,16 +125,16 @@ CMC_CREATE_UNIT(hashmap_test, true, {
for (size_t i = 0; i < 200; i++)
cmc_assert_equals(size_t, i, map->buffer[i].dist);
hm_ftab_key->hash = hash;
hm_fkey->hash = hash;
hm_free(map);
});
CMC_CREATE_TEST(insert[distance wrap], {
struct hashmap *map = hm_new(1, 0.99, hm_ftab_key, hm_ftab_val);
struct hashmap *map = hm_new(1, 0.99, hm_fkey, hm_fval);
// Temporary change
hm_ftab_key->hash = hashcapminus1;
hm_fkey->hash = hashcapminus1;
cmc_assert_not_equals(ptr, NULL, map);
@@ -151,16 +151,16 @@ CMC_CREATE_UNIT(hashmap_test, true, {
cmc_assert_equals(size_t, 0, map->buffer[capacity - 1].dist);
cmc_assert_equals(size_t, 1, map->buffer[0].dist);
hm_ftab_key->hash = hash;
hm_fkey->hash = hash;
hm_free(map);
});
CMC_CREATE_TEST(insert[distances], {
struct hashmap *map = hm_new(1, 0.99, hm_ftab_key, hm_ftab_val);
struct hashmap *map = hm_new(1, 0.99, hm_fkey, hm_fval);
// Temporary change
hm_ftab_key->hash = hashcapminus4;
hm_fkey->hash = hashcapminus4;
cmc_assert_not_equals(ptr, NULL, map);
@@ -172,13 +172,13 @@ CMC_CREATE_UNIT(hashmap_test, true, {
for (size_t i = 0; i < 6; i++)
cmc_assert_equals(size_t, i, hm_impl_get_entry(map, i)->dist);
hm_ftab_key->hash = hash;
hm_fkey->hash = hash;
hm_free(map);
});
CMC_CREATE_TEST(insert[buffer growth and item preservation], {
struct hashmap *map = hm_new(1, 0.99, hm_ftab_key, hm_ftab_val);
struct hashmap *map = hm_new(1, 0.99, hm_fkey, hm_fval);
cmc_assert_not_equals(ptr, NULL, map);
@@ -202,7 +202,7 @@ CMC_CREATE_UNIT(hashmap_test, true, {
});
CMC_CREATE_TEST(update, {
struct hashmap *map = hm_new(100, 0.6, hm_ftab_key, hm_ftab_val);
struct hashmap *map = hm_new(100, 0.6, hm_fkey, hm_fval);
cmc_assert_not_equals(ptr, NULL, map);
@@ -217,7 +217,7 @@ CMC_CREATE_UNIT(hashmap_test, true, {
});
CMC_CREATE_TEST(update[key not found], {
struct hashmap *map = hm_new(100, 0.6, hm_ftab_key, hm_ftab_val);
struct hashmap *map = hm_new(100, 0.6, hm_fkey, hm_fval);
cmc_assert_not_equals(ptr, NULL, map);
@@ -230,7 +230,7 @@ CMC_CREATE_UNIT(hashmap_test, true, {
});
CMC_CREATE_TEST(remove, {
struct hashmap *map = hm_new(100, 0.6, hm_ftab_key, hm_ftab_val);
struct hashmap *map = hm_new(100, 0.6, hm_fkey, hm_fval);
cmc_assert_not_equals(ptr, NULL, map);
@@ -244,7 +244,7 @@ CMC_CREATE_UNIT(hashmap_test, true, {
});
CMC_CREATE_TEST(remove[count = 0], {
struct hashmap *map = hm_new(100, 0.6, hm_ftab_key, hm_ftab_val);
struct hashmap *map = hm_new(100, 0.6, hm_fkey, hm_fval);
cmc_assert_not_equals(ptr, NULL, map);
@@ -255,7 +255,7 @@ CMC_CREATE_UNIT(hashmap_test, true, {
});
CMC_CREATE_TEST(remove[key not found], {
struct hashmap *map = hm_new(100, 0.6, hm_ftab_key, hm_ftab_val);
struct hashmap *map = hm_new(100, 0.6, hm_fkey, hm_fval);
cmc_assert_not_equals(ptr, NULL, map);
@@ -269,7 +269,7 @@ CMC_CREATE_UNIT(hashmap_test, true, {
});
CMC_CREATE_TEST(max, {
struct hashmap *map = hm_new(100, 0.6, hm_ftab_key, hm_ftab_val);
struct hashmap *map = hm_new(100, 0.6, hm_fkey, hm_fval);
cmc_assert_not_equals(ptr, NULL, map);
@@ -287,7 +287,7 @@ CMC_CREATE_UNIT(hashmap_test, true, {
});
CMC_CREATE_TEST(max[count = 0], {
struct hashmap *map = hm_new(100, 0.6, hm_ftab_key, hm_ftab_val);
struct hashmap *map = hm_new(100, 0.6, hm_fkey, hm_fval);
cmc_assert_not_equals(ptr, NULL, map);
@@ -297,7 +297,7 @@ CMC_CREATE_UNIT(hashmap_test, true, {
});
CMC_CREATE_TEST(min, {
struct hashmap *map = hm_new(100, 0.6, hm_ftab_key, hm_ftab_val);
struct hashmap *map = hm_new(100, 0.6, hm_fkey, hm_fval);
cmc_assert_not_equals(ptr, NULL, map);
@@ -315,7 +315,7 @@ CMC_CREATE_UNIT(hashmap_test, true, {
});
CMC_CREATE_TEST(min[count = 0], {
struct hashmap *map = hm_new(100, 0.6, hm_ftab_key, hm_ftab_val);
struct hashmap *map = hm_new(100, 0.6, hm_fkey, hm_fval);
cmc_assert_not_equals(ptr, NULL, map);
@@ -325,7 +325,7 @@ CMC_CREATE_UNIT(hashmap_test, true, {
});
CMC_CREATE_TEST(get, {
struct hashmap *map = hm_new(100, 0.6, hm_ftab_key, hm_ftab_val);
struct hashmap *map = hm_new(100, 0.6, hm_fkey, hm_fval);
cmc_assert_not_equals(ptr, NULL, map);
@@ -337,7 +337,7 @@ CMC_CREATE_UNIT(hashmap_test, true, {
});
CMC_CREATE_TEST(get[count = 0], {
struct hashmap *map = hm_new(100, 0.6, hm_ftab_key, hm_ftab_val);
struct hashmap *map = hm_new(100, 0.6, hm_fkey, hm_fval);
cmc_assert_not_equals(ptr, NULL, map);
@@ -347,7 +347,7 @@ CMC_CREATE_UNIT(hashmap_test, true, {
});
CMC_CREATE_TEST(get_ref, {
struct hashmap *map = hm_new(100, 0.6, hm_ftab_key, hm_ftab_val);
struct hashmap *map = hm_new(100, 0.6, hm_fkey, hm_fval);
cmc_assert_not_equals(ptr, NULL, map);
@@ -362,7 +362,7 @@ CMC_CREATE_UNIT(hashmap_test, true, {
});
CMC_CREATE_TEST(get_ref[count = 0], {
struct hashmap *map = hm_new(100, 0.6, hm_ftab_key, hm_ftab_val);
struct hashmap *map = hm_new(100, 0.6, hm_fkey, hm_fval);
cmc_assert_not_equals(ptr, NULL, map);
@@ -372,7 +372,7 @@ CMC_CREATE_UNIT(hashmap_test, true, {
});
CMC_CREATE_TEST(contains, {
struct hashmap *map = hm_new(100, 0.6, hm_ftab_key, hm_ftab_val);
struct hashmap *map = hm_new(100, 0.6, hm_fkey, hm_fval);
cmc_assert_not_equals(ptr, NULL, map);
@@ -384,7 +384,7 @@ CMC_CREATE_UNIT(hashmap_test, true, {
});
CMC_CREATE_TEST(contains[count = 0], {
struct hashmap *map = hm_new(100, 0.6, hm_ftab_key, hm_ftab_val);
struct hashmap *map = hm_new(100, 0.6, hm_fkey, hm_fval);
cmc_assert_not_equals(ptr, NULL, map);
@@ -394,7 +394,7 @@ CMC_CREATE_UNIT(hashmap_test, true, {
});
CMC_CREATE_TEST(contains[sum], {
struct hashmap *map = hm_new(100, 0.6, hm_ftab_key, hm_ftab_val);
struct hashmap *map = hm_new(100, 0.6, hm_fkey, hm_fval);
cmc_assert_not_equals(ptr, NULL, map);
@@ -412,7 +412,7 @@ CMC_CREATE_UNIT(hashmap_test, true, {
});
CMC_CREATE_TEST(empty, {
struct hashmap *map = hm_new(100, 0.6, hm_ftab_key, hm_ftab_val);
struct hashmap *map = hm_new(100, 0.6, hm_fkey, hm_fval);
cmc_assert_not_equals(ptr, NULL, map);
@@ -427,7 +427,7 @@ CMC_CREATE_UNIT(hashmap_test, true, {
CMC_CREATE_TEST(full, {
struct hashmap *map =
hm_new(cmc_hashtable_primes[0], 0.99999, hm_ftab_key, hm_ftab_val);
hm_new(cmc_hashtable_primes[0], 0.99999, hm_fkey, hm_fval);
cmc_assert_not_equals(ptr, NULL, map);
@@ -448,7 +448,7 @@ CMC_CREATE_UNIT(hashmap_test, true, {
});
CMC_CREATE_TEST(count, {
struct hashmap *map = hm_new(100, 0.6, hm_ftab_key, hm_ftab_val);
struct hashmap *map = hm_new(100, 0.6, hm_fkey, hm_fval);
cmc_assert_not_equals(ptr, NULL, map);
@@ -462,7 +462,7 @@ CMC_CREATE_UNIT(hashmap_test, true, {
});
CMC_CREATE_TEST(capacity, {
struct hashmap *map = hm_new(2500, 0.6, hm_ftab_key, hm_ftab_val);
struct hashmap *map = hm_new(2500, 0.6, hm_fkey, hm_fval);
cmc_assert_not_equals(ptr, NULL, map);
@@ -473,7 +473,7 @@ CMC_CREATE_UNIT(hashmap_test, true, {
});
CMC_CREATE_TEST(capacity[small], {
struct hashmap *map = hm_new(1, 0.99, hm_ftab_key, hm_ftab_val);
struct hashmap *map = hm_new(1, 0.99, hm_fkey, hm_fval);
cmc_assert_not_equals(ptr, NULL, map);
@@ -483,7 +483,7 @@ CMC_CREATE_UNIT(hashmap_test, true, {
});
CMC_CREATE_TEST(load, {
struct hashmap *map = hm_new(1, 0.99, hm_ftab_key, hm_ftab_val);
struct hashmap *map = hm_new(1, 0.99, hm_fkey, hm_fval);
cmc_assert_not_equals(ptr, NULL, map);
@@ -493,7 +493,7 @@ CMC_CREATE_UNIT(hashmap_test, true, {
});
CMC_CREATE_TEST(flags, {
struct hashmap *map = hm_new(100, 0.6, hm_ftab_key, hm_ftab_val);
struct hashmap *map = hm_new(100, 0.6, hm_fkey, hm_fval);
cmc_assert_not_equals(ptr, NULL, map);
cmc_assert_equals(int32_t, cmc_flags.OK, hm_flag(map));
@@ -603,7 +603,7 @@ CMC_CREATE_UNIT(hashmap_test, true, {
CMC_CREATE_TEST(callbacks, {
struct hashmap *map =
hm_new_custom(100, 0.6, hm_ftab_key, hm_ftab_val, NULL, callbacks);
hm_new_custom(100, 0.6, hm_fkey, hm_fval, NULL, callbacks);
cmc_assert_not_equals(ptr, NULL, map);
+39 -39
View File
@@ -5,8 +5,8 @@
#include "../src/hashset.c"
struct hashset_ftab_val *hs_ftab_val =
&(struct hashset_ftab_val){ .cmp = cmp,
struct hashset_fval *hs_fval =
&(struct hashset_fval){ .cmp = cmp,
.cpy = copy,
.str = str,
.free = custom_free,
@@ -15,7 +15,7 @@ struct hashset_ftab_val *hs_ftab_val =
CMC_CREATE_UNIT(hashset_test, true, {
CMC_CREATE_TEST(new, {
struct hashset *set = hs_new(943722, 0.6, hs_ftab_val);
struct hashset *set = hs_new(943722, 0.6, hs_fval);
cmc_assert_not_equals(ptr, NULL, set);
cmc_assert_not_equals(ptr, NULL, set->buffer);
@@ -26,19 +26,19 @@ CMC_CREATE_UNIT(hashset_test, true, {
});
CMC_CREATE_TEST(new[capacity = 0], {
struct hashset *set = hs_new(0, 0.6, hs_ftab_val);
struct hashset *set = hs_new(0, 0.6, hs_fval);
cmc_assert_equals(ptr, NULL, set);
});
CMC_CREATE_TEST(new[capacity = UINT64_MAX], {
struct hashset *set = hs_new(UINT64_MAX, 0.99, hs_ftab_val);
struct hashset *set = hs_new(UINT64_MAX, 0.99, hs_fval);
cmc_assert_equals(ptr, NULL, set);
});
CMC_CREATE_TEST(clear[count capacity], {
struct hashset *set = hs_new(100, 0.6, hs_ftab_val);
struct hashset *set = hs_new(100, 0.6, hs_fval);
cmc_assert_not_equals(ptr, NULL, set);
@@ -55,7 +55,7 @@ CMC_CREATE_UNIT(hashset_test, true, {
});
CMC_CREATE_TEST(insert, {
struct hashset *set = hs_new(100, 0.6, hs_ftab_val);
struct hashset *set = hs_new(100, 0.6, hs_fval);
cmc_assert_not_equals(ptr, NULL, set);
@@ -66,7 +66,7 @@ CMC_CREATE_UNIT(hashset_test, true, {
});
CMC_CREATE_TEST(insert[smallest capacity], {
struct hashset *set = hs_new(1, 0.99, hs_ftab_val);
struct hashset *set = hs_new(1, 0.99, hs_fval);
cmc_assert_not_equals(ptr, NULL, set);
@@ -77,11 +77,11 @@ CMC_CREATE_UNIT(hashset_test, true, {
});
CMC_CREATE_TEST(insert[element position], {
struct hashset *set = hs_new(1, 0.99, hs_ftab_val);
struct hashset *set = hs_new(1, 0.99, hs_fval);
// Temporary change
// Using the numhash the key is the hash itself
hs_ftab_val->hash = numhash;
hs_fval->hash = numhash;
cmc_assert_not_equals(ptr, NULL, set);
@@ -96,16 +96,16 @@ CMC_CREATE_UNIT(hashset_test, true, {
set->buffer[capacity - 1].value);
cmc_assert_equals(size_t, capacity, set->buffer[0].value);
hs_ftab_val->hash = hash;
hs_fval->hash = hash;
hs_free(set);
});
CMC_CREATE_TEST(insert[distance], {
struct hashset *set = hs_new(500, 0.6, hs_ftab_val);
struct hashset *set = hs_new(500, 0.6, hs_fval);
// Temporary change
hs_ftab_val->hash = hash0;
hs_fval->hash = hash0;
cmc_assert_not_equals(ptr, NULL, set);
@@ -117,16 +117,16 @@ CMC_CREATE_UNIT(hashset_test, true, {
for (size_t i = 0; i < 200; i++)
cmc_assert_equals(size_t, i, set->buffer[i].dist);
hs_ftab_val->hash = hash;
hs_fval->hash = hash;
hs_free(set);
});
CMC_CREATE_TEST(insert[distance wrap], {
struct hashset *set = hs_new(1, 0.99, hs_ftab_val);
struct hashset *set = hs_new(1, 0.99, hs_fval);
// Temporary change
hs_ftab_val->hash = hashcapminus1;
hs_fval->hash = hashcapminus1;
cmc_assert_not_equals(ptr, NULL, set);
@@ -143,16 +143,16 @@ CMC_CREATE_UNIT(hashset_test, true, {
cmc_assert_equals(size_t, 0, set->buffer[capacity - 1].dist);
cmc_assert_equals(size_t, 1, set->buffer[0].dist);
hs_ftab_val->hash = hash;
hs_fval->hash = hash;
hs_free(set);
});
CMC_CREATE_TEST(insert[distances], {
struct hashset *set = hs_new(1, 0.99, hs_ftab_val);
struct hashset *set = hs_new(1, 0.99, hs_fval);
// Temporary change
hs_ftab_val->hash = hashcapminus4;
hs_fval->hash = hashcapminus4;
cmc_assert_not_equals(ptr, NULL, set);
@@ -164,13 +164,13 @@ CMC_CREATE_UNIT(hashset_test, true, {
for (size_t i = 0; i < 6; i++)
cmc_assert_equals(size_t, i, hs_impl_get_entry(set, i)->dist);
hs_ftab_val->hash = hash;
hs_fval->hash = hash;
hs_free(set);
});
CMC_CREATE_TEST(insert[buffer growth and item preservation], {
struct hashset *set = hs_new(1, 0.99, hs_ftab_val);
struct hashset *set = hs_new(1, 0.99, hs_fval);
cmc_assert_not_equals(ptr, NULL, set);
@@ -194,7 +194,7 @@ CMC_CREATE_UNIT(hashset_test, true, {
});
CMC_CREATE_TEST(remove, {
struct hashset *set = hs_new(100, 0.6, hs_ftab_val);
struct hashset *set = hs_new(100, 0.6, hs_fval);
cmc_assert_not_equals(ptr, NULL, set);
@@ -208,7 +208,7 @@ CMC_CREATE_UNIT(hashset_test, true, {
});
CMC_CREATE_TEST(remove[count = 0], {
struct hashset *set = hs_new(100, 0.6, hs_ftab_val);
struct hashset *set = hs_new(100, 0.6, hs_fval);
cmc_assert_not_equals(ptr, NULL, set);
@@ -219,7 +219,7 @@ CMC_CREATE_UNIT(hashset_test, true, {
});
CMC_CREATE_TEST(remove[key not found], {
struct hashset *set = hs_new(100, 0.6, hs_ftab_val);
struct hashset *set = hs_new(100, 0.6, hs_fval);
cmc_assert_not_equals(ptr, NULL, set);
@@ -233,7 +233,7 @@ CMC_CREATE_UNIT(hashset_test, true, {
});
CMC_CREATE_TEST(max, {
struct hashset *set = hs_new(100, 0.6, hs_ftab_val);
struct hashset *set = hs_new(100, 0.6, hs_fval);
cmc_assert_not_equals(ptr, NULL, set);
@@ -249,7 +249,7 @@ CMC_CREATE_UNIT(hashset_test, true, {
});
CMC_CREATE_TEST(max[count = 0], {
struct hashset *set = hs_new(100, 0.6, hs_ftab_val);
struct hashset *set = hs_new(100, 0.6, hs_fval);
cmc_assert_not_equals(ptr, NULL, set);
@@ -259,7 +259,7 @@ CMC_CREATE_UNIT(hashset_test, true, {
});
CMC_CREATE_TEST(min, {
struct hashset *set = hs_new(100, 0.6, hs_ftab_val);
struct hashset *set = hs_new(100, 0.6, hs_fval);
cmc_assert_not_equals(ptr, NULL, set);
@@ -275,7 +275,7 @@ CMC_CREATE_UNIT(hashset_test, true, {
});
CMC_CREATE_TEST(min[count = 0], {
struct hashset *set = hs_new(100, 0.6, hs_ftab_val);
struct hashset *set = hs_new(100, 0.6, hs_fval);
cmc_assert_not_equals(ptr, NULL, set);
@@ -285,7 +285,7 @@ CMC_CREATE_UNIT(hashset_test, true, {
});
CMC_CREATE_TEST(contains, {
struct hashset *set = hs_new(100, 0.6, hs_ftab_val);
struct hashset *set = hs_new(100, 0.6, hs_fval);
cmc_assert_not_equals(ptr, NULL, set);
@@ -297,7 +297,7 @@ CMC_CREATE_UNIT(hashset_test, true, {
});
CMC_CREATE_TEST(contains[count = 0], {
struct hashset *set = hs_new(100, 0.6, hs_ftab_val);
struct hashset *set = hs_new(100, 0.6, hs_fval);
cmc_assert_not_equals(ptr, NULL, set);
@@ -307,7 +307,7 @@ CMC_CREATE_UNIT(hashset_test, true, {
});
CMC_CREATE_TEST(contains[sum], {
struct hashset *set = hs_new(100, 0.6, hs_ftab_val);
struct hashset *set = hs_new(100, 0.6, hs_fval);
cmc_assert_not_equals(ptr, NULL, set);
@@ -325,7 +325,7 @@ CMC_CREATE_UNIT(hashset_test, true, {
});
CMC_CREATE_TEST(empty, {
struct hashset *set = hs_new(100, 0.6, hs_ftab_val);
struct hashset *set = hs_new(100, 0.6, hs_fval);
cmc_assert_not_equals(ptr, NULL, set);
@@ -340,7 +340,7 @@ CMC_CREATE_UNIT(hashset_test, true, {
CMC_CREATE_TEST(full, {
struct hashset *set =
hs_new(cmc_hashtable_primes[0], 0.99999, hs_ftab_val);
hs_new(cmc_hashtable_primes[0], 0.99999, hs_fval);
cmc_assert_not_equals(ptr, NULL, set);
@@ -361,7 +361,7 @@ CMC_CREATE_UNIT(hashset_test, true, {
});
CMC_CREATE_TEST(count, {
struct hashset *set = hs_new(100, 0.6, hs_ftab_val);
struct hashset *set = hs_new(100, 0.6, hs_fval);
cmc_assert_not_equals(ptr, NULL, set);
@@ -375,7 +375,7 @@ CMC_CREATE_UNIT(hashset_test, true, {
});
CMC_CREATE_TEST(capacity, {
struct hashset *set = hs_new(2500, 0.6, hs_ftab_val);
struct hashset *set = hs_new(2500, 0.6, hs_fval);
cmc_assert_not_equals(ptr, NULL, set);
@@ -386,7 +386,7 @@ CMC_CREATE_UNIT(hashset_test, true, {
});
CMC_CREATE_TEST(capacity[small], {
struct hashset *set = hs_new(1, 0.99, hs_ftab_val);
struct hashset *set = hs_new(1, 0.99, hs_fval);
cmc_assert_not_equals(ptr, NULL, set);
@@ -396,7 +396,7 @@ CMC_CREATE_UNIT(hashset_test, true, {
});
CMC_CREATE_TEST(load, {
struct hashset *set = hs_new(1, 0.99, hs_ftab_val);
struct hashset *set = hs_new(1, 0.99, hs_fval);
cmc_assert_not_equals(ptr, NULL, set);
@@ -406,7 +406,7 @@ CMC_CREATE_UNIT(hashset_test, true, {
});
CMC_CREATE_TEST(flags, {
struct hashset *set = hs_new(1, 0.99, hs_ftab_val);
struct hashset *set = hs_new(1, 0.99, hs_fval);
cmc_assert_not_equals(ptr, NULL, set);
cmc_assert_equals(int32_t, cmc_flags.OK, hs_flag(set));
@@ -482,7 +482,7 @@ CMC_CREATE_UNIT(hashset_test, true, {
CMC_CREATE_TEST(callbacks, {
struct hashset *set =
hs_new_custom(100, 0.6, hs_ftab_val, NULL, callbacks);
hs_new_custom(100, 0.6, hs_fval, NULL, callbacks);
cmc_assert_not_equals(ptr, NULL, set);
+15 -15
View File
@@ -5,7 +5,7 @@
#include "../src/heap.c"
struct heap_ftab_val *h_ftab_val = &(struct heap_ftab_val){ .cmp = cmp,
struct heap_fval *h_fval = &(struct heap_fval){ .cmp = cmp,
.cpy = copy,
.str = str,
.free = custom_free,
@@ -14,7 +14,7 @@ struct heap_ftab_val *h_ftab_val = &(struct heap_ftab_val){ .cmp = cmp,
CMC_CREATE_UNIT(heap_test, true, {
CMC_CREATE_TEST(new, {
struct heap *h = h_new(1000000, cmc_max_heap, h_ftab_val);
struct heap *h = h_new(1000000, cmc_max_heap, h_fval);
cmc_assert_not_equals(ptr, NULL, h);
cmc_assert_not_equals(ptr, NULL, h->buffer);
@@ -25,19 +25,19 @@ CMC_CREATE_UNIT(heap_test, true, {
});
CMC_CREATE_TEST(new[edge_case capacity = 0], {
struct heap *h = h_new(0, cmc_max_heap, h_ftab_val);
struct heap *h = h_new(0, cmc_max_heap, h_fval);
cmc_assert_equals(ptr, NULL, h);
});
CMC_CREATE_TEST(new[edge_case capacity = UINT64_MAX], {
struct heap *h = h_new(UINT64_MAX, cmc_max_heap, h_ftab_val);
struct heap *h = h_new(UINT64_MAX, cmc_max_heap, h_fval);
cmc_assert_equals(ptr, NULL, h);
});
CMC_CREATE_TEST(clear[count capacity], {
struct heap *h = h_new(100, cmc_max_heap, h_ftab_val);
struct heap *h = h_new(100, cmc_max_heap, h_fval);
cmc_assert_not_equals(ptr, NULL, h);
@@ -55,7 +55,7 @@ CMC_CREATE_UNIT(heap_test, true, {
});
CMC_CREATE_TEST(buffer_growth[edge_case capacity = 1], {
struct heap *h = h_new(1, cmc_max_heap, h_ftab_val);
struct heap *h = h_new(1, cmc_max_heap, h_fval);
cmc_assert_not_equals(ptr, NULL, h);
@@ -68,7 +68,7 @@ CMC_CREATE_UNIT(heap_test, true, {
});
CMC_CREATE_TEST(insert, {
struct heap *h = h_new(100, cmc_max_heap, h_ftab_val);
struct heap *h = h_new(100, cmc_max_heap, h_fval);
cmc_assert_not_equals(ptr, NULL, h);
@@ -78,7 +78,7 @@ CMC_CREATE_UNIT(heap_test, true, {
});
CMC_CREATE_TEST(insert[item preservation], {
struct heap *h = h_new(50, cmc_max_heap, h_ftab_val);
struct heap *h = h_new(50, cmc_max_heap, h_fval);
cmc_assert_not_equals(ptr, NULL, h);
@@ -95,7 +95,7 @@ CMC_CREATE_UNIT(heap_test, true, {
});
CMC_CREATE_TEST(remove, {
struct heap *h = h_new(50, cmc_max_heap, h_ftab_val);
struct heap *h = h_new(50, cmc_max_heap, h_fval);
cmc_assert_not_equals(ptr, NULL, h);
@@ -110,7 +110,7 @@ CMC_CREATE_UNIT(heap_test, true, {
});
CMC_CREATE_TEST(remove[count = 0], {
struct heap *h = h_new(100, cmc_max_heap, h_ftab_val);
struct heap *h = h_new(100, cmc_max_heap, h_fval);
cmc_assert_not_equals(ptr, NULL, h);
@@ -120,7 +120,7 @@ CMC_CREATE_UNIT(heap_test, true, {
});
CMC_CREATE_TEST(remove[sorted], {
struct heap *h = h_new(100, cmc_min_heap, h_ftab_val);
struct heap *h = h_new(100, cmc_min_heap, h_fval);
cmc_assert_not_equals(ptr, NULL, h);
@@ -142,7 +142,7 @@ CMC_CREATE_UNIT(heap_test, true, {
});
CMC_CREATE_TEST(peek, {
struct heap *h = h_new(100, cmc_max_heap, h_ftab_val);
struct heap *h = h_new(100, cmc_max_heap, h_fval);
cmc_assert_not_equals(ptr, NULL, h);
@@ -155,7 +155,7 @@ CMC_CREATE_UNIT(heap_test, true, {
});
CMC_CREATE_TEST(peek[count = 0], {
struct heap *h = h_new(100, cmc_max_heap, h_ftab_val);
struct heap *h = h_new(100, cmc_max_heap, h_fval);
cmc_assert_not_equals(ptr, NULL, h);
@@ -165,7 +165,7 @@ CMC_CREATE_UNIT(heap_test, true, {
});
CMC_CREATE_TEST(flags, {
struct heap *h = h_new(100, cmc_max_heap, h_ftab_val);
struct heap *h = h_new(100, cmc_max_heap, h_fval);
cmc_assert_not_equals(ptr, NULL, h);
cmc_assert_equals(int32_t, cmc_flags.OK, h_flag(h));
@@ -224,7 +224,7 @@ CMC_CREATE_UNIT(heap_test, true, {
CMC_CREATE_TEST(callbacks, {
struct heap *h =
h_new_custom(100, cmc_max_heap, h_ftab_val, NULL, callbacks);
h_new_custom(100, cmc_max_heap, h_fval, NULL, callbacks);
cmc_assert_not_equals(ptr, NULL, h);
+17 -17
View File
@@ -5,8 +5,8 @@
#include "../src/intervalheap.c"
struct intervalheap_ftab_val *ih_ftab_val =
&(struct intervalheap_ftab_val){ .cmp = cmp,
struct intervalheap_fval *ih_fval =
&(struct intervalheap_fval){ .cmp = cmp,
.cpy = copy,
.str = str,
.free = custom_free,
@@ -15,7 +15,7 @@ struct intervalheap_ftab_val *ih_ftab_val =
CMC_CREATE_UNIT(intervalheap_test, true, {
CMC_CREATE_TEST(new, {
struct intervalheap *ih = ih_new(1000000, ih_ftab_val);
struct intervalheap *ih = ih_new(1000000, ih_fval);
cmc_assert_not_equals(ptr, NULL, ih);
cmc_assert_not_equals(ptr, NULL, ih->buffer);
@@ -26,7 +26,7 @@ CMC_CREATE_UNIT(intervalheap_test, true, {
});
CMC_CREATE_TEST(new[capacity = 0], {
struct intervalheap *ih = ih_new(0, ih_ftab_val);
struct intervalheap *ih = ih_new(0, ih_fval);
cmc_assert_equals(ptr, NULL, ih);
@@ -35,28 +35,28 @@ CMC_CREATE_UNIT(intervalheap_test, true, {
});
CMC_CREATE_TEST(new[capacity], {
struct intervalheap *ih = ih_new(1, ih_ftab_val);
struct intervalheap *ih = ih_new(1, ih_fval);
cmc_assert_not_equals(ptr, NULL, ih);
cmc_assert_equals(size_t, 1, ih_capacity(ih));
ih_free(ih);
ih = ih_new(2, ih_ftab_val);
ih = ih_new(2, ih_fval);
cmc_assert_not_equals(ptr, NULL, ih);
cmc_assert_equals(size_t, 1, ih_capacity(ih));
ih_free(ih);
ih = ih_new(3, ih_ftab_val);
ih = ih_new(3, ih_fval);
cmc_assert_not_equals(ptr, NULL, ih);
cmc_assert_equals(size_t, 2, ih_capacity(ih));
ih_free(ih);
ih = ih_new(4, ih_ftab_val);
ih = ih_new(4, ih_fval);
cmc_assert_not_equals(ptr, NULL, ih);
cmc_assert_equals(size_t, 2, ih_capacity(ih));
@@ -65,7 +65,7 @@ CMC_CREATE_UNIT(intervalheap_test, true, {
});
CMC_CREATE_TEST(new[capacity = UINT64_MAX], {
struct intervalheap *ih = ih_new(UINT64_MAX, ih_ftab_val);
struct intervalheap *ih = ih_new(UINT64_MAX, ih_fval);
cmc_assert_equals(ptr, NULL, ih);
@@ -74,7 +74,7 @@ CMC_CREATE_UNIT(intervalheap_test, true, {
});
CMC_CREATE_TEST(clear[count capacity], {
struct intervalheap *ih = ih_new(100, ih_ftab_val);
struct intervalheap *ih = ih_new(100, ih_fval);
cmc_assert_not_equals(ptr, NULL, ih);
@@ -92,7 +92,7 @@ CMC_CREATE_UNIT(intervalheap_test, true, {
});
CMC_CREATE_TEST(buffer_growth[capacity = 1], {
struct intervalheap *ih = ih_new(1, ih_ftab_val);
struct intervalheap *ih = ih_new(1, ih_fval);
cmc_assert_not_equals(ptr, NULL, ih);
@@ -106,7 +106,7 @@ CMC_CREATE_UNIT(intervalheap_test, true, {
});
CMC_CREATE_TEST(insert[count], {
struct intervalheap *ih = ih_new(100, ih_ftab_val);
struct intervalheap *ih = ih_new(100, ih_fval);
cmc_assert_not_equals(ptr, NULL, ih);
@@ -119,7 +119,7 @@ CMC_CREATE_UNIT(intervalheap_test, true, {
});
CMC_CREATE_TEST(insert[max], {
struct intervalheap *ih = ih_new(1, ih_ftab_val);
struct intervalheap *ih = ih_new(1, ih_fval);
cmc_assert(ih_insert(ih, 0));
cmc_assert(ih_insert(ih, 1));
@@ -131,7 +131,7 @@ CMC_CREATE_UNIT(intervalheap_test, true, {
});
CMC_CREATE_TEST(insert[min], {
struct intervalheap *ih = ih_new(1, ih_ftab_val);
struct intervalheap *ih = ih_new(1, ih_fval);
cmc_assert(ih_insert(ih, 0));
cmc_assert(ih_insert(ih, 1));
@@ -143,7 +143,7 @@ CMC_CREATE_UNIT(intervalheap_test, true, {
});
CMC_CREATE_TEST(insert[remove_max remove_min], {
struct intervalheap *ih = ih_new(100, ih_ftab_val);
struct intervalheap *ih = ih_new(100, ih_fval);
cmc_assert_not_equals(ptr, NULL, ih);
@@ -168,7 +168,7 @@ CMC_CREATE_UNIT(intervalheap_test, true, {
});
CMC_CREATE_TEST(flags, {
struct intervalheap *ih = ih_new(100, ih_ftab_val);
struct intervalheap *ih = ih_new(100, ih_fval);
cmc_assert_not_equals(ptr, NULL, ih);
cmc_assert_equals(int32_t, cmc_flags.OK, ih_flag(ih));
@@ -261,7 +261,7 @@ CMC_CREATE_UNIT(intervalheap_test, true, {
CMC_CREATE_TEST(callbacks, {
struct intervalheap *ih =
ih_new_custom(100, ih_ftab_val, NULL, callbacks);
ih_new_custom(100, ih_fval, NULL, callbacks);
cmc_assert_not_equals(ptr, NULL, ih);
+9 -9
View File
@@ -5,8 +5,8 @@
#include "../src/linkedlist.c"
struct linkedlist_ftab_val *ll_ftab_val =
&(struct linkedlist_ftab_val){ .cmp = cmp,
struct linkedlist_fval *ll_fval =
&(struct linkedlist_fval){ .cmp = cmp,
.cpy = copy,
.str = str,
.free = custom_free,
@@ -15,7 +15,7 @@ struct linkedlist_ftab_val *ll_ftab_val =
CMC_CREATE_UNIT(linkedlist_test, true, {
CMC_CREATE_TEST(new, {
struct linkedlist *ll = ll_new(ll_ftab_val);
struct linkedlist *ll = ll_new(ll_fval);
cmc_assert_not_equals(ptr, NULL, ll);
cmc_assert_equals(size_t, 0, ll_count(ll));
@@ -26,7 +26,7 @@ CMC_CREATE_UNIT(linkedlist_test, true, {
});
CMC_CREATE_TEST(clear[count capacity], {
struct linkedlist *ll = ll_new(ll_ftab_val);
struct linkedlist *ll = ll_new(ll_fval);
cmc_assert_not_equals(ptr, NULL, ll);
@@ -43,7 +43,7 @@ CMC_CREATE_UNIT(linkedlist_test, true, {
});
CMC_CREATE_TEST(clear[count = 0], {
struct linkedlist *ll = ll_new(ll_ftab_val);
struct linkedlist *ll = ll_new(ll_fval);
cmc_assert_not_equals(ptr, NULL, ll);
@@ -55,7 +55,7 @@ CMC_CREATE_UNIT(linkedlist_test, true, {
});
CMC_CREATE_TEST(push_front[count], {
struct linkedlist *ll = ll_new(ll_ftab_val);
struct linkedlist *ll = ll_new(ll_fval);
cmc_assert_not_equals(ptr, NULL, ll);
@@ -69,7 +69,7 @@ CMC_CREATE_UNIT(linkedlist_test, true, {
});
CMC_CREATE_TEST(push_front[item preservation], {
struct linkedlist *ll = ll_new(ll_ftab_val);
struct linkedlist *ll = ll_new(ll_fval);
cmc_assert_not_equals(ptr, NULL, ll);
@@ -83,7 +83,7 @@ CMC_CREATE_UNIT(linkedlist_test, true, {
});
CMC_CREATE_TEST(flags, {
struct linkedlist *ll = ll_new(ll_ftab_val);
struct linkedlist *ll = ll_new(ll_fval);
cmc_assert_not_equals(ptr, NULL, ll);
cmc_assert_equals(int32_t, cmc_flags.OK, ll_flag(ll));
@@ -256,7 +256,7 @@ CMC_CREATE_UNIT(linkedlist_test, true, {
});
CMC_CREATE_TEST(callbacks, {
struct linkedlist *ll = ll_new_custom(ll_ftab_val, NULL, callbacks);
struct linkedlist *ll = ll_new_custom(ll_fval, NULL, callbacks);
cmc_assert_not_equals(ptr, NULL, ll);
+27 -27
View File
@@ -5,7 +5,7 @@
#include "../src/list.c"
struct list_ftab_val *l_ftab_val = &(struct list_ftab_val){ .cmp = cmp,
struct list_fval *l_fval = &(struct list_fval){ .cmp = cmp,
.cpy = copy,
.str = str,
.free = custom_free,
@@ -14,7 +14,7 @@ struct list_ftab_val *l_ftab_val = &(struct list_ftab_val){ .cmp = cmp,
CMC_CREATE_UNIT(list_test, true, {
CMC_CREATE_TEST(new, {
struct list *l = l_new(1000000, l_ftab_val);
struct list *l = l_new(1000000, l_fval);
cmc_assert_not_equals(ptr, NULL, l);
cmc_assert_not_equals(ptr, NULL, l->buffer);
@@ -25,19 +25,19 @@ CMC_CREATE_UNIT(list_test, true, {
});
CMC_CREATE_TEST(new[capacity = 0], {
struct list *l = l_new(0, l_ftab_val);
struct list *l = l_new(0, l_fval);
cmc_assert_equals(ptr, NULL, l);
});
CMC_CREATE_TEST(new[capacity = UINT64_MAX], {
struct list *l = l_new(UINT64_MAX, l_ftab_val);
struct list *l = l_new(UINT64_MAX, l_fval);
cmc_assert_equals(ptr, NULL, l);
});
CMC_CREATE_TEST(clear[count capacity], {
struct list *l = l_new(100, l_ftab_val);
struct list *l = l_new(100, l_fval);
cmc_assert_not_equals(ptr, NULL, l);
@@ -55,7 +55,7 @@ CMC_CREATE_UNIT(list_test, true, {
});
CMC_CREATE_TEST(buffer_growth[capacity = 1], {
struct list *l = l_new(1, l_ftab_val);
struct list *l = l_new(1, l_fval);
cmc_assert_not_equals(ptr, NULL, l);
@@ -71,7 +71,7 @@ CMC_CREATE_UNIT(list_test, true, {
});
CMC_CREATE_TEST(push_front[count], {
struct list *l = l_new(100, l_ftab_val);
struct list *l = l_new(100, l_fval);
cmc_assert_not_equals(ptr, NULL, l);
@@ -84,7 +84,7 @@ CMC_CREATE_UNIT(list_test, true, {
});
CMC_CREATE_TEST(push_front[capacity], {
struct list *l = l_new(100, l_ftab_val);
struct list *l = l_new(100, l_fval);
cmc_assert_not_equals(ptr, NULL, l);
@@ -97,7 +97,7 @@ CMC_CREATE_UNIT(list_test, true, {
});
CMC_CREATE_TEST(push_front[item preservation], {
struct list *l = l_new(100, l_ftab_val);
struct list *l = l_new(100, l_fval);
cmc_assert_not_equals(ptr, NULL, l);
@@ -111,7 +111,7 @@ CMC_CREATE_UNIT(list_test, true, {
});
CMC_CREATE_TEST(push_at[count], {
struct list *l = l_new(100, l_ftab_val);
struct list *l = l_new(100, l_fval);
cmc_assert_not_equals(ptr, NULL, l);
@@ -127,7 +127,7 @@ CMC_CREATE_UNIT(list_test, true, {
});
CMC_CREATE_TEST(push_at[capacity], {
struct list *l = l_new(100, l_ftab_val);
struct list *l = l_new(100, l_fval);
cmc_assert_not_equals(ptr, NULL, l);
@@ -143,7 +143,7 @@ CMC_CREATE_UNIT(list_test, true, {
});
CMC_CREATE_TEST(push_at[item preservation], {
struct list *l = l_new(100, l_ftab_val);
struct list *l = l_new(100, l_fval);
cmc_assert_not_equals(ptr, NULL, l);
@@ -160,7 +160,7 @@ CMC_CREATE_UNIT(list_test, true, {
});
CMC_CREATE_TEST(push_back[count], {
struct list *l = l_new(100, l_ftab_val);
struct list *l = l_new(100, l_fval);
cmc_assert_not_equals(ptr, NULL, l);
@@ -173,7 +173,7 @@ CMC_CREATE_UNIT(list_test, true, {
});
CMC_CREATE_TEST(push_back[capacity], {
struct list *l = l_new(100, l_ftab_val);
struct list *l = l_new(100, l_fval);
cmc_assert_not_equals(ptr, NULL, l);
@@ -186,7 +186,7 @@ CMC_CREATE_UNIT(list_test, true, {
});
CMC_CREATE_TEST(push_back[item preservation], {
struct list *l = l_new(100, l_ftab_val);
struct list *l = l_new(100, l_fval);
cmc_assert_not_equals(ptr, NULL, l);
@@ -200,7 +200,7 @@ CMC_CREATE_UNIT(list_test, true, {
});
CMC_CREATE_TEST(pop_front[count], {
struct list *l = l_new(100, l_ftab_val);
struct list *l = l_new(100, l_fval);
cmc_assert_not_equals(ptr, NULL, l);
@@ -213,7 +213,7 @@ CMC_CREATE_UNIT(list_test, true, {
});
CMC_CREATE_TEST(pop_front[item preservation], {
struct list *l = l_new(100, l_ftab_val);
struct list *l = l_new(100, l_fval);
cmc_assert_not_equals(ptr, NULL, l);
@@ -229,7 +229,7 @@ CMC_CREATE_UNIT(list_test, true, {
});
CMC_CREATE_TEST(pop_front[count = 0], {
struct list *l = l_new(100, l_ftab_val);
struct list *l = l_new(100, l_fval);
cmc_assert_not_equals(ptr, NULL, l);
cmc_assert(!l_pop_front(l));
@@ -238,7 +238,7 @@ CMC_CREATE_UNIT(list_test, true, {
});
CMC_CREATE_TEST(pop_front[count = 1], {
struct list *l = l_new(100, l_ftab_val);
struct list *l = l_new(100, l_fval);
cmc_assert_not_equals(ptr, NULL, l);
cmc_assert(l_push_back(l, 10));
@@ -248,7 +248,7 @@ CMC_CREATE_UNIT(list_test, true, {
});
CMC_CREATE_TEST(pop_front[buffer_clear], {
struct list *l = l_new(100, l_ftab_val);
struct list *l = l_new(100, l_fval);
cmc_assert_not_equals(ptr, NULL, l);
cmc_assert(l_push_back(l, 1));
@@ -262,7 +262,7 @@ CMC_CREATE_UNIT(list_test, true, {
});
CMC_CREATE_TEST(pop_at[count = 0], {
struct list *l = l_new(100, l_ftab_val);
struct list *l = l_new(100, l_fval);
cmc_assert_not_equals(ptr, NULL, l);
cmc_assert(!l_pop_at(l, 1));
@@ -271,7 +271,7 @@ CMC_CREATE_UNIT(list_test, true, {
});
CMC_CREATE_TEST(pop_at[count = 1], {
struct list *l = l_new(100, l_ftab_val);
struct list *l = l_new(100, l_fval);
cmc_assert_not_equals(ptr, NULL, l);
cmc_assert(l_push_back(l, 1));
@@ -283,7 +283,7 @@ CMC_CREATE_UNIT(list_test, true, {
});
CMC_CREATE_TEST(pop_at[buffer_clear], {
struct list *l = l_new(100, l_ftab_val);
struct list *l = l_new(100, l_fval);
cmc_assert_not_equals(ptr, NULL, l);
cmc_assert(l_push_back(l, 1));
@@ -295,7 +295,7 @@ CMC_CREATE_UNIT(list_test, true, {
});
CMC_CREATE_TEST(pop_back[count = 0], {
struct list *l = l_new(100, l_ftab_val);
struct list *l = l_new(100, l_fval);
cmc_assert_not_equals(ptr, NULL, l);
cmc_assert(!l_pop_back(l));
@@ -304,7 +304,7 @@ CMC_CREATE_UNIT(list_test, true, {
});
CMC_CREATE_TEST(pop_back[count = 1], {
struct list *l = l_new(100, l_ftab_val);
struct list *l = l_new(100, l_fval);
cmc_assert_not_equals(ptr, NULL, l);
cmc_assert(l_push_back(l, 10));
@@ -314,7 +314,7 @@ CMC_CREATE_UNIT(list_test, true, {
});
CMC_CREATE_TEST(flags, {
struct list *l = l_new(100, l_ftab_val);
struct list *l = l_new(100, l_fval);
cmc_assert_not_equals(ptr, NULL, l);
cmc_assert_equals(int32_t, cmc_flags.OK, l_flag(l));
@@ -496,7 +496,7 @@ CMC_CREATE_UNIT(list_test, true, {
});
CMC_CREATE_TEST(callbacks, {
struct list *l = l_new_custom(100, l_ftab_val, NULL, callbacks);
struct list *l = l_new_custom(100, l_fval, NULL, callbacks);
cmc_assert_not_equals(ptr, NULL, l);
+16 -16
View File
@@ -5,16 +5,16 @@
#include "../src/multimap.c"
struct multimap_ftab_key *mm_ftab_key =
&(struct multimap_ftab_key){ .cmp = cmp,
struct multimap_fkey *mm_fkey =
&(struct multimap_fkey){ .cmp = cmp,
.cpy = copy,
.str = str,
.free = custom_free,
.hash = hash,
.pri = pri };
struct multimap_ftab_val *mm_ftab_val =
&(struct multimap_ftab_val){ .cmp = cmp,
struct multimap_fval *mm_fval =
&(struct multimap_fval){ .cmp = cmp,
.cpy = copy,
.str = str,
.free = custom_free,
@@ -23,7 +23,7 @@ struct multimap_ftab_val *mm_ftab_val =
CMC_CREATE_UNIT(multimap_test, true, {
CMC_CREATE_TEST(new, {
struct multimap *map = mm_new(943722, 0.8, mm_ftab_key, mm_ftab_val);
struct multimap *map = mm_new(943722, 0.8, mm_fkey, mm_fval);
cmc_assert_not_equals(ptr, NULL, map);
cmc_assert_not_equals(ptr, NULL, map->buffer);
@@ -34,20 +34,20 @@ CMC_CREATE_UNIT(multimap_test, true, {
});
CMC_CREATE_TEST(new[capacity = 0], {
struct multimap *map = mm_new(0, 0.8, mm_ftab_key, mm_ftab_val);
struct multimap *map = mm_new(0, 0.8, mm_fkey, mm_fval);
cmc_assert_equals(ptr, NULL, map);
});
CMC_CREATE_TEST(new[capacity = UINT64_MAX], {
struct multimap *map =
mm_new(UINT64_MAX, 0.99, mm_ftab_key, mm_ftab_val);
mm_new(UINT64_MAX, 0.99, mm_fkey, mm_fval);
cmc_assert_equals(ptr, NULL, map);
});
CMC_CREATE_TEST(clear[count capacity], {
struct multimap *map = mm_new(100, 0.8, mm_ftab_key, mm_ftab_val);
struct multimap *map = mm_new(100, 0.8, mm_fkey, mm_fval);
cmc_assert_not_equals(ptr, NULL, map);
@@ -64,7 +64,7 @@ CMC_CREATE_UNIT(multimap_test, true, {
});
CMC_CREATE_TEST(insert[count], {
struct multimap *map = mm_new(100, 0.8, mm_ftab_key, mm_ftab_val);
struct multimap *map = mm_new(100, 0.8, mm_fkey, mm_fval);
cmc_assert_not_equals(ptr, NULL, map);
@@ -77,7 +77,7 @@ CMC_CREATE_UNIT(multimap_test, true, {
});
CMC_CREATE_TEST(remove[count], {
struct multimap *map = mm_new(100, 0.8, mm_ftab_key, mm_ftab_val);
struct multimap *map = mm_new(100, 0.8, mm_fkey, mm_fval);
cmc_assert_not_equals(ptr, NULL, map);
@@ -95,7 +95,7 @@ CMC_CREATE_UNIT(multimap_test, true, {
});
CMC_CREATE_TEST(remove[count = 0], {
struct multimap *map = mm_new(100, 0.8, mm_ftab_key, mm_ftab_val);
struct multimap *map = mm_new(100, 0.8, mm_fkey, mm_fval);
cmc_assert_not_equals(ptr, NULL, map);
@@ -107,7 +107,7 @@ CMC_CREATE_UNIT(multimap_test, true, {
});
CMC_CREATE_TEST(remove[count = 1], {
struct multimap *map = mm_new(100, 0.8, mm_ftab_key, mm_ftab_val);
struct multimap *map = mm_new(100, 0.8, mm_fkey, mm_fval);
cmc_assert_not_equals(ptr, NULL, map);
@@ -120,7 +120,7 @@ CMC_CREATE_UNIT(multimap_test, true, {
});
CMC_CREATE_TEST(get[key ordering], {
struct multimap *map = mm_new(100, 0.8, mm_ftab_key, mm_ftab_val);
struct multimap *map = mm_new(100, 0.8, mm_fkey, mm_fval);
cmc_assert_not_equals(ptr, NULL, map);
@@ -136,7 +136,7 @@ CMC_CREATE_UNIT(multimap_test, true, {
});
CMC_CREATE_TEST(key_count, {
struct multimap *map = mm_new(50, 0.8, mm_ftab_key, mm_ftab_val);
struct multimap *map = mm_new(50, 0.8, mm_fkey, mm_fval);
cmc_assert_not_equals(ptr, NULL, map);
@@ -152,7 +152,7 @@ CMC_CREATE_UNIT(multimap_test, true, {
});
CMC_CREATE_TEST(flags, {
struct multimap *map = mm_new(100, 0.8, mm_ftab_key, mm_ftab_val);
struct multimap *map = mm_new(100, 0.8, mm_fkey, mm_fval);
cmc_assert_not_equals(ptr, NULL, map);
cmc_assert_equals(int32_t, cmc_flags.OK, mm_flag(map));
@@ -273,7 +273,7 @@ CMC_CREATE_UNIT(multimap_test, true, {
CMC_CREATE_TEST(callbacks, {
struct multimap *map =
mm_new_custom(100, 0.8, mm_ftab_key, mm_ftab_val, NULL, callbacks);
mm_new_custom(100, 0.8, mm_fkey, mm_fval, NULL, callbacks);
cmc_assert_not_equals(ptr, NULL, map);
+12 -12
View File
@@ -5,8 +5,8 @@
#include "../src/multiset.c"
struct multiset_ftab_val *ms_ftab_val =
&(struct multiset_ftab_val){ .cmp = cmp,
struct multiset_fval *ms_fval =
&(struct multiset_fval){ .cmp = cmp,
.cpy = copy,
.str = str,
.free = custom_free,
@@ -15,7 +15,7 @@ struct multiset_ftab_val *ms_ftab_val =
CMC_CREATE_UNIT(multiset_test, true, {
CMC_CREATE_TEST(new, {
struct multiset *set = ms_new(943722, 0.6, ms_ftab_val);
struct multiset *set = ms_new(943722, 0.6, ms_fval);
cmc_assert_not_equals(ptr, NULL, set);
cmc_assert_not_equals(ptr, NULL, set->buffer);
@@ -27,19 +27,19 @@ CMC_CREATE_UNIT(multiset_test, true, {
});
CMC_CREATE_TEST(new[capacity = 0], {
struct multiset *set = ms_new(0, 0.6, ms_ftab_val);
struct multiset *set = ms_new(0, 0.6, ms_fval);
cmc_assert_equals(ptr, NULL, set);
});
CMC_CREATE_TEST(new[capacity = UINT64_MAX], {
struct multiset *set = ms_new(UINT64_MAX, 0.99, ms_ftab_val);
struct multiset *set = ms_new(UINT64_MAX, 0.99, ms_fval);
cmc_assert_equals(ptr, NULL, set);
});
CMC_CREATE_TEST(clear[count capacity], {
struct multiset *set = ms_new(100, 0.6, ms_ftab_val);
struct multiset *set = ms_new(100, 0.6, ms_fval);
cmc_assert_not_equals(ptr, NULL, set);
@@ -56,7 +56,7 @@ CMC_CREATE_UNIT(multiset_test, true, {
});
CMC_CREATE_TEST(insert[count cardinality multiplicity], {
struct multiset *set = ms_new(100, 0.6, ms_ftab_val);
struct multiset *set = ms_new(100, 0.6, ms_fval);
cmc_assert_not_equals(ptr, NULL, set);
@@ -77,7 +77,7 @@ CMC_CREATE_UNIT(multiset_test, true, {
});
CMC_CREATE_TEST(remove[count cardinality multiplicity], {
struct multiset *set = ms_new(100, 0.6, ms_ftab_val);
struct multiset *set = ms_new(100, 0.6, ms_fval);
cmc_assert_not_equals(ptr, NULL, set);
@@ -110,7 +110,7 @@ CMC_CREATE_UNIT(multiset_test, true, {
});
CMC_CREATE_TEST(remove_all[count cardinality multiplicity], {
struct multiset *set = ms_new(100, 0.6, ms_ftab_val);
struct multiset *set = ms_new(100, 0.6, ms_fval);
cmc_assert_not_equals(ptr, NULL, set);
@@ -142,7 +142,7 @@ CMC_CREATE_UNIT(multiset_test, true, {
});
CMC_CREATE_TEST(multiplicity, {
struct multiset *set = ms_new(50, 0.6, ms_ftab_val);
struct multiset *set = ms_new(50, 0.6, ms_fval);
cmc_assert_not_equals(ptr, NULL, set);
@@ -159,7 +159,7 @@ CMC_CREATE_UNIT(multiset_test, true, {
});
CMC_CREATE_TEST(flags, {
struct multiset *set = ms_new(100, 0.6, ms_ftab_val);
struct multiset *set = ms_new(100, 0.6, ms_fval);
cmc_assert_not_equals(ptr, NULL, set);
cmc_assert_equals(int32_t, cmc_flags.OK, ms_flag(set));
@@ -263,7 +263,7 @@ CMC_CREATE_UNIT(multiset_test, true, {
CMC_CREATE_TEST(callbacks, {
struct multiset *set =
ms_new_custom(100, 0.8, ms_ftab_val, NULL, callbacks);
ms_new_custom(100, 0.8, ms_fval, NULL, callbacks);
cmc_assert_not_equals(ptr, NULL, set);
+30 -30
View File
@@ -5,8 +5,8 @@
#include "../src/queue.c"
struct queue_ftab_val *q_ftab_val =
&(struct queue_ftab_val){ .cmp = cmp,
struct queue_fval *q_fval =
&(struct queue_fval){ .cmp = cmp,
.cpy = copy,
.str = str,
.free = custom_free,
@@ -15,7 +15,7 @@ struct queue_ftab_val *q_ftab_val =
CMC_CREATE_UNIT(queue_test, true, {
CMC_CREATE_TEST(new, {
struct queue *q = q_new(1000000, q_ftab_val);
struct queue *q = q_new(1000000, q_fval);
cmc_assert_not_equals(ptr, NULL, q);
cmc_assert_not_equals(ptr, NULL, q->buffer);
@@ -27,19 +27,19 @@ CMC_CREATE_UNIT(queue_test, true, {
});
CMC_CREATE_TEST(new[capacity = 0], {
struct queue *q = q_new(0, q_ftab_val);
struct queue *q = q_new(0, q_fval);
cmc_assert_equals(ptr, NULL, q);
});
CMC_CREATE_TEST(new[capacity = UINT64_MAX], {
struct queue *q = q_new(UINT64_MAX, q_ftab_val);
struct queue *q = q_new(UINT64_MAX, q_fval);
cmc_assert_equals(ptr, NULL, q);
});
CMC_CREATE_TEST(clear[count capacity], {
struct queue *q = q_new(100, q_ftab_val);
struct queue *q = q_new(100, q_fval);
cmc_assert_not_equals(ptr, NULL, q);
@@ -57,7 +57,7 @@ CMC_CREATE_UNIT(queue_test, true, {
});
CMC_CREATE_TEST(buffer_growth[capacity = 1], {
struct queue *q = q_new(1, q_ftab_val);
struct queue *q = q_new(1, q_fval);
cmc_assert_not_equals(ptr, NULL, q);
@@ -70,7 +70,7 @@ CMC_CREATE_UNIT(queue_test, true, {
});
CMC_CREATE_TEST(buffer_growth[item preservation], {
struct queue *q = q_new(100, q_ftab_val);
struct queue *q = q_new(100, q_fval);
cmc_assert_not_equals(ptr, NULL, q);
@@ -91,7 +91,7 @@ CMC_CREATE_UNIT(queue_test, true, {
});
CMC_CREATE_TEST(enqueue[count capacity], {
struct queue *q = q_new(100, q_ftab_val);
struct queue *q = q_new(100, q_fval);
cmc_assert_not_equals(ptr, NULL, q);
@@ -105,7 +105,7 @@ CMC_CREATE_UNIT(queue_test, true, {
});
CMC_CREATE_TEST(enqueue[item preservation], {
struct queue *q = q_new(100, q_ftab_val);
struct queue *q = q_new(100, q_fval);
cmc_assert_not_equals(ptr, NULL, q);
@@ -126,7 +126,7 @@ CMC_CREATE_UNIT(queue_test, true, {
});
CMC_CREATE_TEST(dequeue[count capacity], {
struct queue *q = q_new(100, q_ftab_val);
struct queue *q = q_new(100, q_fval);
cmc_assert_not_equals(ptr, NULL, q);
@@ -144,7 +144,7 @@ CMC_CREATE_UNIT(queue_test, true, {
});
CMC_CREATE_TEST(dequeue[item preservation], {
struct queue *q = q_new(100, q_ftab_val);
struct queue *q = q_new(100, q_fval);
cmc_assert_not_equals(ptr, NULL, q);
@@ -168,7 +168,7 @@ CMC_CREATE_UNIT(queue_test, true, {
});
CMC_CREATE_TEST(peek[count = 0], {
struct queue *q = q_new(100, q_ftab_val);
struct queue *q = q_new(100, q_fval);
cmc_assert_not_equals(ptr, NULL, q);
@@ -180,7 +180,7 @@ CMC_CREATE_UNIT(queue_test, true, {
});
CMC_CREATE_TEST(peek[sum], {
struct queue *q = q_new(100, q_ftab_val);
struct queue *q = q_new(100, q_fval);
cmc_assert_not_equals(ptr, NULL, q);
@@ -204,7 +204,7 @@ CMC_CREATE_UNIT(queue_test, true, {
});
CMC_CREATE_TEST(contains, {
struct queue *q = q_new(100, q_ftab_val);
struct queue *q = q_new(100, q_fval);
cmc_assert_not_equals(ptr, NULL, q);
@@ -223,7 +223,7 @@ CMC_CREATE_UNIT(queue_test, true, {
});
CMC_CREATE_TEST(contains[count = 0], {
struct queue *q = q_new(100, q_ftab_val);
struct queue *q = q_new(100, q_fval);
cmc_assert_not_equals(ptr, NULL, q);
@@ -233,7 +233,7 @@ CMC_CREATE_UNIT(queue_test, true, {
});
CMC_CREATE_TEST(contains[count = 1], {
struct queue *q = q_new(100, q_ftab_val);
struct queue *q = q_new(100, q_fval);
cmc_assert_not_equals(ptr, NULL, q);
@@ -248,7 +248,7 @@ CMC_CREATE_UNIT(queue_test, true, {
});
CMC_CREATE_TEST(empty, {
struct queue *q = q_new(100, q_ftab_val);
struct queue *q = q_new(100, q_fval);
cmc_assert_not_equals(ptr, NULL, q);
@@ -262,7 +262,7 @@ CMC_CREATE_UNIT(queue_test, true, {
});
CMC_CREATE_TEST(full, {
struct queue *q = q_new(100, q_ftab_val);
struct queue *q = q_new(100, q_fval);
cmc_assert_not_equals(ptr, NULL, q);
@@ -277,7 +277,7 @@ CMC_CREATE_UNIT(queue_test, true, {
});
CMC_CREATE_TEST(count, {
struct queue *q = q_new(100, q_ftab_val);
struct queue *q = q_new(100, q_fval);
cmc_assert_not_equals(ptr, NULL, q);
@@ -292,7 +292,7 @@ CMC_CREATE_UNIT(queue_test, true, {
});
CMC_CREATE_TEST(capacity, {
struct queue *q = q_new(100, q_ftab_val);
struct queue *q = q_new(100, q_fval);
cmc_assert_not_equals(ptr, NULL, q);
@@ -302,7 +302,7 @@ CMC_CREATE_UNIT(queue_test, true, {
});
CMC_CREATE_TEST(resize, {
struct queue *q = q_new(100, q_ftab_val);
struct queue *q = q_new(100, q_fval);
cmc_assert_not_equals(ptr, NULL, q);
@@ -317,7 +317,7 @@ CMC_CREATE_UNIT(queue_test, true, {
});
CMC_CREATE_TEST(resize[item preservation], {
struct queue *q = q_new(100, q_ftab_val);
struct queue *q = q_new(100, q_fval);
cmc_assert_not_equals(ptr, NULL, q);
@@ -340,7 +340,7 @@ CMC_CREATE_UNIT(queue_test, true, {
});
CMC_CREATE_TEST(copy_of, {
struct queue *d1 = q_new(100, q_ftab_val);
struct queue *d1 = q_new(100, q_fval);
cmc_assert_not_equals(ptr, NULL, d1);
@@ -365,8 +365,8 @@ CMC_CREATE_UNIT(queue_test, true, {
});
CMC_CREATE_TEST(equals, {
struct queue *d1 = q_new(100, q_ftab_val);
struct queue *d2 = q_new(100, q_ftab_val);
struct queue *d1 = q_new(100, q_fval);
struct queue *d2 = q_new(100, q_fval);
cmc_assert_not_equals(ptr, NULL, d1);
cmc_assert_not_equals(ptr, NULL, d2);
@@ -384,7 +384,7 @@ CMC_CREATE_UNIT(queue_test, true, {
});
CMC_CREATE_TEST(equals[from copy], {
struct queue *d1 = q_new(100, q_ftab_val);
struct queue *d1 = q_new(100, q_fval);
cmc_assert_not_equals(ptr, NULL, d1);
@@ -404,7 +404,7 @@ CMC_CREATE_UNIT(queue_test, true, {
});
CMC_CREATE_TEST(equals[count = 0], {
struct queue *d1 = q_new(100, q_ftab_val);
struct queue *d1 = q_new(100, q_fval);
cmc_assert_not_equals(ptr, NULL, d1);
@@ -419,7 +419,7 @@ CMC_CREATE_UNIT(queue_test, true, {
});
CMC_CREATE_TEST(flag, {
struct queue *q = q_new(100, q_ftab_val);
struct queue *q = q_new(100, q_fval);
cmc_assert_not_equals(ptr, NULL, q);
cmc_assert_equals(int32_t, cmc_flags.OK, q_flag(q));
@@ -478,7 +478,7 @@ CMC_CREATE_UNIT(queue_test, true, {
});
CMC_CREATE_TEST(callbacks, {
struct queue *q = q_new_custom(100, q_ftab_val, NULL, callbacks);
struct queue *q = q_new_custom(100, q_fval, NULL, callbacks);
cmc_assert_not_equals(ptr, NULL, q);
+14 -14
View File
@@ -5,8 +5,8 @@
#include "../src/sortedlist.c"
struct sortedlist_ftab_val *sl_ftab_val =
&(struct sortedlist_ftab_val){ .cmp = cmp,
struct sortedlist_fval *sl_fval =
&(struct sortedlist_fval){ .cmp = cmp,
.cpy = copy,
.str = str,
.free = custom_free,
@@ -15,7 +15,7 @@ struct sortedlist_ftab_val *sl_ftab_val =
CMC_CREATE_UNIT(sortedlist_test, true, {
CMC_CREATE_TEST(new, {
struct sortedlist *sl = sl_new(1000000, sl_ftab_val);
struct sortedlist *sl = sl_new(1000000, sl_fval);
cmc_assert_not_equals(ptr, NULL, sl);
cmc_assert_not_equals(ptr, NULL, sl->buffer);
@@ -27,19 +27,19 @@ CMC_CREATE_UNIT(sortedlist_test, true, {
});
CMC_CREATE_TEST(new[capacity = 0], {
struct sortedlist *sl = sl_new(0, sl_ftab_val);
struct sortedlist *sl = sl_new(0, sl_fval);
cmc_assert_equals(ptr, NULL, sl);
});
CMC_CREATE_TEST(new[capacity = UINT64_MAX], {
struct sortedlist *sl = sl_new(UINT64_MAX, sl_ftab_val);
struct sortedlist *sl = sl_new(UINT64_MAX, sl_fval);
cmc_assert_equals(ptr, NULL, sl);
});
CMC_CREATE_TEST(clear[count capacity], {
struct sortedlist *sl = sl_new(100, sl_ftab_val);
struct sortedlist *sl = sl_new(100, sl_fval);
cmc_assert_not_equals(ptr, NULL, sl);
@@ -57,7 +57,7 @@ CMC_CREATE_UNIT(sortedlist_test, true, {
});
CMC_CREATE_TEST(buffer_growth[capacity = 1], {
struct sortedlist *sl = sl_new(1, sl_ftab_val);
struct sortedlist *sl = sl_new(1, sl_fval);
cmc_assert_not_equals(ptr, NULL, sl);
@@ -73,7 +73,7 @@ CMC_CREATE_UNIT(sortedlist_test, true, {
});
CMC_CREATE_TEST(insert, {
struct sortedlist *sl = sl_new(100, sl_ftab_val);
struct sortedlist *sl = sl_new(100, sl_fval);
cmc_assert_not_equals(ptr, NULL, sl);
@@ -83,7 +83,7 @@ CMC_CREATE_UNIT(sortedlist_test, true, {
});
CMC_CREATE_TEST(remove, {
struct sortedlist *sl = sl_new(100, sl_ftab_val);
struct sortedlist *sl = sl_new(100, sl_fval);
cmc_assert_not_equals(ptr, NULL, sl);
@@ -95,7 +95,7 @@ CMC_CREATE_UNIT(sortedlist_test, true, {
});
CMC_CREATE_TEST(remove[count = 0], {
struct sortedlist *sl = sl_new(100, sl_ftab_val);
struct sortedlist *sl = sl_new(100, sl_fval);
cmc_assert_not_equals(ptr, NULL, sl);
@@ -105,7 +105,7 @@ CMC_CREATE_UNIT(sortedlist_test, true, {
});
CMC_CREATE_TEST(remove[out of range], {
struct sortedlist *sl = sl_new(100, sl_ftab_val);
struct sortedlist *sl = sl_new(100, sl_fval);
cmc_assert_not_equals(ptr, NULL, sl);
@@ -117,7 +117,7 @@ CMC_CREATE_UNIT(sortedlist_test, true, {
});
CMC_CREATE_TEST(index_of, {
struct sortedlist *sl = sl_new(1, sl_ftab_val);
struct sortedlist *sl = sl_new(1, sl_fval);
cmc_assert_not_equals(ptr, NULL, sl);
@@ -145,7 +145,7 @@ CMC_CREATE_UNIT(sortedlist_test, true, {
});
CMC_CREATE_TEST(flags, {
struct sortedlist *sl = sl_new(100, sl_ftab_val);
struct sortedlist *sl = sl_new(100, sl_fval);
cmc_assert_not_equals(ptr, NULL, sl);
cmc_assert_equals(int32_t, cmc_flags.OK, sl_flag(sl));
@@ -236,7 +236,7 @@ CMC_CREATE_UNIT(sortedlist_test, true, {
CMC_CREATE_TEST(callbacks, {
struct sortedlist *sl =
sl_new_custom(100, sl_ftab_val, NULL, callbacks);
sl_new_custom(100, sl_fval, NULL, callbacks);
cmc_assert_not_equals(ptr, NULL, sl);
+40 -40
View File
@@ -5,8 +5,8 @@
#include "../src/stack.c"
struct stack_ftab_val *s_ftab_val =
&(struct stack_ftab_val){ .cmp = cmp,
struct stack_fval *s_fval =
&(struct stack_fval){ .cmp = cmp,
.cpy = copy,
.str = str,
.free = custom_free,
@@ -15,7 +15,7 @@ struct stack_ftab_val *s_ftab_val =
CMC_CREATE_UNIT(stack_test, true, {
CMC_CREATE_TEST(new, {
struct stack *s = s_new(1000000, s_ftab_val);
struct stack *s = s_new(1000000, s_fval);
cmc_assert_not_equals(ptr, NULL, s);
cmc_assert_not_equals(ptr, NULL, s->buffer);
@@ -27,19 +27,19 @@ CMC_CREATE_UNIT(stack_test, true, {
});
CMC_CREATE_TEST(new[capacity = 0], {
struct stack *s = s_new(0, s_ftab_val);
struct stack *s = s_new(0, s_fval);
cmc_assert_equals(ptr, NULL, s);
});
CMC_CREATE_TEST(new[capacity = UINT64_MAX], {
struct stack *s = s_new(UINT64_MAX, s_ftab_val);
struct stack *s = s_new(UINT64_MAX, s_fval);
cmc_assert_equals(ptr, NULL, s);
});
CMC_CREATE_TEST(clear[count capacity], {
struct stack *s = s_new(100, s_ftab_val);
struct stack *s = s_new(100, s_fval);
cmc_assert_not_equals(ptr, NULL, s);
@@ -57,7 +57,7 @@ CMC_CREATE_UNIT(stack_test, true, {
});
CMC_CREATE_TEST(buffer_growth[capacity = 1], {
struct stack *s = s_new(1, s_ftab_val);
struct stack *s = s_new(1, s_fval);
cmc_assert_not_equals(ptr, NULL, s);
@@ -71,7 +71,7 @@ CMC_CREATE_UNIT(stack_test, true, {
});
CMC_CREATE_TEST(push[count], {
struct stack *s = s_new(100, s_ftab_val);
struct stack *s = s_new(100, s_fval);
cmc_assert_not_equals(ptr, NULL, s);
@@ -84,7 +84,7 @@ CMC_CREATE_UNIT(stack_test, true, {
});
CMC_CREATE_TEST(push[capacity], {
struct stack *s = s_new(100, s_ftab_val);
struct stack *s = s_new(100, s_fval);
cmc_assert_not_equals(ptr, NULL, s);
@@ -97,7 +97,7 @@ CMC_CREATE_UNIT(stack_test, true, {
});
CMC_CREATE_TEST(push[item preservation], {
struct stack *s = s_new(100, s_ftab_val);
struct stack *s = s_new(100, s_fval);
cmc_assert_not_equals(ptr, NULL, s);
@@ -111,7 +111,7 @@ CMC_CREATE_UNIT(stack_test, true, {
});
CMC_CREATE_TEST(pop[count], {
struct stack *s = s_new(100, s_ftab_val);
struct stack *s = s_new(100, s_fval);
cmc_assert_not_equals(ptr, NULL, s);
@@ -126,7 +126,7 @@ CMC_CREATE_UNIT(stack_test, true, {
});
CMC_CREATE_TEST(pop[capacity], {
struct stack *s = s_new(100, s_ftab_val);
struct stack *s = s_new(100, s_fval);
cmc_assert_not_equals(ptr, NULL, s);
@@ -141,7 +141,7 @@ CMC_CREATE_UNIT(stack_test, true, {
});
CMC_CREATE_TEST(pop[item preservation], {
struct stack *s = s_new(100, s_ftab_val);
struct stack *s = s_new(100, s_fval);
cmc_assert_not_equals(ptr, NULL, s);
@@ -158,7 +158,7 @@ CMC_CREATE_UNIT(stack_test, true, {
});
CMC_CREATE_TEST(pop[count = 0], {
struct stack *s = s_new(100, s_ftab_val);
struct stack *s = s_new(100, s_fval);
cmc_assert_not_equals(ptr, NULL, s);
@@ -168,7 +168,7 @@ CMC_CREATE_UNIT(stack_test, true, {
});
CMC_CREATE_TEST(top, {
struct stack *s = s_new(100, s_ftab_val);
struct stack *s = s_new(100, s_fval);
cmc_assert_not_equals(ptr, NULL, s);
@@ -184,7 +184,7 @@ CMC_CREATE_UNIT(stack_test, true, {
});
CMC_CREATE_TEST(top[count = 0], {
struct stack *s = s_new(100, s_ftab_val);
struct stack *s = s_new(100, s_fval);
cmc_assert_not_equals(ptr, NULL, s);
@@ -198,7 +198,7 @@ CMC_CREATE_UNIT(stack_test, true, {
});
CMC_CREATE_TEST(top[count = 1], {
struct stack *s = s_new(100, s_ftab_val);
struct stack *s = s_new(100, s_fval);
cmc_assert_not_equals(ptr, NULL, s);
@@ -210,7 +210,7 @@ CMC_CREATE_UNIT(stack_test, true, {
});
CMC_CREATE_TEST(contains, {
struct stack *s = s_new(100, s_ftab_val);
struct stack *s = s_new(100, s_fval);
cmc_assert_not_equals(ptr, NULL, s);
@@ -224,7 +224,7 @@ CMC_CREATE_UNIT(stack_test, true, {
});
CMC_CREATE_TEST(contains[count = 0], {
struct stack *s = s_new(100, s_ftab_val);
struct stack *s = s_new(100, s_fval);
cmc_assert_not_equals(ptr, NULL, s);
@@ -234,7 +234,7 @@ CMC_CREATE_UNIT(stack_test, true, {
});
CMC_CREATE_TEST(empty, {
struct stack *s = s_new(100, s_ftab_val);
struct stack *s = s_new(100, s_fval);
cmc_assert_not_equals(ptr, NULL, s);
@@ -244,7 +244,7 @@ CMC_CREATE_UNIT(stack_test, true, {
});
CMC_CREATE_TEST(empty[after_io], {
struct stack *s = s_new(100, s_ftab_val);
struct stack *s = s_new(100, s_fval);
cmc_assert_not_equals(ptr, NULL, s);
@@ -256,7 +256,7 @@ CMC_CREATE_UNIT(stack_test, true, {
});
CMC_CREATE_TEST(full, {
struct stack *s = s_new(100, s_ftab_val);
struct stack *s = s_new(100, s_fval);
cmc_assert_not_equals(ptr, NULL, s);
@@ -269,7 +269,7 @@ CMC_CREATE_UNIT(stack_test, true, {
});
CMC_CREATE_TEST(full[capacity = 1], {
struct stack *s = s_new(1, s_ftab_val);
struct stack *s = s_new(1, s_fval);
cmc_assert_not_equals(ptr, NULL, s);
@@ -281,7 +281,7 @@ CMC_CREATE_UNIT(stack_test, true, {
});
CMC_CREATE_TEST(iter_alloc, {
struct stack *s = s_new(100, s_ftab_val);
struct stack *s = s_new(100, s_fval);
cmc_assert_not_equals(ptr, NULL, s);
@@ -294,7 +294,7 @@ CMC_CREATE_UNIT(stack_test, true, {
});
CMC_CREATE_TEST(iter_init[count = 0], {
struct stack *s = s_new(100, s_ftab_val);
struct stack *s = s_new(100, s_fval);
cmc_assert_not_equals(ptr, NULL, s);
@@ -311,7 +311,7 @@ CMC_CREATE_UNIT(stack_test, true, {
});
CMC_CREATE_TEST(iter_start[count = 0], {
struct stack *s = s_new(100, s_ftab_val);
struct stack *s = s_new(100, s_fval);
cmc_assert_not_equals(ptr, NULL, s);
@@ -325,7 +325,7 @@ CMC_CREATE_UNIT(stack_test, true, {
});
CMC_CREATE_TEST(iter_end[count = 0], {
struct stack *s = s_new(100, s_ftab_val);
struct stack *s = s_new(100, s_fval);
cmc_assert_not_equals(ptr, NULL, s);
@@ -339,7 +339,7 @@ CMC_CREATE_UNIT(stack_test, true, {
});
CMC_CREATE_TEST(iteration, {
struct stack *s = s_new(100, s_ftab_val);
struct stack *s = s_new(100, s_fval);
cmc_assert_not_equals(ptr, NULL, s);
@@ -368,7 +368,7 @@ CMC_CREATE_UNIT(stack_test, true, {
});
CMC_CREATE_TEST(iteration[while loop], {
struct stack *s = s_new(100, s_ftab_val);
struct stack *s = s_new(100, s_fval);
cmc_assert_not_equals(ptr, NULL, s);
@@ -398,7 +398,7 @@ CMC_CREATE_UNIT(stack_test, true, {
});
CMC_CREATE_TEST(iteration[count = 1], {
struct stack *s = s_new(100, s_ftab_val);
struct stack *s = s_new(100, s_fval);
cmc_assert_not_equals(ptr, NULL, s);
cmc_assert(s_push(s, 10));
@@ -423,7 +423,7 @@ CMC_CREATE_UNIT(stack_test, true, {
});
CMC_CREATE_TEST(iteration[count = capacity], {
struct stack *s = s_new(100, s_ftab_val);
struct stack *s = s_new(100, s_fval);
cmc_assert_not_equals(ptr, NULL, s);
@@ -454,7 +454,7 @@ CMC_CREATE_UNIT(stack_test, true, {
});
CMC_CREATE_TEST(iteration[to_start = it_start and to_end = it_end], {
struct stack *s = s_new(100, s_ftab_val);
struct stack *s = s_new(100, s_fval);
cmc_assert_not_equals(ptr, NULL, s);
@@ -489,7 +489,7 @@ CMC_CREATE_UNIT(stack_test, true, {
});
CMC_CREATE_TEST(iteration[boundaries count = 0], {
struct stack *s = s_new(100, s_ftab_val);
struct stack *s = s_new(100, s_fval);
cmc_assert_not_equals(ptr, NULL, s);
@@ -508,7 +508,7 @@ CMC_CREATE_UNIT(stack_test, true, {
});
CMC_CREATE_TEST(iteration[boundaries count > 0], {
struct stack *s = s_new(100, s_ftab_val);
struct stack *s = s_new(100, s_fval);
cmc_assert_not_equals(ptr, NULL, s);
@@ -530,7 +530,7 @@ CMC_CREATE_UNIT(stack_test, true, {
});
CMC_CREATE_TEST(iter_value[count = 0], {
struct stack *s = s_new(100, s_ftab_val);
struct stack *s = s_new(100, s_fval);
cmc_assert_not_equals(ptr, NULL, s);
@@ -544,7 +544,7 @@ CMC_CREATE_UNIT(stack_test, true, {
});
CMC_CREATE_TEST(iter_rvalue[count = 0], {
struct stack *s = s_new(100, s_ftab_val);
struct stack *s = s_new(100, s_fval);
cmc_assert_not_equals(ptr, NULL, s);
@@ -558,7 +558,7 @@ CMC_CREATE_UNIT(stack_test, true, {
});
CMC_CREATE_TEST(index, {
struct stack *s = s_new(100, s_ftab_val);
struct stack *s = s_new(100, s_fval);
cmc_assert_not_equals(ptr, NULL, s);
@@ -599,7 +599,7 @@ CMC_CREATE_UNIT(stack_test, true, {
});
CMC_CREATE_TEST(index[count = 0], {
struct stack *s = s_new(100, s_ftab_val);
struct stack *s = s_new(100, s_fval);
cmc_assert_not_equals(ptr, NULL, s);
@@ -612,7 +612,7 @@ CMC_CREATE_UNIT(stack_test, true, {
});
CMC_CREATE_TEST(flags, {
struct stack *s = s_new(100, s_ftab_val);
struct stack *s = s_new(100, s_fval);
cmc_assert_not_equals(ptr, NULL, s);
cmc_assert_equals(int32_t, cmc_flags.OK, s_flag(s));
@@ -671,7 +671,7 @@ CMC_CREATE_UNIT(stack_test, true, {
});
CMC_CREATE_TEST(callbacks, {
struct stack *s = s_new_custom(100, s_ftab_val, NULL, callbacks);
struct stack *s = s_new_custom(100, s_fval, NULL, callbacks);
cmc_assert_not_equals(ptr, NULL, s);
+8 -8
View File
@@ -5,16 +5,16 @@
#include "../src/treemap.c"
struct treemap_ftab_key *tm_ftab_key =
&(struct treemap_ftab_key){ .cmp = cmp,
struct treemap_fkey *tm_fkey =
&(struct treemap_fkey){ .cmp = cmp,
.cpy = copy,
.str = str,
.free = custom_free,
.hash = hash,
.pri = pri };
struct treemap_ftab_val *tm_ftab_val =
&(struct treemap_ftab_val){ .cmp = cmp,
struct treemap_fval *tm_fval =
&(struct treemap_fval){ .cmp = cmp,
.cpy = copy,
.str = str,
.free = custom_free,
@@ -23,7 +23,7 @@ struct treemap_ftab_val *tm_ftab_val =
CMC_CREATE_UNIT(treemap_test, true, {
CMC_CREATE_TEST(new, {
struct treemap *map = tm_new(tm_ftab_key, tm_ftab_val);
struct treemap *map = tm_new(tm_fkey, tm_fval);
cmc_assert_not_equals(ptr, NULL, map);
@@ -31,7 +31,7 @@ CMC_CREATE_UNIT(treemap_test, true, {
});
CMC_CREATE_TEST(clear[count], {
struct treemap *map = tm_new(tm_ftab_key, tm_ftab_val);
struct treemap *map = tm_new(tm_fkey, tm_fval);
cmc_assert_not_equals(ptr, NULL, map);
@@ -49,7 +49,7 @@ CMC_CREATE_UNIT(treemap_test, true, {
});
CMC_CREATE_TEST(flags, {
struct treemap *map = tm_new(tm_ftab_key, tm_ftab_val);
struct treemap *map = tm_new(tm_fkey, tm_fval);
cmc_assert_not_equals(ptr, NULL, map);
cmc_assert_equals(int32_t, cmc_flags.OK, tm_flag(map));
@@ -140,7 +140,7 @@ CMC_CREATE_UNIT(treemap_test, true, {
CMC_CREATE_TEST(callbacks, {
struct treemap *map =
tm_new_custom(tm_ftab_key, tm_ftab_val, NULL, callbacks);
tm_new_custom(tm_fkey, tm_fval, NULL, callbacks);
cmc_assert_not_equals(ptr, NULL, map);
+6 -6
View File
@@ -5,8 +5,8 @@
#include "../src/treeset.c"
struct treeset_ftab_val *ts_ftab_val =
&(struct treeset_ftab_val){ .cmp = cmp,
struct treeset_fval *ts_fval =
&(struct treeset_fval){ .cmp = cmp,
.cpy = copy,
.str = str,
.free = custom_free,
@@ -15,7 +15,7 @@ struct treeset_ftab_val *ts_ftab_val =
CMC_CREATE_UNIT(treeset_test, true, {
CMC_CREATE_TEST(new, {
struct treeset *set = ts_new(ts_ftab_val);
struct treeset *set = ts_new(ts_fval);
cmc_assert_not_equals(ptr, NULL, set);
@@ -23,7 +23,7 @@ CMC_CREATE_UNIT(treeset_test, true, {
});
CMC_CREATE_TEST(clear[count], {
struct treeset *set = ts_new(ts_ftab_val);
struct treeset *set = ts_new(ts_fval);
cmc_assert_not_equals(ptr, NULL, set);
@@ -41,7 +41,7 @@ CMC_CREATE_UNIT(treeset_test, true, {
});
CMC_CREATE_TEST(flags, {
struct treeset *set = ts_new(ts_ftab_val);
struct treeset *set = ts_new(ts_fval);
cmc_assert_not_equals(ptr, NULL, set);
cmc_assert_equals(int32_t, cmc_flags.OK, ts_flag(set));
@@ -102,7 +102,7 @@ CMC_CREATE_UNIT(treeset_test, true, {
});
CMC_CREATE_TEST(callbacks, {
struct treeset *set = ts_new_custom(ts_ftab_val, NULL, callbacks);
struct treeset *set = ts_new_custom(ts_fval, NULL, callbacks);
cmc_assert_not_equals(ptr, NULL, set);