libdict
Data Structure C Library
Loading...
Searching...
No Matches
hb_tree.h
Go to the documentation of this file.
1/*
2 * libdict -- height-balanced (AVL) 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_HB_TREE_H__
29#define LIBDICT_HB_TREE_H__
30
31#include "dict.h"
32
34
35typedef struct hb_tree hb_tree;
36
39size_t hb_tree_free(hb_tree* tree, dict_delete_func delete_func);
40
42 hb_tree_insert(hb_tree* tree, void* key);
43void** hb_tree_search(hb_tree* tree, const void* key);
44void** hb_tree_search_le(hb_tree* tree, const void* key);
45void** hb_tree_search_lt(hb_tree* tree, const void* key);
46void** hb_tree_search_ge(hb_tree* tree, const void* key);
47void** hb_tree_search_gt(hb_tree* tree, const void* key);
49 hb_tree_remove(hb_tree* tree, const void* key);
50size_t hb_tree_clear(hb_tree* tree, dict_delete_func delete_func);
51size_t hb_tree_traverse(hb_tree* tree, dict_visit_func visit, void* user_data);
52bool hb_tree_select(hb_tree* tree, size_t n, const void** key, void** datum);
53size_t hb_tree_count(const hb_tree* tree);
57bool hb_tree_verify(const hb_tree* tree);
58
59typedef struct hb_itor hb_itor;
60
64
65bool hb_itor_valid(const hb_itor* itor);
66void hb_itor_invalidate(hb_itor* itor);
67bool hb_itor_next(hb_itor* itor);
68bool hb_itor_prev(hb_itor* itor);
69bool hb_itor_nextn(hb_itor* itor, size_t count);
70bool hb_itor_prevn(hb_itor* itor, size_t count);
71bool hb_itor_first(hb_itor* itor);
72bool hb_itor_last(hb_itor* itor);
73bool hb_itor_search(hb_itor* itor, const void* key);
74bool hb_itor_search_le(hb_itor* itor, const void* key);
75bool hb_itor_search_lt(hb_itor* itor, const void* key);
76bool hb_itor_search_ge(hb_itor* itor, const void* key);
77bool hb_itor_search_gt(hb_itor* itor, const void* key);
78const void* hb_itor_key(const hb_itor* itor);
79void** hb_itor_datum(hb_itor* itor);
80int hb_itor_compare(const hb_itor* i1, const hb_itor* i2);
81bool hb_itor_remove(hb_itor* itor);
82
84
85#endif /* !LIBDICT_HB_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
bool hb_itor_search(hb_itor *itor, const void *key)
Definition hb_tree.c:646
dict_itor * hb_dict_itor_new(hb_tree *tree)
Definition hb_tree.c:603
size_t hb_tree_clear(hb_tree *tree, dict_delete_func delete_func)
Definition hb_tree.c:142
bool hb_itor_search_gt(hb_itor *itor, const void *key)
Definition hb_tree.c:650
void ** hb_tree_search_lt(hb_tree *tree, const void *key)
Definition hb_tree.c:358
void ** hb_tree_search(hb_tree *tree, const void *key)
Definition hb_tree.c:356
bool hb_tree_select(hb_tree *tree, size_t n, const void **key, void **datum)
Definition hb_tree.c:467
dict * hb_dict_new(dict_compare_func cmp_func)
Definition hb_tree.c:121
bool hb_itor_search_ge(hb_itor *itor, const void *key)
Definition hb_tree.c:649
hb_itor * hb_itor_new(hb_tree *tree)
Definition hb_tree.c:592
bool hb_itor_search_lt(hb_itor *itor, const void *key)
Definition hb_tree.c:648
bool hb_itor_prev(hb_itor *itor)
Definition hb_tree.c:626
void ** hb_tree_search_gt(hb_tree *tree, const void *key)
Definition hb_tree.c:360
hb_tree * hb_tree_new(dict_compare_func cmp_func)
Definition hb_tree.c:106
void hb_itor_invalidate(hb_itor *itor)
Definition hb_tree.c:618
size_t hb_tree_count(const hb_tree *tree)
Definition hb_tree.c:494
bool hb_itor_valid(const hb_itor *itor)
Definition hb_tree.c:617
size_t hb_tree_min_path_length(const hb_tree *tree)
Definition hb_tree.c:495
dict_insert_result hb_tree_insert(hb_tree *tree, void *key)
Definition hb_tree.c:278
void ** hb_tree_search_ge(hb_tree *tree, const void *key)
Definition hb_tree.c:359
bool hb_itor_nextn(hb_itor *itor, size_t count)
Definition hb_tree.c:632
bool hb_itor_remove(hb_itor *itor)
Definition hb_tree.c:656
void hb_itor_free(hb_itor *tree)
Definition hb_tree.c:616
size_t hb_tree_free(hb_tree *tree, dict_delete_func delete_func)
Definition hb_tree.c:135
dict_remove_result hb_tree_remove(hb_tree *tree, const void *key)
Definition hb_tree.c:450
size_t hb_tree_max_path_length(const hb_tree *tree)
Definition hb_tree.c:496
int hb_itor_compare(const hb_itor *i1, const hb_itor *i2)
Definition hb_tree.c:651
bool hb_itor_last(hb_itor *itor)
Definition hb_tree.c:645
bool hb_itor_prevn(hb_itor *itor, size_t count)
Definition hb_tree.c:638
void ** hb_itor_datum(hb_itor *itor)
Definition hb_tree.c:653
bool hb_itor_next(hb_itor *itor)
Definition hb_tree.c:620
const void * hb_itor_key(const hb_itor *itor)
Definition hb_tree.c:652
bool hb_itor_search_le(hb_itor *itor, const void *key)
Definition hb_tree.c:647
bool hb_tree_verify(const hb_tree *tree)
Definition hb_tree.c:583
bool hb_itor_first(hb_itor *itor)
Definition hb_tree.c:644
size_t hb_tree_traverse(hb_tree *tree, dict_visit_func visit, void *user_data)
Definition hb_tree.c:461
void ** hb_tree_search_le(hb_tree *tree, const void *key)
Definition hb_tree.c:357
size_t hb_tree_total_path_length(const hb_tree *tree)
Definition hb_tree.c:497
Definition dict.h:151
dict_compare_func cmp_func
Definition hb_tree.c:52