Update examples.
This commit is contained in:
1 parent
f388ed6808
commit
db7af704a6
39 files changed
+278
-169
No files matched your search
@@ -10,7 +10,9 @@
|
||||
#include "cmc/deque.h"
|
||||
#include <stdio.h>
|
||||
|
||||
DEQUE_GENERATE(d, deque, static, int)
|
||||
CMC_GENERATE_DEQUE(d, deque, int);
|
||||
typedef struct deque deque;
|
||||
typedef struct deque_iter deque_iter;
|
||||
|
||||
int main(int argc, char const *argv[])
|
||||
{
|
||||
@@ -54,7 +56,7 @@ int main(int argc, char const *argv[])
|
||||
printf("D[%2d] = %2d\n", d_iter_index(&iter), d_iter_value(&iter));
|
||||
}
|
||||
|
||||
d_free(d);
|
||||
d_free(d, NULL);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -10,7 +10,10 @@
|
||||
#include "cmc/hashmap.h"
|
||||
#include <stdio.h>
|
||||
|
||||
HASHMAP_GENERATE(hm, hmap, static, int, double)
|
||||
CMC_GENERATE_HASHMAP(hm, hmap, int, double)
|
||||
typedef struct hmap hmap;
|
||||
typedef struct hmap_iter hmap_iter;
|
||||
|
||||
|
||||
size_t inthash(int t)
|
||||
{
|
||||
@@ -70,7 +73,7 @@ int main(int argc, char const *argv[])
|
||||
printf("HM[%2d] = { %2d : %2.2lf }\n", hm_iter_index(&iter), hm_iter_key(&iter), hm_iter_value(&iter));
|
||||
}
|
||||
|
||||
hm_free(hm);
|
||||
hm_free(hm, NULL);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -10,7 +10,10 @@
|
||||
#include "cmc/hashset.h"
|
||||
#include <stdio.h>
|
||||
|
||||
HASHSET_GENERATE(hs, hset, static, int)
|
||||
CMC_GENERATE_HASHSET(hs, hset, int);
|
||||
typedef struct hset hset;
|
||||
typedef struct hset_iter hset_iter;
|
||||
|
||||
|
||||
size_t inthash(int t)
|
||||
{
|
||||
@@ -69,7 +72,7 @@ int main(int argc, char const *argv[])
|
||||
printf("HS[%2d] = %2d\n", hs_iter_index(&iter), hs_iter_value(&iter));
|
||||
}
|
||||
|
||||
hs_free(hs);
|
||||
hs_free(hs, NULL);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -15,12 +15,16 @@ int intcmp(int a, int b)
|
||||
return (a > b) - (a < b);
|
||||
}
|
||||
|
||||
HEAP_GENERATE(h, heap, static, int)
|
||||
|
||||
CMC_GENERATE_HEAP(h, heap, int)
|
||||
typedef struct heap heap;
|
||||
typedef struct heap_iter heap_iter;
|
||||
|
||||
|
||||
int main(int argc, char const *argv[])
|
||||
{
|
||||
// Initialize heap and add some elements
|
||||
heap *h = h_new(10, MaxHeap, intcmp);
|
||||
heap *h = h_new(10, cmc_max_heap, intcmp);
|
||||
for (int i = 0; i < 10; i++)
|
||||
h_insert(h, i);
|
||||
|
||||
@@ -57,7 +61,7 @@ int main(int argc, char const *argv[])
|
||||
printf("H[%2d] = %2d\n", h_iter_index(&iter), h_iter_value(&iter));
|
||||
}
|
||||
|
||||
h_free(h);
|
||||
h_free(h, NULL);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -10,7 +10,10 @@
|
||||
#include "cmc/linkedlist.h"
|
||||
#include <stdio.h>
|
||||
|
||||
LINKEDLIST_GENERATE(ll, linkedlist, static, int)
|
||||
CMC_GENERATE_LINKEDLIST(ll, linkedlist, int);
|
||||
typedef struct linkedlist linkedlist;
|
||||
typedef struct linkedlist_iter linkedlist_iter;
|
||||
|
||||
|
||||
int main(int argc, char const *argv[])
|
||||
{
|
||||
@@ -52,7 +55,7 @@ int main(int argc, char const *argv[])
|
||||
printf("LL[%2d] = %2d\n", ll_iter_index(&iter), ll_iter_value(&iter));
|
||||
}
|
||||
|
||||
ll_free(ll);
|
||||
ll_free(ll, NULL);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -10,7 +10,10 @@
|
||||
#include "cmc/list.h"
|
||||
#include <stdio.h>
|
||||
|
||||
LIST_GENERATE(l, list, static, int)
|
||||
CMC_GENERATE_LIST(l, list, int);
|
||||
typedef struct list list;
|
||||
typedef struct list_iter list_iter;
|
||||
|
||||
|
||||
int main(int argc, char const *argv[])
|
||||
{
|
||||
@@ -52,7 +55,7 @@ int main(int argc, char const *argv[])
|
||||
printf("L[%2d] = %2d\n", l_iter_index(&iter), l_iter_value(&iter));
|
||||
}
|
||||
|
||||
l_free(l);
|
||||
l_free(l, NULL);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -10,7 +10,10 @@
|
||||
#include "cmc/queue.h"
|
||||
#include <stdio.h>
|
||||
|
||||
QUEUE_GENERATE(q, queue, static, int)
|
||||
CMC_GENERATE_QUEUE(q, queue, int)
|
||||
typedef struct queue queue;
|
||||
typedef struct queue_iter queue_iter;
|
||||
|
||||
|
||||
int main(int argc, char const *argv[])
|
||||
{
|
||||
@@ -52,7 +55,7 @@ int main(int argc, char const *argv[])
|
||||
printf("Q[%2d] = %2d\n", q_iter_index(&iter), q_iter_value(&iter));
|
||||
}
|
||||
|
||||
q_free(q);
|
||||
q_free(q, NULL);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -10,7 +10,10 @@
|
||||
#include "cmc/stack.h"
|
||||
#include <stdio.h>
|
||||
|
||||
STACK_GENERATE(s, stack, static, int)
|
||||
CMC_GENERATE_STACK(s, stack, int)
|
||||
typedef struct stack stack;
|
||||
typedef struct stack_iter stack_iter;
|
||||
|
||||
|
||||
int main(int argc, char const *argv[])
|
||||
{
|
||||
@@ -52,7 +55,7 @@ int main(int argc, char const *argv[])
|
||||
printf("S[%2d] = %2d\n", s_iter_index(&iter), s_iter_value(&iter));
|
||||
}
|
||||
|
||||
s_free(s);
|
||||
s_free(s, NULL);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -15,7 +15,10 @@ int intcmp(int a, int b)
|
||||
return (a > b) - (a < b);
|
||||
}
|
||||
|
||||
TREEMAP_GENERATE(tm, tmap, static, int, double)
|
||||
CMC_GENERATE_TREEMAP(tm, tmap, int, double)
|
||||
typedef struct tmap tmap;
|
||||
typedef struct tmap_iter tmap_iter;
|
||||
|
||||
|
||||
int main(int argc, char const *argv[])
|
||||
{
|
||||
@@ -58,7 +61,7 @@ int main(int argc, char const *argv[])
|
||||
printf("TM[%2d] = { %2d : %2.2lf }\n", tm_iter_index(&iter), tm_iter_key(&iter), tm_iter_value(&iter));
|
||||
}
|
||||
|
||||
tm_free(hm);
|
||||
tm_free(hm, NULL);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -15,7 +15,10 @@ int intcmp(int a, int b)
|
||||
return (a > b) - (a < b);
|
||||
}
|
||||
|
||||
TREESET_GENERATE(ts, tset, static, int)
|
||||
CMC_GENERATE_TREESET(ts, tset, int);
|
||||
typedef struct tset tset;
|
||||
typedef struct tset_iter tset_iter;
|
||||
|
||||
|
||||
int main(int argc, char const *argv[])
|
||||
{
|
||||
@@ -57,7 +60,7 @@ int main(int argc, char const *argv[])
|
||||
printf("TS[%2d] = %2d\n", ts_iter_index(&iter), ts_iter_value(&iter));
|
||||
}
|
||||
|
||||
ts_free(ts);
|
||||
ts_free(ts, NULL);
|
||||
|
||||
return 0;
|
||||
}
|
||||
Reference in new issue
Block a user