Moving more things to EXT

This commit is contained in:
Leonardo Vencovsky committed 2020-06-03 18:38:49 -03:00
1 parent 97f46b3a81
commit 63eb525406
10 files changed
+1902 -1814

No files matched your search

-20
View File
@@ -477,26 +477,6 @@ _Bool ih_equals(struct intervalheap *_heap1_, struct intervalheap *_heap2_)
}
return 1;
}
struct cmc_string ih_to_string(struct intervalheap *_heap_)
{
struct cmc_string str;
struct intervalheap *h_ = _heap_;
int n = snprintf(str.s, cmc_string_len, cmc_cmc_string_fmt_intervalheap,
"CMC_PARAM_SNAME((ih, intervalheap, , , size_t))",
"CMC_PARAM_V((ih, intervalheap, , , size_t))", h_,
h_->buffer, h_->capacity, h_->size, h_->count, h_->flag,
h_->f_val, h_->alloc, h_->callbacks);
return n >= 0 ? str : (struct cmc_string){ 0 };
}
_Bool ih_print(struct intervalheap *_heap_, FILE *fptr)
{
for (size_t i = 0; i < _heap_->count; i++)
{
if (!_heap_->f_val->str(fptr, _heap_->buffer[i / 2][i % 2]))
return 0;
}
return 1;
}
struct intervalheap_iter ih_iter_start(struct intervalheap *target)
{
struct intervalheap_iter iter;
-22
View File
@@ -446,28 +446,6 @@ _Bool ll_equals(struct linkedlist *_list1_, struct linkedlist *_list2_)
}
return 1;
}
struct cmc_string ll_to_string(struct linkedlist *_list_)
{
struct cmc_string str;
struct linkedlist *l_ = _list_;
int n = snprintf(str.s, cmc_string_len, cmc_cmc_string_fmt_linkedlist,
"CMC_PARAM_SNAME((ll, linkedlist, , , size_t))",
"CMC_PARAM_V((ll, linkedlist, , , size_t))", l_, l_->count,
l_->head, l_->tail, l_->flag, l_->f_val, l_->alloc,
l_->callbacks);
return n >= 0 ? str : (struct cmc_string){ 0 };
}
_Bool ll_print(struct linkedlist *_list_, FILE *fptr)
{
struct linkedlist_node *scan = _list_->head;
while (scan != ((void *)0))
{
if (!_list_->f_val->str(fptr, scan->value))
return 0;
scan = scan->next;
}
return 1;
}
struct linkedlist_node *ll_new_node(struct linkedlist *_list_, size_t value)
{
struct linkedlist_node *_node_ =
+10
View File
@@ -10,6 +10,7 @@ C_MACRO_COLLECTIONS_ALL(CMC, HASHMULTISET, (hms, hashmultiset, , , int))
C_MACRO_COLLECTIONS_ALL(CMC, HASHSET, ( hs, hashset, , , int))
C_MACRO_COLLECTIONS_ALL(CMC, HEAP, ( h, heap, , , int))
C_MACRO_COLLECTIONS_ALL(CMC, INTERVALHEAP, ( ih, intervalheap, , , int))
C_MACRO_COLLECTIONS_ALL(CMC, LINKEDLIST, ( ll, linkedlist, , , int))
struct
{
@@ -35,6 +36,7 @@ int main(void)
(struct hashset_fval *)&int_ftab);
struct heap *h = h_new(100, CMC_MAX_HEAP, (struct heap_fval *)&int_ftab);
struct intervalheap *ih = ih_new(100, (struct intervalheap_fval *)&int_ftab);
struct linkedlist *ll = ll_new((struct linkedlist_fval *)&int_ftab);
d_to_string(d, stdout);
d_print(d, stdout, "\n[ ", ", ", " ]\n");
@@ -50,6 +52,8 @@ int main(void)
h_print(h, stdout, "\n[ ", ", ", " ]\n");
ih_to_string(ih, stdout);
ih_print(ih, stdout, "\n[ ", ", ", " ]\n");
ll_to_string(ll, stdout);
ll_print(ll, stdout, "\n[ ", ", ", " ]\n");
fprintf(stdout, "\n");
@@ -60,6 +64,7 @@ int main(void)
hs_insert(hs, 0);
h_insert(h, 0);
ih_insert(ih, 0);
ll_push_back(ll, 0);
d_to_string(d, stdout);
d_print(d, stdout, "\n[ ", ", ", " ]\n");
@@ -75,6 +80,8 @@ int main(void)
h_print(h, stdout, "\n[ ", ", ", " ]\n");
ih_to_string(ih, stdout);
ih_print(ih, stdout, "\n[ ", ", ", " ]\n");
ll_to_string(ll, stdout);
ll_print(ll, stdout, "\n[ ", ", ", " ]\n");
for (int i = 1; i < 20; i++)
{
@@ -85,6 +92,7 @@ int main(void)
hs_insert(hs, i);
h_insert(h, i);
ih_insert(ih, i);
ll_push_back(ll, i);
}
fprintf(stdout, "\n");
@@ -103,6 +111,8 @@ int main(void)
h_print(h, stdout, "\n[ ", ", ", " ]\n");
ih_to_string(ih, stdout);
ih_print(ih, stdout, "\n[ ", ", ", " ]\n");
ll_to_string(ll, stdout);
ll_print(ll, stdout, "\n[ ", ", ", " ]\n");
d_free(d);
hm_free(hm);