splay tree minor fixes + header;
This commit is contained in:
parent
5d57fbcdfd
commit
a7645b813c
@ -1,13 +1,28 @@
|
||||
/* splay tree implementation */
|
||||
/*
|
||||
* this is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published
|
||||
* by the Free Software Foundation, either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* this is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
* See the GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.";
|
||||
*
|
||||
* (c) Alexander Vdolainen 2007, 2026 <alex@vapaa.xyz>
|
||||
* subrelay: a minimalistic maillist server based on external IMAPs/SMTPs
|
||||
*
|
||||
* splay.h: splay tree implementation
|
||||
*
|
||||
*/
|
||||
#ifndef __SPLAY_H__
|
||||
#define __SPLAY_H__
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#define tree_root_priv(T) ((T)->splay_sentinel.splay_left)
|
||||
#define tree_null_priv(L) (&(L)->splay_sentinel)
|
||||
#define TREE_DEPTH_MAX 64
|
||||
|
||||
typedef long (*splay_compare_t)(const void*, const void*);
|
||||
|
||||
typedef struct __splay_node_t {
|
||||
@ -20,7 +35,6 @@ typedef struct __splay_node_t {
|
||||
|
||||
typedef struct __splay_t {
|
||||
uint64_t nodecount;
|
||||
uint64_t maxcount;
|
||||
splay_node_t splay_sentinel;
|
||||
splay_compare_t splay_compare;
|
||||
void *splay_context;
|
||||
|
||||
26
src/splay.c
26
src/splay.c
@ -1,4 +1,23 @@
|
||||
/* splay tree implementation */
|
||||
/*
|
||||
* this is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published
|
||||
* by the Free Software Foundation, either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* this is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
* See the GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.";
|
||||
*
|
||||
* (c) Alexander Vdolainen 2007, 2026 <alex@vapaa.xyz>
|
||||
* subrelay: a minimalistic maillist server based on external IMAPs/SMTPs
|
||||
*
|
||||
* splay.c: splay tree implementation
|
||||
*
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
@ -7,6 +26,9 @@
|
||||
|
||||
#include <ilib/splay.h>
|
||||
|
||||
#define tree_root_priv(T) ((T)->splay_sentinel.splay_left)
|
||||
#define tree_null_priv(L) (&(L)->splay_sentinel)
|
||||
|
||||
static void splay_node(splay_t *, splay_node_t *);
|
||||
static void tree_rotate_left(splay_node_t *, splay_node_t *);
|
||||
static void tree_rotate_right(splay_node_t *, splay_node_t *);
|
||||
@ -21,8 +43,6 @@ int splay_init(splay_t *sp, splay_compare_t cmp_fu)
|
||||
|
||||
memset(sp, 0, sizeof(splay_t));
|
||||
|
||||
/* FIXME: do better maxcount */
|
||||
sp->maxcount = 65535;
|
||||
sp->splay_compare = cmp_fu;
|
||||
|
||||
/* tree init */
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user