From 3ee070b4ddd457465641929733fe314f692b55c1 Mon Sep 17 00:00:00 2001 From: Leonardo Date: Sat, 23 Nov 2019 00:38:31 -0300 Subject: [PATCH] Update TODO and added to_string visual test --- TODO | 84 +++++++++++++++++++++++++---------------------- tests/to_string.c | 70 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 115 insertions(+), 39 deletions(-) create mode 100644 tests/to_string.c diff --git a/TODO b/TODO index 6ea008f..2dce90d 100644 --- a/TODO +++ b/TODO @@ -7,27 +7,21 @@ TODO #!! High Priority ---------------------------------------------------------------------------------- [/] Tests -[/] Custom allocators -[ ] Separate each collection unit test into their own executable -[/] Each file needs to be independent without including external files +[/] Documentation +[ ] Add to iterators struct + [ ] get_value + [ ] get_index + [ ] get_rvalue {only those that allow it} + [ ] get_key {associative collections} + [ ] get_multiplicity {multiset} + [ ] get_node {linkedlist} #!! Medium Priority -------------------------------------------------------------------------------- -[ ] Add memory usage in the benchmark [/] Callback utility -[/] Documentation -[/] Add functions - [X] update {hashmap, treemap, multimap} - [X] set {hashmap, treemap, multimap} - [X] to_string {all} - [X] iter_advance {all} (iterators) - [X] iter_rewind {all} (iterators) - [X] iter_go_to {all} (iterators) - [ ] from_array {all} - [ ] to_array {all} - [X] equals {all} - [X] copy_of {all} - [X] resize {array based collections} +[ ] Add memory usage in the benchmark +[ ] Add to_array and from_array functions +[ ] Separate each collection unit test into their own executable #!! Low Priority ----------------------------------------------------------------------------------- @@ -37,22 +31,6 @@ TODO [ ] serialize {all} [ ] deserialize {all} [ ] Zip Iterators -[ ] Statically Allocated Collections - [ ] BidiMap - [ ] Deque - [ ] HashMap - [ ] HashSet - [ ] Heap - [ ] IntervalHeap - [ ] LinkedList - [ ] List - [ ] MultiMap - [ ] MultiSet - [~] Queue - [ ] SortedList - [~] Stack - [ ] TreeMap - [ ] TreeSet [ ] Dev Collections [ ] BidiMap [~] Deque @@ -69,6 +47,22 @@ TODO [ ] Stack [ ] TreeMap [ ] TreeSet +[ ] Statically Allocated Collections + [ ] BidiMap + [ ] Deque + [ ] HashMap + [ ] HashSet + [ ] Heap + [ ] IntervalHeap + [ ] LinkedList + [ ] List + [ ] MultiMap + [ ] MultiSet + [~] Queue + [ ] SortedList + [~] Stack + [ ] TreeMap + [ ] TreeSet #!! Optimizations ---------------------------------------------------------------------------------- @@ -79,15 +73,27 @@ TODO #!! Done ------------------------------------------------------------------------------------------- [X] Remove PUBLIC and PRIVATE -[X] Extra Collections - [X] Add MultiSet - [X] Add MultiMap - [X] Add IntervalHeap - [X] Add SortedList - [X] Add BidiMap [X] Utility [X] assert.h [X] foreach.h [X] log.h [X] test.h [X] timer.h +[X] Extra Collections + [X] Add MultiSet + [X] Add MultiMap + [X] Add IntervalHeap + [X] Add SortedList + [X] Add BidiMap +[X] Add functions + [X] update {hashmap, treemap, multimap} + [X] set {hashmap, treemap, multimap} + [X] to_string {all} + [X] iter_advance {all} (iterators) + [X] iter_rewind {all} (iterators) + [X] iter_go_to {all} (iterators) + [X] equals {all} + [X] copy_of {all} + [X] resize {array based collections} +[X] Custom allocators +[X] Each file needs to be independent without including external files diff --git a/tests/to_string.c b/tests/to_string.c new file mode 100644 index 0000000..a5df4a1 --- /dev/null +++ b/tests/to_string.c @@ -0,0 +1,70 @@ +// A visual check for to_string methods + +#include "../src/macro_collections.h" + +CMC_COLLECTION_GENERATE( BIDIMAP, bm, bmap, int, int) +CMC_COLLECTION_GENERATE( DEQUE, d, deque, /* K */, int) +CMC_COLLECTION_GENERATE( HASHMAP, hm, hmap, int, int) +CMC_COLLECTION_GENERATE( HASHSET, hs, hset, /* K */, int) +CMC_COLLECTION_GENERATE( HEAP, h, heap, /* K */, int) +CMC_COLLECTION_GENERATE(INTERVALHEAP, ih, iheap, /* K */, int) +CMC_COLLECTION_GENERATE( LINKEDLIST, ll, linked, /* K */, int) +CMC_COLLECTION_GENERATE( LIST, l, list, /* K */, int) +CMC_COLLECTION_GENERATE( MULTIMAP, mm, mmap, int, int) +CMC_COLLECTION_GENERATE( MULTISET, ms, mset, /* K */, int) +CMC_COLLECTION_GENERATE( QUEUE, q, queue, /* K */, int) +CMC_COLLECTION_GENERATE( SORTEDLIST, sl, slist, /* K */, int) +CMC_COLLECTION_GENERATE( STACK, s, stack, /* K */, int) +CMC_COLLECTION_GENERATE( TREESET, ts, tset, /* K */, int) +CMC_COLLECTION_GENERATE( TREEMAP, tm, tmap, int, int) + +int main(void) +{ + struct bmap *bm = bm_new_custom(100, 0.7, NULL, NULL, NULL, NULL, NULL, NULL); + struct deque *d = d_new_custom(100, NULL, NULL); + struct hmap *hm = hm_new_custom(100, 0.6, NULL, NULL, NULL, NULL); + struct hset *hs = hs_new_custom(100, 0.6, NULL, NULL, NULL, NULL); + struct heap *h = h_new_custom(100, cmc_max_heap, NULL, NULL, NULL); + struct iheap *ih = ih_new_custom(100, NULL, NULL, NULL); + struct linked *ll = ll_new_custom(NULL, NULL); + struct list *l = l_new_custom(100, NULL, NULL); + struct mmap *mm = mm_new_custom(100, 0.8, NULL, NULL, NULL, NULL); + struct mset *ms = ms_new_custom(100, 0.6, NULL, NULL, NULL, NULL); + struct queue *q = q_new_custom(100, NULL, NULL); + struct slist *sl = sl_new_custom(100, NULL, NULL, NULL); + struct stack *s = s_new_custom(100, NULL, NULL); + struct tmap *tm = tm_new_custom(NULL, NULL, NULL); + struct tset *ts = ts_new_custom(NULL, NULL, NULL); + + printf("%s\n", bm_to_string(bm).s); + printf("%s\n", d_to_string(d).s); + printf("%s\n", hm_to_string(hm).s); + printf("%s\n", hs_to_string(hs).s); + printf("%s\n", h_to_string(h).s); + printf("%s\n", ih_to_string(ih).s); + printf("%s\n", ll_to_string(ll).s); + printf("%s\n", l_to_string(l).s); + printf("%s\n", mm_to_string(mm).s); + printf("%s\n", ms_to_string(ms).s); + printf("%s\n", q_to_string(q).s); + printf("%s\n", sl_to_string(sl).s); + printf("%s\n", s_to_string(s).s); + printf("%s\n", tm_to_string(tm).s); + printf("%s\n", ts_to_string(ts).s); + + bm_free(bm, NULL); + d_free(d, NULL); + hm_free(hm, NULL); + hs_free(hs, NULL); + h_free(h, NULL); + ih_free(ih, NULL); + ll_free(ll, NULL); + l_free(l, NULL); + mm_free(mm, NULL); + ms_free(ms, NULL); + q_free(q, NULL); + sl_free(sl, NULL); + s_free(s, NULL); + tm_free(tm, NULL); + ts_free(ts, NULL); +}