APPEND/PREPEND commands
[rxpd] / psplay.h
index b337dba..ea65417 100644 (file)
--- a/psplay.h
+++ b/psplay.h
 #include <stdint.h>
 #include <stdio.h>
 
+enum psplay_order_e
+  {
+    PSPLAY_PREORDER,
+    PSPLAY_INORDER,
+    PSPLAY_POSTORDER
+  };
+
 typedef struct psplayroot_struct psplayroot;
 typedef psplayroot* PSplayroot;
 
@@ -35,6 +42,7 @@ typedef psplay* PSplay;
 
 typedef int (*psplay_cmp_t)(const void*, const void*);
 typedef void (*psplay_delete_t)(PSplay);
+typedef psplay_delete_t (*psplay_action_t)(PSplay node, const enum psplay_order_e which, int level, void* data);
 
 //
 struct psplayroot_struct
@@ -53,6 +61,12 @@ psplay_init_root (PSplayroot self, psplay_cmp_t cmp, psplay_delete_t delete);
 PSplayroot
 psplay_destroy_root (PSplayroot self);
 
+static inline int
+psplay_isempty_root (PSplayroot root)
+{
+  return !root->tree;
+}
+
 #define PSPLAYROOT_INITIALIZER(cmp, delete) {NULL, cmp, delete, 0}
 
 //
@@ -83,7 +97,16 @@ psplay_find (PSplayroot root, void* key);
 PSplay
 psplay_remove (PSplayroot root, PSplay node);
 
+extern const psplay_delete_t PSPLAY_CONT;
+extern const psplay_delete_t PSPLAY_STOP;
+extern const psplay_delete_t PSPLAY_REMOVE;
+
+int
+psplay_walk (PSplayroot root, PSplay node, psplay_action_t action, int level, void* data);
+
+
 void
-psplay_dump (PSplay root, FILE* dest, unsigned level);
+psplay_dump (PSplayroot root, FILE* dest);
+
 
 #endif