Tests reworked - CI might not work

This commit is contained in:
Leonardo Vencovsky committed 2020-06-11 21:23:42 -03:00
1 parent f8607e8cdc
commit 4bebb90cb6
65 files changed
+2071 -1952

No files matched your search

+51
View File
@@ -0,0 +1,51 @@
#ifndef CMC_CMC_BITSET_TEST_H
#define CMC_CMC_BITSET_TEST_H
#include "macro_collections.h"
struct bitset
{
cmc_bitset_word *buffer;
size_t capacity;
int flag;
struct cmc_alloc_node *alloc;
struct cmc_callbacks *callbacks;
};
struct bitset_iter
{
struct bitset *target;
size_t cursor;
_Bool start;
_Bool end;
};
struct bitset *bs_new(size_t n_bits);
struct bitset *bs_new_custom(size_t n_bits, struct cmc_alloc_node *alloc, struct cmc_callbacks *callbacks);
struct bitset bs_init(size_t n_bits);
struct bitset bs_init_custom(size_t n_bits, struct cmc_alloc_node *alloc, struct cmc_callbacks *callbacks);
void bs_free(struct bitset *_bitset_);
void bs_release(struct bitset _bitset_);
void bs_customize(struct bitset *_bitset_, struct cmc_alloc_node *alloc, struct cmc_callbacks *callbacks);
_Bool bs_set(struct bitset *_bitset_, size_t bit_index);
_Bool bs_set_range(struct bitset *_bitset_, size_t from, size_t to);
_Bool bs_clear(struct bitset *_bitset_, size_t bit_index);
_Bool bs_clear_range(struct bitset *_bitset_, size_t from, size_t to);
_Bool bs_flip(struct bitset *_bitset_, size_t bit_index);
_Bool bs_flip_range(struct bitset *_bitset_, size_t from, size_t to);
_Bool bs_put(struct bitset *_bitset_, size_t bit_index, _Bool state);
_Bool bs_put_range(struct bitset *_bitset_, size_t from, size_t to, _Bool state);
_Bool bs_set_all(struct bitset *_bitset_);
_Bool bs_clear_all(struct bitset *_bitset_);
_Bool bs_flip_all(struct bitset *_bitset_);
_Bool bs_get(struct bitset *_bitset_, size_t bit_index);
_Bool bs_resize(struct bitset *_bitset_, size_t n_bits);
static inline size_t bs_bit_to_index(size_t idx)
{
static const size_t shift =
((sizeof(cmc_bitset_word) * 8) >> 6) > 0
? 6
: ((sizeof(cmc_bitset_word) * 8) >> 5) > 0 ? 5 : ((sizeof(cmc_bitset_word) * 8) >> 4) > 0 ? 4 : 3;
return idx >> shift;
}
#endif /* CMC_CMC_BITSET_TEST_H */
+78
View File
@@ -0,0 +1,78 @@
#ifndef CMC_CMC_DEQUE_TEST_H
#define CMC_CMC_DEQUE_TEST_H
#include "macro_collections.h"
struct deque
{
size_t *buffer;
size_t capacity;
size_t count;
size_t front;
size_t back;
int flag;
struct deque_fval *f_val;
struct cmc_alloc_node *alloc;
struct cmc_callbacks *callbacks;
};
struct deque_fval
{
int (*cmp)(size_t, size_t);
size_t (*cpy)(size_t);
_Bool (*str)(FILE *, size_t);
void (*free)(size_t);
size_t (*hash)(size_t);
int (*pri)(size_t, size_t);
};
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_);
void d_free(struct deque *_deque_);
void d_customize(struct deque *_deque_, struct cmc_alloc_node *alloc, struct cmc_callbacks *callbacks);
_Bool d_push_front(struct deque *_deque_, size_t value);
_Bool d_push_back(struct deque *_deque_, size_t value);
_Bool d_pop_front(struct deque *_deque_);
_Bool d_pop_back(struct deque *_deque_);
size_t d_front(struct deque *_deque_);
size_t d_back(struct deque *_deque_);
_Bool d_contains(struct deque *_deque_, size_t value);
_Bool d_empty(struct deque *_deque_);
_Bool d_full(struct deque *_deque_);
size_t d_count(struct deque *_deque_);
size_t d_capacity(struct deque *_deque_);
int d_flag(struct deque *_deque_);
_Bool d_resize(struct deque *_deque_, size_t capacity);
struct deque *d_copy_of(struct deque *_deque_);
_Bool d_equals(struct deque *_deque1_, struct deque *_deque2_);
struct deque d_init(size_t capacity, struct deque_fval *f_val);
struct deque d_init_custom(size_t capacity, struct deque_fval *f_val, struct cmc_alloc_node *alloc,
struct cmc_callbacks *callbacks);
void d_release(struct deque _deque_);
struct deque_iter
{
struct deque *target;
size_t cursor;
size_t index;
_Bool start;
_Bool end;
};
struct deque_iter d_iter_start(struct deque *target);
struct deque_iter d_iter_end(struct deque *target);
_Bool d_iter_at_start(struct deque_iter *iter);
_Bool d_iter_at_end(struct deque_iter *iter);
_Bool d_iter_to_start(struct deque_iter *iter);
_Bool d_iter_to_end(struct deque_iter *iter);
_Bool d_iter_next(struct deque_iter *iter);
_Bool d_iter_prev(struct deque_iter *iter);
_Bool d_iter_advance(struct deque_iter *iter, size_t steps);
_Bool d_iter_rewind(struct deque_iter *iter, size_t steps);
_Bool d_iter_go_to(struct deque_iter *iter, size_t index);
size_t d_iter_value(struct deque_iter *iter);
size_t *d_iter_rvalue(struct deque_iter *iter);
size_t d_iter_index(struct deque_iter *iter);
_Bool d_to_string(struct deque *_deque_, FILE *fptr);
_Bool d_print(struct deque *_deque_, FILE *fptr, const char *start, const char *separator, const char *end);
#endif /* CMC_CMC_DEQUE_TEST_H */
+101
View File
@@ -0,0 +1,101 @@
#ifndef CMC_CMC_HASHBIDIMAP_TEST_H
#define CMC_CMC_HASHBIDIMAP_TEST_H
#include "macro_collections.h"
struct hashbidimap
{
struct hashbidimap_entry *(*buffer)[2];
size_t capacity;
size_t count;
double load;
int flag;
struct hashbidimap_fkey *f_key;
struct hashbidimap_fval *f_val;
struct cmc_alloc_node *alloc;
struct cmc_callbacks *callbacks;
struct hashbidimap_iter (*it_start)(struct hashbidimap *);
struct hashbidimap_iter (*it_end)(struct hashbidimap *);
};
struct hashbidimap_entry
{
size_t key;
size_t value;
size_t dist[2];
struct hashbidimap_entry **ref[2];
};
struct hashbidimap_fkey
{
int (*cmp)(size_t, size_t);
size_t (*cpy)(size_t);
_Bool (*str)(FILE *, size_t);
void (*free)(size_t);
size_t (*hash)(size_t);
int (*pri)(size_t, size_t);
};
struct hashbidimap_fval
{
int (*cmp)(size_t, size_t);
size_t (*cpy)(size_t);
_Bool (*str)(FILE *, size_t);
void (*free)(size_t);
size_t (*hash)(size_t);
int (*pri)(size_t, size_t);
};
struct hashbidimap_iter
{
struct hashbidimap *target;
size_t cursor;
size_t index;
size_t first;
size_t last;
_Bool start;
_Bool end;
};
struct hashbidimap *hbm_new(size_t capacity, double load, struct hashbidimap_fkey *f_key,
struct hashbidimap_fval *f_val);
struct hashbidimap *hbm_new_custom(size_t capacity, double load, struct hashbidimap_fkey *f_key,
struct hashbidimap_fval *f_val, struct cmc_alloc_node *alloc,
struct cmc_callbacks *callbacks);
void hbm_clear(struct hashbidimap *_map_);
void hbm_free(struct hashbidimap *_map_);
void hbm_customize(struct hashbidimap *_map_, struct cmc_alloc_node *alloc, struct cmc_callbacks *callbacks);
_Bool hbm_insert(struct hashbidimap *_map_, size_t key, size_t value);
_Bool hbm_update_key(struct hashbidimap *_map_, size_t val, size_t new_key);
_Bool hbm_update_val(struct hashbidimap *_map_, size_t key, size_t new_val);
_Bool hbm_remove_by_key(struct hashbidimap *_map_, size_t key, size_t *out_key, size_t *out_val);
_Bool hbm_remove_by_val(struct hashbidimap *_map_, size_t val, size_t *out_key, size_t *out_val);
size_t hbm_get_key(struct hashbidimap *_map_, size_t val);
size_t hbm_get_val(struct hashbidimap *_map_, size_t key);
_Bool hbm_contains_key(struct hashbidimap *_map_, size_t key);
_Bool hbm_contains_val(struct hashbidimap *_map_, size_t val);
_Bool hbm_empty(struct hashbidimap *_map_);
_Bool hbm_full(struct hashbidimap *_map_);
size_t hbm_count(struct hashbidimap *_map_);
size_t hbm_capacity(struct hashbidimap *_map_);
double hbm_load(struct hashbidimap *_map_);
int hbm_flag(struct hashbidimap *_map_);
_Bool hbm_resize(struct hashbidimap *_map_, size_t capacity);
struct hashbidimap *hbm_copy_of(struct hashbidimap *_map_);
_Bool hbm_equals(struct hashbidimap *_map1_, struct hashbidimap *_map2_);
struct hashbidimap_iter *hbm_iter_new(struct hashbidimap *target);
void hbm_iter_free(struct hashbidimap_iter *iter);
void hbm_iter_init(struct hashbidimap_iter *iter, struct hashbidimap *target);
_Bool hbm_iter_start(struct hashbidimap_iter *iter);
_Bool hbm_iter_end(struct hashbidimap_iter *iter);
void hbm_iter_to_start(struct hashbidimap_iter *iter);
void hbm_iter_to_end(struct hashbidimap_iter *iter);
_Bool hbm_iter_next(struct hashbidimap_iter *iter);
_Bool hbm_iter_prev(struct hashbidimap_iter *iter);
_Bool hbm_iter_advance(struct hashbidimap_iter *iter, size_t steps);
_Bool hbm_iter_rewind(struct hashbidimap_iter *iter, size_t steps);
_Bool hbm_iter_go_to(struct hashbidimap_iter *iter, size_t index);
size_t hbm_iter_key(struct hashbidimap_iter *iter);
size_t hbm_iter_value(struct hashbidimap_iter *iter);
size_t hbm_iter_index(struct hashbidimap_iter *iter);
_Bool hbm_to_string(struct hashbidimap *_map_, FILE *fptr);
_Bool hbm_print(struct hashbidimap *_map_, FILE *fptr, const char *start, const char *separator, const char *end,
const char *key_val_sep);
#endif /* CMC_CMC_HASHBIDIMAP_TEST_H */
+100
View File
@@ -0,0 +1,100 @@
#ifndef CMC_CMC_HASHMAP_TEST_H
#define CMC_CMC_HASHMAP_TEST_H
#include "macro_collections.h"
struct hashmap
{
struct hashmap_entry *buffer;
size_t capacity;
size_t count;
double load;
int flag;
struct hashmap_fkey *f_key;
struct hashmap_fval *f_val;
struct cmc_alloc_node *alloc;
struct cmc_callbacks *callbacks;
};
struct hashmap_entry
{
size_t key;
size_t value;
size_t dist;
enum cmc_entry_state state;
};
struct hashmap_fkey
{
int (*cmp)(size_t, size_t);
size_t (*cpy)(size_t);
_Bool (*str)(FILE *, size_t);
void (*free)(size_t);
size_t (*hash)(size_t);
int (*pri)(size_t, size_t);
};
struct hashmap_fval
{
int (*cmp)(size_t, size_t);
size_t (*cpy)(size_t);
_Bool (*str)(FILE *, size_t);
void (*free)(size_t);
size_t (*hash)(size_t);
int (*pri)(size_t, size_t);
};
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_fkey *f_key, struct hashmap_fval *f_val,
struct cmc_alloc_node *alloc, struct cmc_callbacks *callbacks);
void hm_clear(struct hashmap *_map_);
void hm_free(struct hashmap *_map_);
void hm_customize(struct hashmap *_map_, struct cmc_alloc_node *alloc, struct cmc_callbacks *callbacks);
_Bool hm_insert(struct hashmap *_map_, size_t key, size_t value);
_Bool hm_update(struct hashmap *_map_, size_t key, size_t new_value, size_t *old_value);
_Bool hm_remove(struct hashmap *_map_, size_t key, size_t *out_value);
_Bool hm_max(struct hashmap *_map_, size_t *key, size_t *value);
_Bool hm_min(struct hashmap *_map_, size_t *key, size_t *value);
size_t hm_get(struct hashmap *_map_, size_t key);
size_t *hm_get_ref(struct hashmap *_map_, size_t key);
_Bool hm_contains(struct hashmap *_map_, size_t key);
_Bool hm_empty(struct hashmap *_map_);
_Bool hm_full(struct hashmap *_map_);
size_t hm_count(struct hashmap *_map_);
size_t hm_capacity(struct hashmap *_map_);
double hm_load(struct hashmap *_map_);
int hm_flag(struct hashmap *_map_);
_Bool hm_resize(struct hashmap *_map_, size_t capacity);
struct hashmap *hm_copy_of(struct hashmap *_map_);
_Bool hm_equals(struct hashmap *_map1_, struct hashmap *_map2_);
struct hashmap hm_init(size_t capacity, double load, struct hashmap_fkey *f_key, struct hashmap_fval *f_val);
struct hashmap hm_init_custom(size_t capacity, double load, struct hashmap_fkey *f_key, struct hashmap_fval *f_val,
struct cmc_alloc_node *alloc, struct cmc_callbacks *callbacks);
void hm_release(struct hashmap _map_);
struct hashmap_iter
{
struct hashmap *target;
size_t cursor;
size_t index;
size_t first;
size_t last;
_Bool start;
_Bool end;
};
struct hashmap_iter hm_iter_start(struct hashmap *target);
struct hashmap_iter hm_iter_end(struct hashmap *target);
_Bool hm_iter_at_start(struct hashmap_iter *iter);
_Bool hm_iter_at_end(struct hashmap_iter *iter);
_Bool hm_iter_to_start(struct hashmap_iter *iter);
_Bool hm_iter_to_end(struct hashmap_iter *iter);
_Bool hm_iter_next(struct hashmap_iter *iter);
_Bool hm_iter_prev(struct hashmap_iter *iter);
_Bool hm_iter_advance(struct hashmap_iter *iter, size_t steps);
_Bool hm_iter_rewind(struct hashmap_iter *iter, size_t steps);
_Bool hm_iter_go_to(struct hashmap_iter *iter, size_t index);
size_t hm_iter_key(struct hashmap_iter *iter);
size_t hm_iter_value(struct hashmap_iter *iter);
size_t *hm_iter_rvalue(struct hashmap_iter *iter);
size_t hm_iter_index(struct hashmap_iter *iter);
_Bool hm_to_string(struct hashmap *_map_, FILE *fptr);
_Bool hm_print(struct hashmap *_map_, FILE *fptr, const char *start, const char *separator, const char *end,
const char *key_val_sep);
#endif /* CMC_CMC_HASHMAP_TEST_H */
+102
View File
@@ -0,0 +1,102 @@
#ifndef CMC_CMC_HASHMULTIMAP_TEST_H
#define CMC_CMC_HASHMULTIMAP_TEST_H
#include "macro_collections.h"
struct hashmultimap
{
struct hashmultimap_entry *(*buffer)[2];
size_t capacity;
size_t count;
double load;
int flag;
struct hashmultimap_fkey *f_key;
struct hashmultimap_fval *f_val;
struct cmc_alloc_node *alloc;
struct cmc_callbacks *callbacks;
};
struct hashmultimap_entry
{
size_t key;
size_t value;
struct hashmultimap_entry *next;
struct hashmultimap_entry *prev;
};
struct hashmultimap_fkey
{
int (*cmp)(size_t, size_t);
size_t (*cpy)(size_t);
_Bool (*str)(FILE *, size_t);
void (*free)(size_t);
size_t (*hash)(size_t);
int (*pri)(size_t, size_t);
};
struct hashmultimap_fval
{
int (*cmp)(size_t, size_t);
size_t (*cpy)(size_t);
_Bool (*str)(FILE *, size_t);
void (*free)(size_t);
size_t (*hash)(size_t);
int (*pri)(size_t, size_t);
};
struct hashmultimap *hmm_new(size_t capacity, double load, struct hashmultimap_fkey *f_key,
struct hashmultimap_fval *f_val);
struct hashmultimap *hmm_new_custom(size_t capacity, double load, struct hashmultimap_fkey *f_key,
struct hashmultimap_fval *f_val, struct cmc_alloc_node *alloc,
struct cmc_callbacks *callbacks);
void hmm_clear(struct hashmultimap *_map_);
void hmm_free(struct hashmultimap *_map_);
void hmm_customize(struct hashmultimap *_map_, struct cmc_alloc_node *alloc, struct cmc_callbacks *callbacks);
_Bool hmm_insert(struct hashmultimap *_map_, size_t key, size_t value);
_Bool hmm_update(struct hashmultimap *_map_, size_t key, size_t new_value, size_t *old_value);
size_t hmm_update_all(struct hashmultimap *_map_, size_t key, size_t new_value, size_t **old_values);
_Bool hmm_remove(struct hashmultimap *_map_, size_t key, size_t *out_value);
size_t hmm_remove_all(struct hashmultimap *_map_, size_t key, size_t **out_values);
_Bool hmm_max(struct hashmultimap *_map_, size_t *key, size_t *value);
_Bool hmm_min(struct hashmultimap *_map_, size_t *key, size_t *value);
size_t hmm_get(struct hashmultimap *_map_, size_t key);
size_t *hmm_get_ref(struct hashmultimap *_map_, size_t key);
_Bool hmm_contains(struct hashmultimap *_map_, size_t key);
_Bool hmm_empty(struct hashmultimap *_map_);
_Bool hmm_full(struct hashmultimap *_map_);
size_t hmm_count(struct hashmultimap *_map_);
size_t hmm_key_count(struct hashmultimap *_map_, size_t key);
size_t hmm_capacity(struct hashmultimap *_map_);
double hmm_load(struct hashmultimap *_map_);
int hmm_flag(struct hashmultimap *_map_);
_Bool hmm_resize(struct hashmultimap *_map_, size_t capacity);
struct hashmultimap *hmm_copy_of(struct hashmultimap *_map_);
_Bool hmm_equals(struct hashmultimap *_map1_, struct hashmultimap *_map2_);
struct hashmultimap_iter
{
struct hashmultimap *target;
struct hashmultimap_entry *curr_entry;
size_t cursor;
size_t index;
size_t first;
size_t last;
_Bool start;
_Bool end;
};
struct hashmultimap_iter hmm_iter_start(struct hashmultimap *target);
struct hashmultimap_iter hmm_iter_end(struct hashmultimap *target);
_Bool hmm_iter_at_start(struct hashmultimap_iter *iter);
_Bool hmm_iter_at_end(struct hashmultimap_iter *iter);
_Bool hmm_iter_to_start(struct hashmultimap_iter *iter);
_Bool hmm_iter_to_end(struct hashmultimap_iter *iter);
_Bool hmm_iter_next(struct hashmultimap_iter *iter);
_Bool hmm_iter_prev(struct hashmultimap_iter *iter);
_Bool hmm_iter_advance(struct hashmultimap_iter *iter, size_t steps);
_Bool hmm_iter_rewind(struct hashmultimap_iter *iter, size_t steps);
_Bool hmm_iter_go_to(struct hashmultimap_iter *iter, size_t index);
size_t hmm_iter_key(struct hashmultimap_iter *iter);
size_t hmm_iter_value(struct hashmultimap_iter *iter);
size_t *hmm_iter_rvalue(struct hashmultimap_iter *iter);
size_t hmm_iter_index(struct hashmultimap_iter *iter);
_Bool hmm_to_string(struct hashmultimap *_map_, FILE *fptr);
_Bool hmm_print(struct hashmultimap *_map_, FILE *fptr, const char *start, const char *separator, const char *end,
const char *key_val_sep);
#endif /* CMC_CMC_HASHMULTIMAP_TEST_H */
+98
View File
@@ -0,0 +1,98 @@
#ifndef CMC_CMC_HASHMULTISET_TEST_H
#define CMC_CMC_HASHMULTISET_TEST_H
#include "macro_collections.h"
struct hashmultiset
{
struct hashmultiset_entry *buffer;
size_t capacity;
size_t count;
size_t cardinality;
double load;
int flag;
struct hashmultiset_fval *f_val;
struct cmc_alloc_node *alloc;
struct cmc_callbacks *callbacks;
};
struct hashmultiset_entry
{
size_t value;
size_t multiplicity;
size_t dist;
enum cmc_entry_state state;
};
struct hashmultiset_fval
{
int (*cmp)(size_t, size_t);
size_t (*cpy)(size_t);
_Bool (*str)(FILE *, size_t);
void (*free)(size_t);
size_t (*hash)(size_t);
int (*pri)(size_t, size_t);
};
struct hashmultiset *hms_new(size_t capacity, double load, struct hashmultiset_fval *f_val);
struct hashmultiset *hms_new_custom(size_t capacity, double load, struct hashmultiset_fval *f_val,
struct cmc_alloc_node *alloc, struct cmc_callbacks *callbacks);
void hms_clear(struct hashmultiset *_set_);
void hms_free(struct hashmultiset *_set_);
void hms_customize(struct hashmultiset *_set_, struct cmc_alloc_node *alloc, struct cmc_callbacks *callbacks);
_Bool hms_insert(struct hashmultiset *_set_, size_t value);
_Bool hms_insert_many(struct hashmultiset *_set_, size_t value, size_t count);
_Bool hms_update(struct hashmultiset *_set_, size_t value, size_t multiplicity);
_Bool hms_remove(struct hashmultiset *_set_, size_t value);
size_t hms_remove_all(struct hashmultiset *_set_, size_t value);
_Bool hms_max(struct hashmultiset *_set_, size_t *value);
_Bool hms_min(struct hashmultiset *_set_, size_t *value);
size_t hms_multiplicity_of(struct hashmultiset *_set_, size_t value);
_Bool hms_contains(struct hashmultiset *_set_, size_t value);
_Bool hms_empty(struct hashmultiset *_set_);
_Bool hms_full(struct hashmultiset *_set_);
size_t hms_count(struct hashmultiset *_set_);
size_t hms_cardinality(struct hashmultiset *_set_);
size_t hms_capacity(struct hashmultiset *_set_);
double hms_load(struct hashmultiset *_set_);
int hms_flag(struct hashmultiset *_set_);
_Bool hms_resize(struct hashmultiset *_set_, size_t capacity);
struct hashmultiset *hms_copy_of(struct hashmultiset *_set_);
_Bool hms_equals(struct hashmultiset *_set1_, struct hashmultiset *_set2_);
struct hashmultiset_iter
{
struct hashmultiset *target;
size_t cursor;
size_t index;
size_t first;
size_t last;
_Bool start;
_Bool end;
};
struct hashmultiset_iter hms_iter_start(struct hashmultiset *target);
struct hashmultiset_iter hms_iter_end(struct hashmultiset *target);
_Bool hms_iter_at_start(struct hashmultiset_iter *iter);
_Bool hms_iter_at_end(struct hashmultiset_iter *iter);
_Bool hms_iter_to_start(struct hashmultiset_iter *iter);
_Bool hms_iter_to_end(struct hashmultiset_iter *iter);
_Bool hms_iter_next(struct hashmultiset_iter *iter);
_Bool hms_iter_prev(struct hashmultiset_iter *iter);
_Bool hms_iter_advance(struct hashmultiset_iter *iter, size_t steps);
_Bool hms_iter_rewind(struct hashmultiset_iter *iter, size_t steps);
_Bool hms_iter_go_to(struct hashmultiset_iter *iter, size_t index);
size_t hms_iter_value(struct hashmultiset_iter *iter);
size_t hms_iter_multiplicity(struct hashmultiset_iter *iter);
size_t hms_iter_index(struct hashmultiset_iter *iter);
struct hashmultiset *hms_union(struct hashmultiset *_set1_, struct hashmultiset *_set2_);
struct hashmultiset *hms_intersection(struct hashmultiset *_set1_, struct hashmultiset *_set2_);
struct hashmultiset *hms_difference(struct hashmultiset *_set1_, struct hashmultiset *_set2_);
struct hashmultiset *hms_summation(struct hashmultiset *_set1_, struct hashmultiset *_set2_);
struct hashmultiset *hms_symmetric_difference(struct hashmultiset *_set1_, struct hashmultiset *_set2_);
_Bool hms_is_subset(struct hashmultiset *_set1_, struct hashmultiset *_set2_);
_Bool hms_is_superset(struct hashmultiset *_set1_, struct hashmultiset *_set2_);
_Bool hms_is_proper_subset(struct hashmultiset *_set1_, struct hashmultiset *_set2_);
_Bool hms_is_proper_superset(struct hashmultiset *_set1_, struct hashmultiset *_set2_);
_Bool hms_is_disjointset(struct hashmultiset *_set1_, struct hashmultiset *_set2_);
_Bool hms_to_string(struct hashmultiset *_set_, FILE *fptr);
_Bool hms_print(struct hashmultiset *_set_, FILE *fptr, const char *start, const char *separator, const char *end,
const char *key_val_sep);
#endif /* CMC_CMC_HASHMULTISET_TEST_H */
+88
View File
@@ -0,0 +1,88 @@
#ifndef CMC_CMC_HASHSET_TEST_H
#define CMC_CMC_HASHSET_TEST_H
#include "macro_collections.h"
struct hashset
{
struct hashset_entry *buffer;
size_t capacity;
size_t count;
double load;
int flag;
struct hashset_fval *f_val;
struct cmc_alloc_node *alloc;
struct cmc_callbacks *callbacks;
};
struct hashset_entry
{
size_t value;
size_t dist;
enum cmc_entry_state state;
};
struct hashset_fval
{
int (*cmp)(size_t, size_t);
size_t (*cpy)(size_t);
_Bool (*str)(FILE *, size_t);
void (*free)(size_t);
size_t (*hash)(size_t);
int (*pri)(size_t, size_t);
};
struct hashset *hs_new(size_t capacity, double load, struct hashset_fval *f_val);
struct hashset *hs_new_custom(size_t capacity, double load, struct hashset_fval *f_val, struct cmc_alloc_node *alloc,
struct cmc_callbacks *callbacks);
void hs_clear(struct hashset *_set_);
void hs_free(struct hashset *_set_);
void hs_customize(struct hashset *_set_, struct cmc_alloc_node *alloc, struct cmc_callbacks *callbacks);
_Bool hs_insert(struct hashset *_set_, size_t value);
_Bool hs_remove(struct hashset *_set_, size_t value);
_Bool hs_max(struct hashset *_set_, size_t *value);
_Bool hs_min(struct hashset *_set_, size_t *value);
_Bool hs_contains(struct hashset *_set_, size_t value);
_Bool hs_empty(struct hashset *_set_);
_Bool hs_full(struct hashset *_set_);
size_t hs_count(struct hashset *_set_);
size_t hs_capacity(struct hashset *_set_);
double hs_load(struct hashset *_set_);
int hs_flag(struct hashset *_set_);
_Bool hs_resize(struct hashset *_set_, size_t capacity);
struct hashset *hs_copy_of(struct hashset *_set_);
_Bool hs_equals(struct hashset *_set1_, struct hashset *_set2_);
struct hashset_iter
{
struct hashset *target;
size_t cursor;
size_t index;
size_t first;
size_t last;
_Bool start;
_Bool end;
};
struct hashset_iter hs_iter_start(struct hashset *target);
struct hashset_iter hs_iter_end(struct hashset *target);
_Bool hs_iter_at_start(struct hashset_iter *iter);
_Bool hs_iter_at_end(struct hashset_iter *iter);
_Bool hs_iter_to_start(struct hashset_iter *iter);
_Bool hs_iter_to_end(struct hashset_iter *iter);
_Bool hs_iter_next(struct hashset_iter *iter);
_Bool hs_iter_prev(struct hashset_iter *iter);
_Bool hs_iter_advance(struct hashset_iter *iter, size_t steps);
_Bool hs_iter_rewind(struct hashset_iter *iter, size_t steps);
_Bool hs_iter_go_to(struct hashset_iter *iter, size_t index);
size_t hs_iter_value(struct hashset_iter *iter);
size_t hs_iter_index(struct hashset_iter *iter);
struct hashset *hs_union(struct hashset *_set1_, struct hashset *_set2_);
struct hashset *hs_intersection(struct hashset *_set1_, struct hashset *_set2_);
struct hashset *hs_difference(struct hashset *_set1_, struct hashset *_set2_);
struct hashset *hs_symmetric_difference(struct hashset *_set1_, struct hashset *_set2_);
_Bool hs_is_subset(struct hashset *_set1_, struct hashset *_set2_);
_Bool hs_is_superset(struct hashset *_set1_, struct hashset *_set2_);
_Bool hs_is_proper_subset(struct hashset *_set1_, struct hashset *_set2_);
_Bool hs_is_proper_superset(struct hashset *_set1_, struct hashset *_set2_);
_Bool hs_is_disjointset(struct hashset *_set1_, struct hashset *_set2_);
_Bool hs_to_string(struct hashset *_set_, FILE *fptr);
_Bool hs_print(struct hashset *_set_, FILE *fptr, const char *start, const char *separator, const char *end);
#endif /* CMC_CMC_HASHSET_TEST_H */
+68
View File
@@ -0,0 +1,68 @@
#ifndef CMC_CMC_HEAP_TEST_H
#define CMC_CMC_HEAP_TEST_H
#include "macro_collections.h"
struct heap
{
size_t *buffer;
size_t capacity;
size_t count;
enum cmc_heap_order HO;
int flag;
struct heap_fval *f_val;
struct cmc_alloc_node *alloc;
struct cmc_callbacks *callbacks;
};
struct heap_fval
{
int (*cmp)(size_t, size_t);
size_t (*cpy)(size_t);
_Bool (*str)(FILE *, size_t);
void (*free)(size_t);
size_t (*hash)(size_t);
int (*pri)(size_t, size_t);
};
struct heap *h_new(size_t capacity, enum cmc_heap_order HO, struct heap_fval *f_val);
struct heap *h_new_custom(size_t capacity, enum cmc_heap_order HO, 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_);
void h_customize(struct heap *_heap_, struct cmc_alloc_node *alloc, struct cmc_callbacks *callbacks);
_Bool h_insert(struct heap *_heap_, size_t value);
_Bool h_remove(struct heap *_heap_);
size_t h_peek(struct heap *_heap_);
_Bool h_contains(struct heap *_heap_, size_t value);
_Bool h_empty(struct heap *_heap_);
_Bool h_full(struct heap *_heap_);
size_t h_count(struct heap *_heap_);
size_t h_capacity(struct heap *_heap_);
int h_flag(struct heap *_heap_);
_Bool h_resize(struct heap *_heap_, size_t capacity);
struct heap *h_copy_of(struct heap *_heap_);
_Bool h_equals(struct heap *_heap1_, struct heap *_heap2_);
struct heap_iter
{
struct heap *target;
size_t cursor;
_Bool start;
_Bool end;
};
struct heap_iter h_iter_start(struct heap *target);
struct heap_iter h_iter_end(struct heap *target);
_Bool h_iter_at_start(struct heap_iter *iter);
_Bool h_iter_at_end(struct heap_iter *iter);
_Bool h_iter_to_start(struct heap_iter *iter);
_Bool h_iter_to_end(struct heap_iter *iter);
_Bool h_iter_next(struct heap_iter *iter);
_Bool h_iter_prev(struct heap_iter *iter);
_Bool h_iter_advance(struct heap_iter *iter, size_t steps);
_Bool h_iter_rewind(struct heap_iter *iter, size_t steps);
_Bool h_iter_go_to(struct heap_iter *iter, size_t index);
size_t h_iter_value(struct heap_iter *iter);
size_t h_iter_index(struct heap_iter *iter);
_Bool h_to_string(struct heap *_heap_, FILE *fptr);
_Bool h_print(struct heap *_heap_, FILE *fptr, const char *start, const char *separator, const char *end);
#endif /* CMC_CMC_HEAP_TEST_H */
+72
View File
@@ -0,0 +1,72 @@
#ifndef CMC_CMC_INTERVALHEAP_TEST_H
#define CMC_CMC_INTERVALHEAP_TEST_H
#include "macro_collections.h"
struct intervalheap
{
size_t (*buffer)[2];
size_t capacity;
size_t size;
size_t count;
int flag;
struct intervalheap_fval *f_val;
struct cmc_alloc_node *alloc;
struct cmc_callbacks *callbacks;
};
struct intervalheap_fval
{
int (*cmp)(size_t, size_t);
size_t (*cpy)(size_t);
_Bool (*str)(FILE *, size_t);
void (*free)(size_t);
size_t (*hash)(size_t);
int (*pri)(size_t, size_t);
};
struct intervalheap *ih_new(size_t capacity, struct intervalheap_fval *f_val);
struct intervalheap *ih_new_custom(size_t capacity, struct intervalheap_fval *f_val, struct cmc_alloc_node *alloc,
struct cmc_callbacks *callbacks);
void ih_clear(struct intervalheap *_heap_);
void ih_free(struct intervalheap *_heap_);
void ih_customize(struct intervalheap *_heap_, struct cmc_alloc_node *alloc, struct cmc_callbacks *callbacks);
_Bool ih_insert(struct intervalheap *_heap_, size_t value);
_Bool ih_remove_max(struct intervalheap *_heap_);
_Bool ih_remove_min(struct intervalheap *_heap_);
_Bool ih_update_max(struct intervalheap *_heap_, size_t value);
_Bool ih_update_min(struct intervalheap *_heap_, size_t value);
size_t ih_max(struct intervalheap *_heap_);
size_t ih_min(struct intervalheap *_heap_);
_Bool ih_contains(struct intervalheap *_heap_, size_t value);
_Bool ih_empty(struct intervalheap *_heap_);
_Bool ih_full(struct intervalheap *_heap_);
size_t ih_count(struct intervalheap *_heap_);
size_t ih_capacity(struct intervalheap *_heap_);
int ih_flag(struct intervalheap *_heap_);
_Bool ih_resize(struct intervalheap *_heap_, size_t capacity);
struct intervalheap *ih_copy_of(struct intervalheap *_heap_);
_Bool ih_equals(struct intervalheap *_heap1_, struct intervalheap *_heap2_);
struct intervalheap_iter
{
struct intervalheap *target;
size_t cursor;
_Bool start;
_Bool end;
};
struct intervalheap_iter ih_iter_start(struct intervalheap *target);
struct intervalheap_iter ih_iter_end(struct intervalheap *target);
_Bool ih_iter_at_start(struct intervalheap_iter *iter);
_Bool ih_iter_at_end(struct intervalheap_iter *iter);
_Bool ih_iter_to_start(struct intervalheap_iter *iter);
_Bool ih_iter_to_end(struct intervalheap_iter *iter);
_Bool ih_iter_next(struct intervalheap_iter *iter);
_Bool ih_iter_prev(struct intervalheap_iter *iter);
_Bool ih_iter_advance(struct intervalheap_iter *iter, size_t steps);
_Bool ih_iter_rewind(struct intervalheap_iter *iter, size_t steps);
_Bool ih_iter_go_to(struct intervalheap_iter *iter, size_t index);
size_t ih_iter_value(struct intervalheap_iter *iter);
size_t ih_iter_index(struct intervalheap_iter *iter);
_Bool ih_to_string(struct intervalheap *_heap_, FILE *fptr);
_Bool ih_print(struct intervalheap *_heap_, FILE *fptr, const char *start, const char *separator, const char *end);
#endif /* CMC_CMC_INTERVALHEAP_TEST_H */
+92
View File
@@ -0,0 +1,92 @@
#ifndef CMC_CMC_LINKEDLIST_TEST_H
#define CMC_CMC_LINKEDLIST_TEST_H
#include "macro_collections.h"
struct linkedlist
{
struct linkedlist_node *head;
struct linkedlist_node *tail;
size_t count;
int flag;
struct linkedlist_fval *f_val;
struct cmc_alloc_node *alloc;
struct cmc_callbacks *callbacks;
};
struct linkedlist_node
{
size_t value;
struct linkedlist_node *next;
struct linkedlist_node *prev;
};
struct linkedlist_fval
{
int (*cmp)(size_t, size_t);
size_t (*cpy)(size_t);
_Bool (*str)(FILE *, size_t);
void (*free)(size_t);
size_t (*hash)(size_t);
int (*pri)(size_t, size_t);
};
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_);
void ll_free(struct linkedlist *_list_);
void ll_customize(struct linkedlist *_list_, struct cmc_alloc_node *alloc, struct cmc_callbacks *callbacks);
_Bool ll_push_front(struct linkedlist *_list_, size_t value);
_Bool ll_push_at(struct linkedlist *_list_, size_t value, size_t index);
_Bool ll_push_back(struct linkedlist *_list_, size_t value);
_Bool ll_pop_front(struct linkedlist *_list_);
_Bool ll_pop_at(struct linkedlist *_list_, size_t index);
_Bool ll_pop_back(struct linkedlist *_list_);
size_t ll_front(struct linkedlist *_list_);
size_t ll_get(struct linkedlist *_list_, size_t index);
size_t *ll_get_ref(struct linkedlist *_list_, size_t index);
size_t ll_back(struct linkedlist *_list_);
_Bool ll_contains(struct linkedlist *_list_, size_t value);
_Bool ll_empty(struct linkedlist *_list_);
size_t ll_count(struct linkedlist *_list_);
int ll_flag(struct linkedlist *_list_);
struct linkedlist *ll_copy_of(struct linkedlist *_list_);
_Bool ll_equals(struct linkedlist *_list1_, struct linkedlist *_list2_);
struct linkedlist_iter
{
struct linkedlist *target;
struct linkedlist_node *cursor;
size_t index;
_Bool start;
_Bool end;
};
struct linkedlist_iter ll_iter_start(struct linkedlist *target);
struct linkedlist_iter ll_iter_end(struct linkedlist *target);
_Bool ll_iter_at_start(struct linkedlist_iter *iter);
_Bool ll_iter_at_end(struct linkedlist_iter *iter);
_Bool ll_iter_to_start(struct linkedlist_iter *iter);
_Bool ll_iter_to_end(struct linkedlist_iter *iter);
_Bool ll_iter_next(struct linkedlist_iter *iter);
_Bool ll_iter_prev(struct linkedlist_iter *iter);
_Bool ll_iter_advance(struct linkedlist_iter *iter, size_t steps);
_Bool ll_iter_rewind(struct linkedlist_iter *iter, size_t steps);
_Bool ll_iter_go_to(struct linkedlist_iter *iter, size_t index);
size_t ll_iter_value(struct linkedlist_iter *iter);
size_t *ll_iter_rvalue(struct linkedlist_iter *iter);
size_t ll_iter_index(struct linkedlist_iter *iter);
struct linkedlist_node *ll_iter_node(struct linkedlist_iter *iter);
struct linkedlist_node *ll_new_node(struct linkedlist *_list_, size_t value);
void ll_free_node(struct linkedlist *_list_, struct linkedlist_node *_node_);
struct linkedlist_node *ll_head(struct linkedlist *_list_);
struct linkedlist_node *ll_get_node(struct linkedlist *_list_, size_t index);
struct linkedlist_node *ll_tail(struct linkedlist *_list_);
_Bool ll_add_next(struct linkedlist *_owner_, struct linkedlist_node *_node_, size_t value);
_Bool ll_add_prev(struct linkedlist *_owner_, struct linkedlist_node *_node_, size_t value);
_Bool ll_del_next(struct linkedlist *_owner_, struct linkedlist_node *_node_);
_Bool ll_del_curr(struct linkedlist *_owner_, struct linkedlist_node *_node_);
_Bool ll_del_prev(struct linkedlist *_owner_, struct linkedlist_node *_node_);
struct linkedlist_node *ll_next_node(struct linkedlist_node *_node_);
struct linkedlist_node *ll_prev_node(struct linkedlist_node *_node_);
_Bool ll_to_string(struct linkedlist *_list_, FILE *fptr);
_Bool ll_print(struct linkedlist *_list_, FILE *fptr, const char *start, const char *separator, const char *end);
#endif /* CMC_CMC_LINKEDLIST_TEST_H */
+82
View File
@@ -0,0 +1,82 @@
#ifndef CMC_CMC_LIST_TEST_H
#define CMC_CMC_LIST_TEST_H
#include "macro_collections.h"
struct list
{
size_t *buffer;
size_t capacity;
size_t count;
int flag;
struct list_fval *f_val;
struct cmc_alloc_node *alloc;
struct cmc_callbacks *callbacks;
};
struct list_fval
{
int (*cmp)(size_t, size_t);
size_t (*cpy)(size_t);
_Bool (*str)(FILE *, size_t);
void (*free)(size_t);
size_t (*hash)(size_t);
int (*pri)(size_t, size_t);
};
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_);
void l_free(struct list *_list_);
void l_customize(struct list *_list_, struct cmc_alloc_node *alloc, struct cmc_callbacks *callbacks);
_Bool l_push_front(struct list *_list_, size_t value);
_Bool l_push_at(struct list *_list_, size_t value, size_t index);
_Bool l_push_back(struct list *_list_, size_t value);
_Bool l_pop_front(struct list *_list_);
_Bool l_pop_at(struct list *_list_, size_t index);
_Bool l_pop_back(struct list *_list_);
size_t l_front(struct list *_list_);
size_t l_get(struct list *_list_, size_t index);
size_t *l_get_ref(struct list *_list_, size_t index);
size_t l_back(struct list *_list_);
size_t l_index_of(struct list *_list_, size_t value, _Bool from_start);
_Bool l_contains(struct list *_list_, size_t value);
_Bool l_empty(struct list *_list_);
_Bool l_full(struct list *_list_);
size_t l_count(struct list *_list_);
_Bool l_fits(struct list *_list_, size_t size);
size_t l_capacity(struct list *_list_);
int l_flag(struct list *_list_);
_Bool l_resize(struct list *_list_, size_t capacity);
struct list *l_copy_of(struct list *_list_);
_Bool l_equals(struct list *_list1_, struct list *_list2_);
struct list_iter
{
struct list *target;
size_t cursor;
_Bool start;
_Bool end;
};
struct list_iter l_iter_start(struct list *target);
struct list_iter l_iter_end(struct list *target);
_Bool l_iter_at_start(struct list_iter *iter);
_Bool l_iter_at_end(struct list_iter *iter);
_Bool l_iter_to_start(struct list_iter *iter);
_Bool l_iter_to_end(struct list_iter *iter);
_Bool l_iter_next(struct list_iter *iter);
_Bool l_iter_prev(struct list_iter *iter);
_Bool l_iter_advance(struct list_iter *iter, size_t steps);
_Bool l_iter_rewind(struct list_iter *iter, size_t steps);
_Bool l_iter_go_to(struct list_iter *iter, size_t index);
size_t l_iter_value(struct list_iter *iter);
size_t *l_iter_rvalue(struct list_iter *iter);
size_t l_iter_index(struct list_iter *iter);
_Bool l_seq_push_front(struct list *_list_, size_t *values, size_t size);
_Bool l_seq_push_at(struct list *_list_, size_t *values, size_t size, size_t index);
_Bool l_seq_push_back(struct list *_list_, size_t *values, size_t size);
_Bool l_seq_pop_at(struct list *_list_, size_t from, size_t to);
struct list *l_seq_sublist(struct list *_list_, size_t from, size_t to);
_Bool l_to_string(struct list *_list_, FILE *fptr);
_Bool l_print(struct list *_list_, FILE *fptr, const char *start, const char *separator, const char *end);
#endif /* CMC_CMC_LIST_TEST_H */
+71
View File
@@ -0,0 +1,71 @@
#ifndef CMC_CMC_QUEUE_TEST_H
#define CMC_CMC_QUEUE_TEST_H
#include "macro_collections.h"
struct queue
{
size_t *buffer;
size_t capacity;
size_t count;
size_t front;
size_t back;
int flag;
struct queue_fval *f_val;
struct cmc_alloc_node *alloc;
struct cmc_callbacks *callbacks;
};
struct queue_fval
{
int (*cmp)(size_t, size_t);
size_t (*cpy)(size_t);
_Bool (*str)(FILE *, size_t);
void (*free)(size_t);
size_t (*hash)(size_t);
int (*pri)(size_t, size_t);
};
struct queue_iter
{
struct queue *target;
size_t cursor;
size_t index;
_Bool start;
_Bool end;
};
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_);
void q_free(struct queue *_queue_);
void q_customize(struct queue *_queue_, struct cmc_alloc_node *alloc, struct cmc_callbacks *callbacks);
_Bool q_enqueue(struct queue *_queue_, size_t value);
_Bool q_dequeue(struct queue *_queue_);
size_t q_peek(struct queue *_queue_);
_Bool q_contains(struct queue *_queue_, size_t value);
_Bool q_empty(struct queue *_queue_);
_Bool q_full(struct queue *_queue_);
size_t q_count(struct queue *_queue_);
size_t q_capacity(struct queue *_queue_);
int q_flag(struct queue *_queue_);
_Bool q_resize(struct queue *_queue_, size_t capacity);
struct queue *q_copy_of(struct queue *_queue_);
_Bool q_equals(struct queue *_queue1_, struct queue *_queue2_);
struct queue_iter q_iter_start(struct queue *target);
struct queue_iter q_iter_end(struct queue *target);
_Bool q_iter_at_start(struct queue_iter *iter);
_Bool q_iter_at_end(struct queue_iter *iter);
_Bool q_iter_to_start(struct queue_iter *iter);
_Bool q_iter_to_end(struct queue_iter *iter);
_Bool q_iter_next(struct queue_iter *iter);
_Bool q_iter_prev(struct queue_iter *iter);
_Bool q_iter_advance(struct queue_iter *iter, size_t steps);
_Bool q_iter_rewind(struct queue_iter *iter, size_t steps);
_Bool q_iter_go_to(struct queue_iter *iter, size_t index);
size_t q_iter_value(struct queue_iter *iter);
size_t *q_iter_rvalue(struct queue_iter *iter);
size_t q_iter_index(struct queue_iter *iter);
_Bool q_to_string(struct queue *_queue_, FILE *fptr);
_Bool q_print(struct queue *_queue_, FILE *fptr, const char *start, const char *separator, const char *end);
#endif /* CMC_CMC_QUEUE_TEST_H */
+72
View File
@@ -0,0 +1,72 @@
#ifndef CMC_CMC_SORTEDLIST_TEST_H
#define CMC_CMC_SORTEDLIST_TEST_H
#include "macro_collections.h"
struct sortedlist
{
size_t *buffer;
size_t capacity;
size_t count;
_Bool is_sorted;
int flag;
struct sortedlist_fval *f_val;
struct cmc_alloc_node *alloc;
struct cmc_callbacks *callbacks;
};
struct sortedlist_fval
{
int (*cmp)(size_t, size_t);
size_t (*cpy)(size_t);
_Bool (*str)(FILE *, size_t);
void (*free)(size_t);
size_t (*hash)(size_t);
int (*pri)(size_t, size_t);
};
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_);
void sl_free(struct sortedlist *_list_);
void sl_customize(struct sortedlist *_list_, struct cmc_alloc_node *alloc, struct cmc_callbacks *callbacks);
_Bool sl_insert(struct sortedlist *_list_, size_t value);
_Bool sl_remove(struct sortedlist *_list_, size_t index);
size_t sl_max(struct sortedlist *_list_);
size_t sl_min(struct sortedlist *_list_);
size_t sl_get(struct sortedlist *_list_, size_t index);
size_t sl_index_of(struct sortedlist *_list_, size_t value, _Bool from_start);
_Bool sl_contains(struct sortedlist *_list_, size_t value);
_Bool sl_empty(struct sortedlist *_list_);
_Bool sl_full(struct sortedlist *_list_);
size_t sl_count(struct sortedlist *_list_);
size_t sl_capacity(struct sortedlist *_list_);
int sl_flag(struct sortedlist *_list_);
_Bool sl_resize(struct sortedlist *_list_, size_t capacity);
void sl_sort(struct sortedlist *_list_);
struct sortedlist *sl_copy_of(struct sortedlist *_list_);
_Bool sl_equals(struct sortedlist *_list1_, struct sortedlist *_list2_);
struct sortedlist_iter
{
struct sortedlist *target;
size_t cursor;
_Bool start;
_Bool end;
};
struct sortedlist_iter sl_iter_start(struct sortedlist *target);
struct sortedlist_iter sl_iter_end(struct sortedlist *target);
_Bool sl_iter_at_start(struct sortedlist_iter *iter);
_Bool sl_iter_at_end(struct sortedlist_iter *iter);
_Bool sl_iter_to_start(struct sortedlist_iter *iter);
_Bool sl_iter_to_end(struct sortedlist_iter *iter);
_Bool sl_iter_next(struct sortedlist_iter *iter);
_Bool sl_iter_prev(struct sortedlist_iter *iter);
_Bool sl_iter_advance(struct sortedlist_iter *iter, size_t steps);
_Bool sl_iter_rewind(struct sortedlist_iter *iter, size_t steps);
_Bool sl_iter_go_to(struct sortedlist_iter *iter, size_t index);
size_t sl_iter_value(struct sortedlist_iter *iter);
size_t sl_iter_index(struct sortedlist_iter *iter);
_Bool sl_to_string(struct sortedlist *_list_, FILE *fptr);
_Bool sl_print(struct sortedlist *_list_, FILE *fptr, const char *start, const char *separator, const char *end);
#endif /* CMC_CMC_SORTEDLIST_TEST_H */
+68
View File
@@ -0,0 +1,68 @@
#ifndef CMC_CMC_STACK_TEST_H
#define CMC_CMC_STACK_TEST_H
#include "macro_collections.h"
struct stack
{
size_t *buffer;
size_t capacity;
size_t count;
int flag;
struct stack_fval *f_val;
struct cmc_alloc_node *alloc;
struct cmc_callbacks *callbacks;
};
struct stack_fval
{
int (*cmp)(size_t, size_t);
size_t (*cpy)(size_t);
_Bool (*str)(FILE *, size_t);
void (*free)(size_t);
size_t (*hash)(size_t);
int (*pri)(size_t, size_t);
};
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_);
void s_free(struct stack *_stack_);
void s_customize(struct stack *_stack_, struct cmc_alloc_node *alloc, struct cmc_callbacks *callbacks);
_Bool s_push(struct stack *_stack_, size_t value);
_Bool s_pop(struct stack *_stack_);
size_t s_top(struct stack *_stack_);
_Bool s_contains(struct stack *_stack_, size_t value);
_Bool s_empty(struct stack *_stack_);
_Bool s_full(struct stack *_stack_);
size_t s_count(struct stack *_stack_);
size_t s_capacity(struct stack *_stack_);
int s_flag(struct stack *_stack_);
_Bool s_resize(struct stack *_stack_, size_t capacity);
struct stack *s_copy_of(struct stack *_stack_);
_Bool s_equals(struct stack *_stack1_, struct stack *_stack2_);
struct stack_iter
{
struct stack *target;
size_t cursor;
_Bool start;
_Bool end;
};
struct stack_iter s_iter_start(struct stack *target);
struct stack_iter s_iter_end(struct stack *target);
_Bool s_iter_at_start(struct stack_iter *iter);
_Bool s_iter_at_end(struct stack_iter *iter);
_Bool s_iter_to_start(struct stack_iter *iter);
_Bool s_iter_to_end(struct stack_iter *iter);
_Bool s_iter_next(struct stack_iter *iter);
_Bool s_iter_prev(struct stack_iter *iter);
_Bool s_iter_advance(struct stack_iter *iter, size_t steps);
_Bool s_iter_rewind(struct stack_iter *iter, size_t steps);
_Bool s_iter_go_to(struct stack_iter *iter, size_t index);
size_t s_iter_value(struct stack_iter *iter);
size_t *s_iter_rvalue(struct stack_iter *iter);
size_t s_iter_index(struct stack_iter *iter);
_Bool s_to_string(struct stack *_stack_, FILE *fptr);
_Bool s_print(struct stack *_stack_, FILE *fptr, const char *start, const char *separator, const char *end);
#endif /* CMC_CMC_STACK_TEST_H */
+92
View File
@@ -0,0 +1,92 @@
#ifndef CMC_CMC_TREEMAP_TEST_H
#define CMC_CMC_TREEMAP_TEST_H
#include "macro_collections.h"
struct treemap
{
struct treemap_node *root;
size_t count;
int flag;
struct treemap_fkey *f_key;
struct treemap_fval *f_val;
struct cmc_alloc_node *alloc;
struct cmc_callbacks *callbacks;
};
struct treemap_node
{
size_t key;
size_t value;
unsigned char height;
struct treemap_node *right;
struct treemap_node *left;
struct treemap_node *parent;
};
struct treemap_fkey
{
int (*cmp)(size_t, size_t);
size_t (*cpy)(size_t);
_Bool (*str)(FILE *, size_t);
void (*free)(size_t);
size_t (*hash)(size_t);
int (*pri)(size_t, size_t);
};
struct treemap_fval
{
int (*cmp)(size_t, size_t);
size_t (*cpy)(size_t);
_Bool (*str)(FILE *, size_t);
void (*free)(size_t);
size_t (*hash)(size_t);
int (*pri)(size_t, size_t);
};
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_);
void tm_free(struct treemap *_map_);
void tm_customize(struct treemap *_map_, struct cmc_alloc_node *alloc, struct cmc_callbacks *callbacks);
_Bool tm_insert(struct treemap *_map_, size_t key, size_t value);
_Bool tm_update(struct treemap *_map_, size_t key, size_t new_value, size_t *old_value);
_Bool tm_remove(struct treemap *_map_, size_t key, size_t *out_value);
_Bool tm_max(struct treemap *_map_, size_t *key, size_t *value);
_Bool tm_min(struct treemap *_map_, size_t *key, size_t *value);
size_t tm_get(struct treemap *_map_, size_t key);
size_t *tm_get_ref(struct treemap *_map_, size_t key);
_Bool tm_contains(struct treemap *_map_, size_t key);
_Bool tm_empty(struct treemap *_map_);
size_t tm_count(struct treemap *_map_);
int tm_flag(struct treemap *_map_);
struct treemap *tm_copy_of(struct treemap *_map_);
_Bool tm_equals(struct treemap *_map1_, struct treemap *_map2_);
struct treemap_iter
{
struct treemap *target;
struct treemap_node *cursor;
struct treemap_node *first;
struct treemap_node *last;
size_t index;
_Bool start;
_Bool end;
};
struct treemap_iter tm_iter_start(struct treemap *target);
struct treemap_iter tm_iter_end(struct treemap *target);
_Bool tm_iter_at_start(struct treemap_iter *iter);
_Bool tm_iter_at_end(struct treemap_iter *iter);
_Bool tm_iter_to_start(struct treemap_iter *iter);
_Bool tm_iter_to_end(struct treemap_iter *iter);
_Bool tm_iter_next(struct treemap_iter *iter);
_Bool tm_iter_prev(struct treemap_iter *iter);
_Bool tm_iter_advance(struct treemap_iter *iter, size_t steps);
_Bool tm_iter_rewind(struct treemap_iter *iter, size_t steps);
_Bool tm_iter_go_to(struct treemap_iter *iter, size_t index);
size_t tm_iter_key(struct treemap_iter *iter);
size_t tm_iter_value(struct treemap_iter *iter);
size_t *tm_iter_rvalue(struct treemap_iter *iter);
size_t tm_iter_index(struct treemap_iter *iter);
_Bool tm_to_string(struct treemap *_map_, FILE *fptr);
_Bool tm_print(struct treemap *_map_, FILE *fptr, const char *start, const char *separator, const char *end,
const char *key_val_sep);
#endif /* CMC_CMC_TREEMAP_TEST_H */
+84
View File
@@ -0,0 +1,84 @@
#ifndef CMC_CMC_TREESET_TEST_H
#define CMC_CMC_TREESET_TEST_H
#include "macro_collections.h"
struct treeset
{
struct treeset_node *root;
size_t count;
int flag;
struct treeset_fval *f_val;
struct cmc_alloc_node *alloc;
struct cmc_callbacks *callbacks;
};
struct treeset_node
{
size_t value;
unsigned char height;
struct treeset_node *right;
struct treeset_node *left;
struct treeset_node *parent;
};
struct treeset_fval
{
int (*cmp)(size_t, size_t);
size_t (*cpy)(size_t);
_Bool (*str)(FILE *, size_t);
void (*free)(size_t);
size_t (*hash)(size_t);
int (*pri)(size_t, size_t);
};
struct treeset_iter
{
struct treeset *target;
struct treeset_node *cursor;
struct treeset_node *first;
struct treeset_node *last;
size_t index;
_Bool start;
_Bool end;
};
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_);
void ts_free(struct treeset *_set_);
void ts_customize(struct treeset *_set_, struct cmc_alloc_node *alloc, struct cmc_callbacks *callbacks);
_Bool ts_insert(struct treeset *_set_, size_t value);
_Bool ts_remove(struct treeset *_set_, size_t value);
_Bool ts_max(struct treeset *_set_, size_t *value);
_Bool ts_min(struct treeset *_set_, size_t *value);
_Bool ts_contains(struct treeset *_set_, size_t value);
_Bool ts_empty(struct treeset *_set_);
size_t ts_count(struct treeset *_set_);
int ts_flag(struct treeset *_set_);
struct treeset *ts_copy_of(struct treeset *_set_);
_Bool ts_equals(struct treeset *_set1_, struct treeset *_set2_);
struct treeset *ts_union(struct treeset *_set1_, struct treeset *_set2_);
struct treeset *ts_intersection(struct treeset *_set1_, struct treeset *_set2_);
struct treeset *ts_difference(struct treeset *_set1_, struct treeset *_set2_);
struct treeset *ts_symmetric_difference(struct treeset *_set1_, struct treeset *_set2_);
_Bool ts_is_subset(struct treeset *_set1_, struct treeset *_set2_);
_Bool ts_is_superset(struct treeset *_set1_, struct treeset *_set2_);
_Bool ts_is_proper_subset(struct treeset *_set1_, struct treeset *_set2_);
_Bool ts_is_proper_superset(struct treeset *_set1_, struct treeset *_set2_);
_Bool ts_is_disjointset(struct treeset *_set1_, struct treeset *_set2_);
struct treeset_iter ts_iter_start(struct treeset *target);
struct treeset_iter ts_iter_end(struct treeset *target);
_Bool ts_iter_at_start(struct treeset_iter *iter);
_Bool ts_iter_at_end(struct treeset_iter *iter);
_Bool ts_iter_to_start(struct treeset_iter *iter);
_Bool ts_iter_to_end(struct treeset_iter *iter);
_Bool ts_iter_next(struct treeset_iter *iter);
_Bool ts_iter_prev(struct treeset_iter *iter);
_Bool ts_iter_advance(struct treeset_iter *iter, size_t steps);
_Bool ts_iter_rewind(struct treeset_iter *iter, size_t steps);
_Bool ts_iter_go_to(struct treeset_iter *iter, size_t index);
size_t ts_iter_value(struct treeset_iter *iter);
size_t ts_iter_index(struct treeset_iter *iter);
_Bool ts_to_string(struct treeset *_set_, FILE *fptr);
_Bool ts_print(struct treeset *_set_, FILE *fptr, const char *start, const char *separator, const char *end);
#endif /* CMC_CMC_TREESET_TEST_H */