tree2.c (1076B)
1 #include "../lash_tree2.h" 2 #include "../lash_tree2_dump.h" 3 #include <stdio.h> 4 5 int main() { 6 lash_tree_t *tree; 7 char *teststring = (char*)malloc(sizeof(char) * 255); 8 char *teststring2 = (char*)malloc(sizeof(char) * 255); 9 char *teststring3 = (char*)malloc(sizeof(char) * 255); 10 char *resultstring; 11 long int value; 12 sprintf(teststring, "one"); 13 sprintf(teststring2, "two"); 14 sprintf(teststring3, "three"); 15 16 tree = lash_treeInit(tree, 10); 17 if (tree == NULL) 18 return 1; 19 20 lash_treeDumpInit(1); 21 lash_treeDumpAdd(tree, "tree"); 22 23 24 lash_treePush(tree, 10, (void*)teststring); 25 lash_treeDump(NULL, NULL); 26 lash_treePush(tree, 20, (void*)teststring2); 27 lash_treeDump(NULL, NULL); 28 lash_treeShift(tree, &value, &resultstring); 29 printf("Shift got %li and %s\n", value, resultstring); 30 lash_treeDump(NULL, NULL); 31 lash_treePush(tree, 30, (void*)teststring3); 32 lash_treeDump(NULL, NULL); 33 lash_treeShift(tree, &value, &resultstring); 34 printf("Shift got %li and %s\n", value, resultstring); 35 lash_treeDump(NULL, NULL); 36 free(teststring); 37 lash_treeFree(tree); 38 39 return 0; 40 }