libdict
Data Structure C Library
Loading...
Searching...
No Matches
tr_tree.h
Go to the documentation of this file.
1/*
2 * libdict -- treap interface.
3 *
4 * Copyright (c) 2001-2014, Farooq Mela
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions are met:
9 *
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
17 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
20 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28#ifndef LIBDICT_TR_TREE_H__
29#define LIBDICT_TR_TREE_H__
30
31#include "dict.h"
32
34
35typedef struct tr_tree tr_tree;
36
39size_t tr_tree_free(tr_tree* tree, dict_delete_func delete_func);
40
42 tr_tree_insert(tr_tree* tree, void* key);
43void** tr_tree_search(tr_tree* tree, const void* key);
44void** tr_tree_search_le(tr_tree* tree, const void* key);
45void** tr_tree_search_lt(tr_tree* tree, const void* key);
46void** tr_tree_search_ge(tr_tree* tree, const void* key);
47void** tr_tree_search_gt(tr_tree* tree, const void* key);
49 tr_tree_remove(tr_tree* tree, const void* key);
50size_t tr_tree_clear(tr_tree* tree, dict_delete_func delete_func);
51size_t tr_tree_traverse(tr_tree* tree, dict_visit_func visit, void* user_data);
52bool tr_tree_select(tr_tree* tree, size_t n, const void** key, void** datum);
53size_t tr_tree_count(const tr_tree* tree);
57bool tr_tree_verify(const tr_tree* tree);
58
59typedef struct tr_itor tr_itor;
60
64
65bool tr_itor_valid(const tr_itor* itor);
66void tr_itor_invalidate(tr_itor* itor);
67bool tr_itor_next(tr_itor* itor);
68bool tr_itor_prev(tr_itor* itor);
69bool tr_itor_nextn(tr_itor* itor, size_t count);
70bool tr_itor_prevn(tr_itor* itor, size_t count);
71bool tr_itor_first(tr_itor* itor);
72bool tr_itor_last(tr_itor* itor);
73bool tr_itor_search(tr_itor* itor, const void* key);
74bool tr_itor_search_le(tr_itor* itor, const void* key);
75bool tr_itor_search_lt(tr_itor* itor, const void* key);
76bool tr_itor_search_ge(tr_itor* itor, const void* key);
77bool tr_itor_search_gt(tr_itor* itor, const void* key);
78const void* tr_itor_key(const tr_itor* itor);
79void** tr_itor_datum(tr_itor* itor);
80int tr_itor_compare(const tr_itor* i1, const tr_itor* i2);
81bool tr_itor_remove(tr_itor* itor);
82
84
85#endif /* !LIBDICT_TR_TREE_H__ */
#define BEGIN_DECL
Definition dict.h:35
int(* dict_compare_func)(const void *, const void *)
Definition dict.h:54
void(* dict_delete_func)(void *, void *)
Definition dict.h:57
#define END_DECL
Definition dict.h:36
unsigned(* dict_prio_func)(const void *)
Definition dict.h:63
bool(* dict_visit_func)(const void *, void *, void *)
Definition dict.h:59
Definition dict.h:151
dict_prio_func prio_func
Definition tr_tree.c:57
void ** tr_itor_datum(tr_itor *itor)
Definition tr_tree.c:321
void tr_itor_free(tr_itor *tree)
Definition tr_tree.c:306
bool tr_itor_search_le(tr_itor *itor, const void *key)
Definition tr_tree.c:316
dict_itor * tr_dict_itor_new(tr_tree *tree)
Definition tr_tree.c:293
dict_remove_result tr_tree_remove(tr_tree *tree, const void *key)
Definition tr_tree.c:208
size_t tr_tree_total_path_length(const tr_tree *tree)
Definition tr_tree.c:228
void tr_itor_invalidate(tr_itor *itor)
Definition tr_tree.c:308
bool tr_tree_select(tr_tree *tree, size_t n, const void **key, void **datum)
Definition tr_tree.c:224
bool tr_itor_last(tr_itor *itor)
Definition tr_tree.c:314
bool tr_itor_search_lt(tr_itor *itor, const void *key)
Definition tr_tree.c:317
void ** tr_tree_search_le(tr_tree *tree, const void *key)
Definition tr_tree.c:219
bool tr_itor_nextn(tr_itor *itor, size_t count)
Definition tr_tree.c:311
bool tr_itor_remove(tr_itor *itor)
Definition tr_tree.c:325
size_t tr_tree_clear(tr_tree *tree, dict_delete_func delete_func)
Definition tr_tree.c:136
bool tr_itor_next(tr_itor *itor)
Definition tr_tree.c:309
size_t tr_tree_traverse(tr_tree *tree, dict_visit_func visit, void *user_data)
Definition tr_tree.c:223
size_t tr_tree_free(tr_tree *tree, dict_delete_func delete_func)
Definition tr_tree.c:135
bool tr_itor_first(tr_itor *itor)
Definition tr_tree.c:313
tr_tree * tr_tree_new(dict_compare_func compare_func, dict_prio_func prio_func)
Definition tr_tree.c:106
tr_itor * tr_itor_new(tr_tree *tree)
Definition tr_tree.c:282
bool tr_itor_prev(tr_itor *itor)
Definition tr_tree.c:310
bool tr_itor_search_ge(tr_itor *itor, const void *key)
Definition tr_tree.c:318
size_t tr_tree_min_path_length(const tr_tree *tree)
Definition tr_tree.c:226
bool tr_itor_search_gt(tr_itor *itor, const void *key)
Definition tr_tree.c:319
const void * tr_itor_key(const tr_itor *itor)
Definition tr_tree.c:320
bool tr_itor_valid(const tr_itor *itor)
Definition tr_tree.c:307
bool tr_tree_verify(const tr_tree *tree)
Definition tr_tree.c:271
bool tr_itor_prevn(tr_itor *itor, size_t count)
Definition tr_tree.c:312
size_t tr_tree_count(const tr_tree *tree)
Definition tr_tree.c:225
int tr_itor_compare(const tr_itor *i1, const tr_itor *i2)
Definition tr_tree.c:322
void ** tr_tree_search_lt(tr_tree *tree, const void *key)
Definition tr_tree.c:220
dict * tr_dict_new(dict_compare_func compare_func, dict_prio_func prio_func)
Definition tr_tree.c:122
void ** tr_tree_search_ge(tr_tree *tree, const void *key)
Definition tr_tree.c:221
void ** tr_tree_search_gt(tr_tree *tree, const void *key)
Definition tr_tree.c:222
dict_insert_result tr_tree_insert(tr_tree *tree, void *key)
Definition tr_tree.c:139
bool tr_itor_search(tr_itor *itor, const void *key)
Definition tr_tree.c:315
size_t tr_tree_max_path_length(const tr_tree *tree)
Definition tr_tree.c:227
void ** tr_tree_search(tr_tree *tree, const void *key)
Definition tr_tree.c:218