/* * 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 ."; * * (c) Alexander Vdolainen 2007, 2026 * subrelay: a minimalistic maillist server based on external IMAPs/SMTPs * * splay.h: splay tree implementation * */ #ifndef __SPLAY_H__ #define __SPLAY_H__ #include typedef long (*splay_compare_t)(const void*, const void*); typedef struct __splay_node_t { struct __splay_node_t *splay_left; struct __splay_node_t *splay_right; struct __splay_node_t *splay_parent; void *splay_data; const void *splay_node_key; } splay_node_t; typedef struct __splay_t { uint64_t nodecount; splay_node_t splay_sentinel; splay_compare_t splay_compare; void *splay_context; } splay_t; int splay_init(splay_t *sp, splay_compare_t cmp_fu); int splay_insert(splay_t *sp, splay_node_t *node, const void *node_key); int splay_delete(splay_t *sp, splay_node_t *node); splay_node_t *splay_lookup(splay_t *sp, const void *key); splay_node_t *splay_first(splay_t *sp); splay_node_t *splay_next(splay_t *sp, splay_node_t *curr); #endif /* __SPLAY_H__*/