|
|
@ -49,9 +49,11 @@ static usrtc_node_t *default_node_alloc(void *context)
|
|
|
|
static void default_node_free(void *context, usrtc_node_t *node)
|
|
|
|
static void default_node_free(void *context, usrtc_node_t *node)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
free(node);
|
|
|
|
free(node);
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void usrtc_init(usrtc_t *us,int impl,usrtc_count_t maxcount,usrtc_compare_t compare)
|
|
|
|
void usrtc_init(usrtc_t *us, int impl, usrtc_count_t maxcount,
|
|
|
|
|
|
|
|
usrtc_compare_t compare)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if(!us)
|
|
|
|
if(!us)
|
|
|
|
return;
|
|
|
|
return;
|
|
|
@ -67,9 +69,11 @@ void usrtc_init(usrtc_t *us,int impl,usrtc_count_t maxcount,usrtc_compare_t comp
|
|
|
|
us->context = 0;
|
|
|
|
us->context = 0;
|
|
|
|
us->futable = impl_table[impl];
|
|
|
|
us->futable = impl_table[impl];
|
|
|
|
us->futable->usrtc_init(us);
|
|
|
|
us->futable->usrtc_init(us);
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
usrtc_t *usrtc_create(int impl,usrtc_count_t maxcount,usrtc_compare_t compare)
|
|
|
|
usrtc_t *usrtc_create(int impl, usrtc_count_t maxcount,
|
|
|
|
|
|
|
|
usrtc_compare_t compare)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
usrtc_t *newrtc = (usrtc_t *) malloc(sizeof *newrtc);
|
|
|
|
usrtc_t *newrtc = (usrtc_t *) malloc(sizeof *newrtc);
|
|
|
|
|
|
|
|
|
|
|
@ -86,6 +90,7 @@ void usrtc_destroy(usrtc_t *us)
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
free(us);
|
|
|
|
free(us);
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void usrtc_convert_to(usrtc_t *us,int impl)
|
|
|
|
void usrtc_convert_to(usrtc_t *us,int impl)
|
|
|
@ -93,7 +98,8 @@ void usrtc_convert_to(usrtc_t *us,int impl)
|
|
|
|
if(impl_table[impl] == us->futable)
|
|
|
|
if(impl_table[impl] == us->futable)
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
if(us->futable->usrtc_type==usrtc_bst && (impl==USRTC_BST || impl==USRTC_SPLAY)) {
|
|
|
|
if((us->futable->usrtc_type == usrtc_bst) &&
|
|
|
|
|
|
|
|
(impl == USRTC_BST || impl == USRTC_SPLAY)) {
|
|
|
|
us->futable = impl_table[impl];
|
|
|
|
us->futable = impl_table[impl];
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -105,6 +111,7 @@ void usrtc_convert_to(usrtc_t *us,int impl)
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
us->futable->usrtc_convert_from_list(us);
|
|
|
|
us->futable->usrtc_convert_from_list(us);
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
usrtc_count_t usrtc_count(usrtc_t *us)
|
|
|
|
usrtc_count_t usrtc_count(usrtc_t *us)
|
|
|
@ -138,13 +145,16 @@ void usrtc_delete_free(usrtc_t *us,usrtc_node_t *node)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
us->futable->usrtc_delete(us, node);
|
|
|
|
us->futable->usrtc_delete(us, node);
|
|
|
|
us->node_free(us->context, node);
|
|
|
|
us->node_free(us->context, node);
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void usrtc_set_allocator(usrtc_t *us,usrtc_node_alloc_t alloc,usrtc_node_free_t n_free,void *context)
|
|
|
|
void usrtc_set_allocator(usrtc_t *us, usrtc_node_alloc_t alloc,
|
|
|
|
|
|
|
|
usrtc_node_free_t n_free, void *context)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
us->node_alloc = alloc;
|
|
|
|
us->node_alloc = alloc;
|
|
|
|
us->node_free = n_free;
|
|
|
|
us->node_free = n_free;
|
|
|
|
us->context = context;
|
|
|
|
us->context = context;
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void usrtc_allow_dupes(usrtc_t *us)
|
|
|
|
void usrtc_allow_dupes(usrtc_t *us)
|
|
|
@ -154,6 +164,7 @@ void usrtc_allow_dupes(usrtc_t *us)
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
us->dupes_allowed = 1;
|
|
|
|
us->dupes_allowed = 1;
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void usrtc_node_init(usrtc_node_t *node, void *data)
|
|
|
|
void usrtc_node_init(usrtc_node_t *node, void *data)
|
|
|
@ -178,6 +189,7 @@ usrtc_node_t *usrtc_node_create(void *data)
|
|
|
|
void usrtc_node_destroy(usrtc_node_t *node)
|
|
|
|
void usrtc_node_destroy(usrtc_node_t *node)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
free(node);
|
|
|
|
free(node);
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void *usrtc_node_getdata(usrtc_node_t *node)
|
|
|
|
void *usrtc_node_getdata(usrtc_node_t *node)
|
|
|
@ -188,6 +200,7 @@ void *usrtc_node_getdata(usrtc_node_t *node)
|
|
|
|
void usrtc_node_setdata(usrtc_node_t *node, void *data)
|
|
|
|
void usrtc_node_setdata(usrtc_node_t *node, void *data)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
node->data = data;
|
|
|
|
node->data = data;
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const void *usrtc_node_getkey(usrtc_node_t *node)
|
|
|
|
const void *usrtc_node_getkey(usrtc_node_t *node)
|
|
|
@ -198,11 +211,13 @@ const void *usrtc_node_getkey(usrtc_node_t *node)
|
|
|
|
void usrtc_insert(usrtc_t *us, usrtc_node_t *node, const void *key)
|
|
|
|
void usrtc_insert(usrtc_t *us, usrtc_node_t *node, const void *key)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
us->futable->usrtc_insert(us, node, key);
|
|
|
|
us->futable->usrtc_insert(us, node, key);
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void usrtc_delete(usrtc_t *us, usrtc_node_t *node)
|
|
|
|
void usrtc_delete(usrtc_t *us, usrtc_node_t *node)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
us->futable->usrtc_delete(us, node);
|
|
|
|
us->futable->usrtc_delete(us, node);
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
usrtc_node_t *usrtc_lookup(usrtc_t *us, const void *key)
|
|
|
|
usrtc_node_t *usrtc_lookup(usrtc_t *us, const void *key)
|
|
|
@ -240,4 +255,3 @@ usrtc_node_t *usrtc_prev(usrtc_t *us,usrtc_node_t *node)
|
|
|
|
return us->futable->usrtc_prev(us, node);
|
|
|
|
return us->futable->usrtc_prev(us, node);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|