|
|
|
@ -2,6 +2,7 @@
|
|
|
|
|
/*
|
|
|
|
|
* usrtc.h
|
|
|
|
|
* Copyright (C) 2006-2013 Askele inc. <http://askele.com>
|
|
|
|
|
* Copyright (C) 2015-2016 Alexander Vdolainen <avdolainen@zoho.com>
|
|
|
|
|
*
|
|
|
|
|
* libtdata is free software: you can redistribute it and/or modify it
|
|
|
|
|
* under the terms of the GNU Lesser General Public License as published
|
|
|
|
@ -46,20 +47,21 @@ typedef enum {
|
|
|
|
|
usrtc_red,
|
|
|
|
|
usrtc_black
|
|
|
|
|
} usrtc_rb_color_t;
|
|
|
|
|
|
|
|
|
|
typedef enum {
|
|
|
|
|
usrtc_balanced,
|
|
|
|
|
usrtc_leftheavy,
|
|
|
|
|
usrtc_rightheavy
|
|
|
|
|
} usrtc_avl_balance_t;
|
|
|
|
|
|
|
|
|
|
/*used for the specific implementation features*/
|
|
|
|
|
/* used for the specific implementation features */
|
|
|
|
|
typedef union {
|
|
|
|
|
int usrtc_dummy;
|
|
|
|
|
usrtc_rb_color_t usrtc_rb_color;
|
|
|
|
|
usrtc_avl_balance_t usrtc_avl_balance;
|
|
|
|
|
} usrtc_impldata_t;
|
|
|
|
|
|
|
|
|
|
/*universal node*/
|
|
|
|
|
/* universal node */
|
|
|
|
|
typedef struct __usrtc_node_t {
|
|
|
|
|
struct __usrtc_node_t *usrtc_left;
|
|
|
|
|
struct __usrtc_node_t *usrtc_right;
|
|
|
|
@ -105,12 +107,16 @@ typedef struct __usrtc_functions_t {
|
|
|
|
|
void usrtc_init(usrtc_t *us,int impl,usrtc_count_t maxcount,usrtc_compare_t compare);
|
|
|
|
|
usrtc_t *usrtc_create(int impl,usrtc_count_t maxcount,usrtc_compare_t compare);
|
|
|
|
|
void usrtc_destroy(usrtc_t *us);
|
|
|
|
|
|
|
|
|
|
void usrtc_convert_to(usrtc_t *us,int impl);
|
|
|
|
|
|
|
|
|
|
usrtc_count_t usrtc_count(usrtc_t *us);
|
|
|
|
|
int usrtc_isempty(usrtc_t *us);
|
|
|
|
|
int usrtc_isfull(usrtc_t *us);
|
|
|
|
|
|
|
|
|
|
int usrtc_alloc_insert(usrtc_t *us,const void *key,void *data);
|
|
|
|
|
void usrtc_delete_free(usrtc_t *us,usrtc_node_t *node);
|
|
|
|
|
|
|
|
|
|
void usrtc_set_allocator(usrtc_t *us,usrtc_node_alloc_t alloc,usrtc_node_free_t n_free,void *context);
|
|
|
|
|
void usrtc_allow_dupes(usrtc_t *ud);
|
|
|
|
|
|
|
|
|
@ -125,9 +131,12 @@ const void *usrtc_node_getkey(usrtc_node_t *node);
|
|
|
|
|
/*rtc wrappers for the specific data structure functions*/
|
|
|
|
|
void usrtc_insert(usrtc_t *us,usrtc_node_t *node,const void *key);
|
|
|
|
|
void usrtc_delete(usrtc_t *us,usrtc_node_t *node);
|
|
|
|
|
|
|
|
|
|
usrtc_node_t *usrtc_lookup(usrtc_t *us,const void *key);
|
|
|
|
|
|
|
|
|
|
usrtc_node_t *usrtc_lower_bound(usrtc_t *us,const void *key);
|
|
|
|
|
usrtc_node_t *usrtc_upper_bound(usrtc_t *us,const void *key);
|
|
|
|
|
|
|
|
|
|
usrtc_node_t *usrtc_first(usrtc_t *us);
|
|
|
|
|
usrtc_node_t *usrtc_last(usrtc_t *us);
|
|
|
|
|
usrtc_node_t *usrtc_next(usrtc_t *us,usrtc_node_t *node);
|
|
|
|
|