libdict
Data Structure C Library
Loading...
Searching...
No Matches
wb_tree.h
Go to the documentation of this file.
1/*
2 * libdict -- weight balanced tree 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_WB_TREE_H__
29#define LIBDICT_WB_TREE_H__
30
31#include "dict.h"
32
34
35typedef struct wb_tree wb_tree;
36
39size_t wb_tree_free(wb_tree* tree, dict_delete_func delete_func);
40
42 wb_tree_insert(wb_tree* tree, void* key);
43void** wb_tree_search(wb_tree* tree, const void* key);
44void** wb_tree_search_le(wb_tree* tree, const void* key);
45void** wb_tree_search_lt(wb_tree* tree, const void* key);
46void** wb_tree_search_ge(wb_tree* tree, const void* key);
47void** wb_tree_search_gt(wb_tree* tree, const void* key);
48
50 wb_tree_remove(wb_tree* tree, const void* key);
51size_t wb_tree_clear(wb_tree* tree, dict_delete_func delete_func);
52size_t wb_tree_traverse(wb_tree* tree, dict_visit_func visit, void* user_data);
53bool wb_tree_select(wb_tree* tree, size_t n, const void** key, void** datum);
54size_t wb_tree_count(const wb_tree* tree);
58bool wb_tree_verify(const wb_tree* tree);
59
60typedef struct wb_itor wb_itor;
61
65
66bool wb_itor_valid(const wb_itor* itor);
67void wb_itor_invalidate(wb_itor* itor);
68bool wb_itor_next(wb_itor* itor);
69bool wb_itor_prev(wb_itor* itor);
70bool wb_itor_nextn(wb_itor* itor, size_t count);
71bool wb_itor_prevn(wb_itor* itor, size_t count);
72bool wb_itor_first(wb_itor* itor);
73bool wb_itor_last(wb_itor* itor);
74bool wb_itor_search(wb_itor* itor, const void* key);
75bool wb_itor_search_le(wb_itor* itor, const void* key);
76bool wb_itor_search_lt(wb_itor* itor, const void* key);
77bool wb_itor_search_ge(wb_itor* itor, const void* key);
78bool wb_itor_search_gt(wb_itor* itor, const void* key);
79const void* wb_itor_key(const wb_itor* itor);
80void** wb_itor_datum(wb_itor* itor);
81int wb_itor_compare(const wb_itor* i1, const wb_itor* i2);
82bool wb_itor_remove(wb_itor* itor);
83
85
86#endif /* !LIBDICT_WB_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
bool(* dict_visit_func)(const void *, void *, void *)
Definition dict.h:59
Definition dict.h:151
dict_compare_func cmp_func
Definition wb_tree.c:75
bool wb_itor_first(wb_itor *itor)
Definition wb_tree.c:456
size_t wb_tree_clear(wb_tree *tree, dict_delete_func delete_func)
Definition wb_tree.c:324
void ** wb_tree_search_ge(wb_tree *tree, const void *key)
Definition wb_tree.c:155
void ** wb_tree_search_le(wb_tree *tree, const void *key)
Definition wb_tree.c:153
size_t wb_tree_count(const wb_tree *tree)
Definition wb_tree.c:356
int wb_itor_compare(const wb_itor *i1, const wb_itor *i2)
Definition wb_tree.c:465
bool wb_itor_last(wb_itor *itor)
Definition wb_tree.c:457
bool wb_itor_search_lt(wb_itor *itor, const void *key)
Definition wb_tree.c:460
const void * wb_itor_key(const wb_itor *itor)
Definition wb_tree.c:463
bool wb_itor_remove(wb_itor *itor)
Definition wb_tree.c:468
bool wb_itor_search_gt(wb_itor *itor, const void *key)
Definition wb_tree.c:462
void ** wb_tree_search_lt(wb_tree *tree, const void *key)
Definition wb_tree.c:154
size_t wb_tree_traverse(wb_tree *tree, dict_visit_func visit, void *user_data)
Definition wb_tree.c:325
wb_tree * wb_tree_new(dict_compare_func cmp_func)
Definition wb_tree.c:124
void wb_itor_free(wb_itor *tree)
Definition wb_tree.c:449
dict_insert_result wb_tree_insert(wb_tree *tree, void *key)
Definition wb_tree.c:235
dict * wb_dict_new(dict_compare_func cmp_func)
Definition wb_tree.c:139
bool wb_itor_prevn(wb_itor *itor, size_t count)
Definition wb_tree.c:455
dict_itor * wb_dict_itor_new(wb_tree *tree)
Definition wb_tree.c:436
bool wb_itor_search(wb_itor *itor, const void *key)
Definition wb_tree.c:458
bool wb_tree_verify(const wb_tree *tree)
Definition wb_tree.c:412
void ** wb_itor_datum(wb_itor *itor)
Definition wb_tree.c:464
bool wb_itor_search_ge(wb_itor *itor, const void *key)
Definition wb_tree.c:461
bool wb_itor_nextn(wb_itor *itor, size_t count)
Definition wb_tree.c:454
bool wb_itor_search_le(wb_itor *itor, const void *key)
Definition wb_tree.c:459
void wb_itor_invalidate(wb_itor *itor)
Definition wb_tree.c:451
size_t wb_tree_free(wb_tree *tree, dict_delete_func delete_func)
Definition wb_tree.c:323
bool wb_itor_valid(const wb_itor *itor)
Definition wb_tree.c:450
bool wb_itor_prev(wb_itor *itor)
Definition wb_tree.c:453
bool wb_tree_select(wb_tree *tree, size_t n, const void **key, void **datum)
Definition wb_tree.c:328
size_t wb_tree_min_path_length(const wb_tree *tree)
Definition wb_tree.c:357
dict_remove_result wb_tree_remove(wb_tree *tree, const void *key)
Definition wb_tree.c:313
bool wb_itor_next(wb_itor *itor)
Definition wb_tree.c:452
void ** wb_tree_search(wb_tree *tree, const void *key)
Definition wb_tree.c:152
void ** wb_tree_search_gt(wb_tree *tree, const void *key)
Definition wb_tree.c:156
wb_itor * wb_itor_new(wb_tree *tree)
Definition wb_tree.c:425
size_t wb_tree_max_path_length(const wb_tree *tree)
Definition wb_tree.c:358
size_t wb_tree_total_path_length(const wb_tree *tree)
Definition wb_tree.c:359