summaryrefslogtreecommitdiff
path: root/src/include/skalibs/avlnode.h
diff options
context:
space:
mode:
authorLaurent Bercot <ska-skaware@skarnet.org>2017-02-22 10:03:15 +0000
committerLaurent Bercot <ska-skaware@skarnet.org>2017-02-22 10:03:15 +0000
commita5079576ae9007fb1ca7ebcc911b5fb035cd2d06 (patch)
tree70f4014dd37d780dfb45182d26092cb1998d4eec /src/include/skalibs/avlnode.h
parent49d8fa1058aaf23c29e074b2314492ae40d2f557 (diff)
downloadskalibs-a5079576ae9007fb1ca7ebcc911b5fb035cd2d06.tar.xz
Types change: switch libdatastruct to uint32_t
Still needs to be reviewed.
Diffstat (limited to 'src/include/skalibs/avlnode.h')
-rw-r--r--src/include/skalibs/avlnode.h27
1 files changed, 14 insertions, 13 deletions
diff --git a/src/include/skalibs/avlnode.h b/src/include/skalibs/avlnode.h
index 245eef4..69e507b 100644
--- a/src/include/skalibs/avlnode.h
+++ b/src/include/skalibs/avlnode.h
@@ -3,44 +3,45 @@
#ifndef AVLNODE_H
#define AVLNODE_H
+#include <stdint.h>
#include <skalibs/gccattributes.h>
#include <skalibs/functypes.h>
#define AVLNODE_MAXDEPTH 49 /* enough for 2^32 nodes in the worst case */
-typedef int avliterfunc_t (unsigned int, unsigned int, void *) ;
+typedef int avliterfunc_t (uint32_t, unsigned int, void *) ;
typedef avliterfunc_t *avliterfunc_t_ref ;
typedef struct avlnode_s avlnode, *avlnode_ref ;
struct avlnode_s
{
- unsigned int data ;
- unsigned int child[2] ;
+ uint32_t data ;
+ uint32_t child[2] ;
signed char balance : 2 ;
} ;
-#define AVLNODE_ZERO { .data = 0, .child = { (unsigned int)-1, (unsigned int)-1 }, .balance = 0 }
+#define AVLNODE_ZERO { .data = 0, .child = { UINT32_MAX, UINT32_MAX }, .balance = 0 }
extern avlnode const avlnode_zero ;
-extern unsigned int avlnode_searchnode (avlnode const *, unsigned int, unsigned int, void const *, dtokfunc_t_ref, cmpfunc_t_ref, void *) ;
-extern int avlnode_search (avlnode const *, unsigned int, unsigned int, void const *, unsigned int *, dtokfunc_t_ref, cmpfunc_t_ref, void *) ;
-extern unsigned int avlnode_height (avlnode const *, unsigned int, unsigned int) gccattr_pure ;
+extern uint32_t avlnode_searchnode (avlnode const *, uint32_t, uint32_t, void const *, dtokfunc_t_ref, cmpfunc_t_ref, void *) ;
+extern int avlnode_search (avlnode const *, uint32_t, uint32_t, void const *, uint32_t *, dtokfunc_t_ref, cmpfunc_t_ref, void *) ;
+extern unsigned int avlnode_height (avlnode const *, uint32_t, uint32_t) gccattr_pure ;
-extern unsigned int avlnode_extremenode (avlnode const *, unsigned int, unsigned int, int) gccattr_pure ;
+extern uint32_t avlnode_extremenode (avlnode const *, uint32_t, uint32_t, int) gccattr_pure ;
#define avlnode_minnode(s, max, r) avlnode_extremenode(s, max, (r), 0)
#define avlnode_maxnode(s, max, r) avlnode_extremenode(s, max, (r), 1)
-extern int avlnode_extreme (avlnode const *, unsigned int, unsigned int, int, unsigned int *) ;
+extern int avlnode_extreme (avlnode const *, uint32_t, uint32_t, int, uint32_t *) ;
#define avlnode_min(s, max, r, data) avlnode_extreme(s, max, (r), 0, data)
#define avlnode_max(s, max, r, data) avlnode_extreme(s, max, (r), 1, data)
-extern unsigned int avlnode_insertnode (avlnode *, unsigned int, unsigned int, unsigned int, dtokfunc_t_ref, cmpfunc_t_ref, void *) ;
-extern unsigned int avlnode_delete (avlnode *, unsigned int, unsigned int *, void const *, dtokfunc_t_ref, cmpfunc_t_ref, void *) ;
+extern uint32_t avlnode_insertnode (avlnode *, uint32_t, uint32_t, uint32_t, dtokfunc_t_ref, cmpfunc_t_ref, void *) ;
+extern uint32_t avlnode_delete (avlnode *, uint32_t, uint32_t *, void const *, dtokfunc_t_ref, cmpfunc_t_ref, void *) ;
#define avlnode_deletenode(s, max, r, i, dtok, f, p) avlnode_delete(s, max, r, (*(dtok))((s)[i].data), dtok, f, p)
-extern unsigned int avlnode_iter_nocancel (avlnode *, unsigned int, unsigned int, unsigned int, avliterfunc_t_ref, void *) ;
+extern uint32_t avlnode_iter_nocancel (avlnode *, uint32_t, uint32_t, uint32_t, avliterfunc_t_ref, void *) ;
#define avlnode_iter(tree, max, root, f, stuff) (avlnode_iter_nocancel(tree, max, max, root, f, stuff) == (max))
-extern int avlnode_iter_withcancel (avlnode *, unsigned int, unsigned int, avliterfunc_t_ref, avliterfunc_t_ref, void *) ;
+extern int avlnode_iter_withcancel (avlnode *, uint32_t, uint32_t, avliterfunc_t_ref, avliterfunc_t_ref, void *) ;
#endif