aboutsummaryrefslogtreecommitdiff
path: root/shared/hammer/tree.h
diff options
context:
space:
mode:
authorN.N. <krzyszcz@users.sourceforge.net>2004-12-08 15:40:14 +0000
committerN.N. <krzyszcz@users.sourceforge.net>2004-12-08 15:40:14 +0000
commitd5a39ff6469f8762218c00a34f4b0a120a56332b (patch)
tree8b5d6f1008f1ce09daf3e2a63b71f9c142911e80 /shared/hammer/tree.h
parentb88a64023a08ed9a0e520058ef8be200515d9639 (diff)
various bug-fixes, maxmode, toxy .#args
svn path=/trunk/externals/miXed/; revision=2360
Diffstat (limited to 'shared/hammer/tree.h')
-rw-r--r--shared/hammer/tree.h67
1 files changed, 58 insertions, 9 deletions
diff --git a/shared/hammer/tree.h b/shared/hammer/tree.h
index fcbc036..368fed2 100644
--- a/shared/hammer/tree.h
+++ b/shared/hammer/tree.h
@@ -1,17 +1,24 @@
-/* Copyright (c) 2003 krzYszcz and others.
+/* Copyright (c) 2003-2004 krzYszcz and others.
* For information on usage and redistribution, and for a DISCLAIMER OF ALL
* WARRANTIES, see the file, "LICENSE.txt," in this distribution. */
#ifndef __HAMMERTREE_H__
#define __HAMMERTREE_H__
+#ifdef KRZYSZCZ
#define HAMMERTREE_DEBUG
+#endif
+
+typedef enum
+{
+ HAMMERTYPE_FLOAT, HAMMERTYPE_SYMBOL, HAMMERTYPE_ATOM,
+ HAMMERTYPE_CUSTOM, HAMMERTYPE_ILLEGAL
+} t_hammertype;
typedef struct _hammernode
{
- int n_index;
- float n_value;
- int n_black;
+ int n_key;
+ int n_black;
struct _hammernode *n_left;
struct _hammernode *n_right;
struct _hammernode *n_parent;
@@ -19,19 +26,61 @@ typedef struct _hammernode
struct _hammernode *n_next;
} t_hammernode;
+typedef struct _hammernode_float
+{
+ t_hammernode nf_node;
+ t_float nf_value;
+} t_hammernode_float;
+
+typedef struct _hammernode_symbol
+{
+ t_hammernode ns_node;
+ t_symbol *ns_value;
+} t_hammernode_symbol;
+
+typedef struct _hammernode_atom
+{
+ t_hammernode na_node;
+ t_atom na_value;
+} t_hammernode_atom;
+
typedef struct _hammertree
{
t_hammernode *t_root;
t_hammernode *t_first;
t_hammernode *t_last;
+ t_hammertype t_valuetype;
+ size_t t_nodesize;
} t_hammertree;
-t_hammernode *hammertree_insert(t_hammertree *tree, int ndx);
+#define HAMMERNODE_GETFLOAT(np) (((t_hammernode_float *)(np))->nf_value)
+#define HAMMERNODE_GETSYMBOL(np) (((t_hammernode_symbol *)(np))->ns_value)
+#define HAMMERNODE_GETATOMPTR(np) (&((t_hammernode_atom *)(np))->na_value)
+
+typedef void (*t_hammernode_vshowhook)(t_hammernode *, char *, unsigned);
+
+t_hammernode *hammertree_search(t_hammertree *tree, int key);
+t_hammernode *hammertree_closest(t_hammertree *tree, int key, int geqflag);
+
+t_hammernode *hammertree_insert(t_hammertree *tree, int key, int *foundp);
+t_hammernode *hammertree_multiinsert(t_hammertree *tree, int key, int fifoflag);
+t_hammernode *hammertree_insertfloat(t_hammertree *tree, int key, t_float f,
+ int replaceflag);
+t_hammernode *hammertree_insertsymbol(t_hammertree *tree, int key, t_symbol *s,
+ int replaceflag);
+t_hammernode *hammertree_insertatom(t_hammertree *tree, int key, t_atom *ap,
+ int replaceflag);
void hammertree_delete(t_hammertree *tree, t_hammernode *np);
-t_hammernode *hammertree_search(t_hammertree *tree, int ndx);
-t_hammernode *hammertree_closest(t_hammertree *tree, int ndx, int geqflag);
-void hammertree_init(t_hammertree *tree, int freecount);
+
+void hammertree_inittyped(t_hammertree *tree,
+ t_hammertype vtype, int freecount);
+void hammertree_initcustom(t_hammertree *tree,
+ size_t nodesize, int freecount);
void hammertree_clear(t_hammertree *tree, int freecount);
-void hammertree_debug(t_hammertree *tree, int level);
+
+#ifdef HAMMERTREE_DEBUG
+void hammertree_debug(t_hammertree *tree, int level,
+ t_hammernode_vshowhook hook);
+#endif
#endif