💾 Archived View for gmi.noulin.net › gitRepositories › tree › file › main.c.gmi captured on 2023-01-29 at 11:35:38. Gemini links have been rewritten to link to archived content
-=-=-=-=-=-=-
main.c (1272B)
1 #! /usr/bin/env sheepy 2 /* or direct path to sheepy: #! /usr/local/bin/sheepy */ 3 4 /* Libsheepy documentation: http://spartatek.se/libsheepy/ */ 5 #include "libsheepyObject.h" 6 #include "wavl.h" 7 8 int argc; char **argv; 9 10 /* enable/disable logging */ 11 /* #undef pLog */ 12 /* #define pLog(...) */ 13 14 wavlDef(/* scope */, w /* wt wavl tree type and wNodet node type */, W /* function suffix: initW...*/, u32 /* keyType*/, u32 /* valueType */); 15 16 wt tree; 17 18 void freeKV(u32* /* keyType */ key, u32* /* valueType*/ value) { 19 } 20 21 #define FREEFUNC freeKV 22 #define CMPFUNC CMP 23 24 wavlFunctions(/* scope */, w /* wt wavl tree type*/, W /* function suffix: initW...*/, u32 /* keyType*/, u32 /* valueType */, -1 /* null key */, -1 /* null value */); 25 26 #undef FREEFUNC 27 #undef CMPFUNC 28 29 int main(int ARGC, char** ARGV) { 30 31 argc = ARGC; argv = ARGV; 32 33 initLibsheepy(ARGV[0]); 34 setLogMode(LOG_FUNC); 35 36 initW(&tree); 37 38 addW(&tree, 0, 0); 39 addW(&tree, 1, 1); 40 addW(&tree, 10, 10); 41 addW(&tree, 5, 5); 42 43 var n = getW(&tree, 10); 44 logVarG(n); 45 46 // tree.inOrderTraversal(tree.root); 47 iterStartW(&tree, getFirstEntryW(&tree)); 48 wNodet *node; 49 while(node = nextW(&tree)) { 50 logVarG(node->key); 51 logVarG(node->value); 52 } 53 54 delW(&tree, 10); 55 56 freeW(&tree); 57 58 } 59 // vim: set expandtab ts=2 sw=2: