BLOG | DOCUMENTATION | GITHUB

Home --> Documentations --> PJLIB Reference

rbtree.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2008-2011 Teluu Inc. (http://www.teluu.com)
3 * Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org>
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 */
19#ifndef __PJ_RBTREE_H__
20#define __PJ_RBTREE_H__
21
27#include <pj/types.h>
28
30
42typedef enum pj_rbcolor_t
43{
44 PJ_RBCOLOR_BLACK,
45 PJ_RBCOLOR_RED
47
51typedef struct pj_rbtree_node
52{
55
58
61
63 const void *key;
64
66 void *user_data;
67
70
72
73
81typedef int pj_rbtree_comp(const void *key1, const void *key2);
82
83
92typedef struct pj_rbtree
93{
97 unsigned size;
99} pj_rbtree;
100
101
105#define PJ_RBTREE_NODE_SIZE (sizeof(pj_rbtree_node))
106
107
111#define PJ_RBTREE_SIZE (sizeof(pj_rbtree))
112
113
119PJ_DECL(void) pj_rbtree_init( pj_rbtree *tree, pj_rbtree_comp *comp);
120
129
138
147 pj_rbtree_node *node );
148
157 pj_rbtree_node *node );
158
167PJ_DECL(int) pj_rbtree_insert( pj_rbtree *tree,
168 pj_rbtree_node *node );
169
178 const void *key );
179
187 pj_rbtree_node *node );
188
195PJ_DECL(unsigned) pj_rbtree_max_height( pj_rbtree *tree,
196 pj_rbtree_node *node );
197
204PJ_DECL(unsigned) pj_rbtree_min_height( pj_rbtree *tree,
205 pj_rbtree_node *node );
206
207
213
214#endif /* __PJ_RBTREE_H__ */
215
unsigned pj_rbtree_min_height(pj_rbtree *tree, pj_rbtree_node *node)
int pj_rbtree_insert(pj_rbtree *tree, pj_rbtree_node *node)
int pj_rbtree_comp(const void *key1, const void *key2)
Definition: rbtree.h:81
pj_rbtree_node * pj_rbtree_first(pj_rbtree *tree)
void pj_rbtree_init(pj_rbtree *tree, pj_rbtree_comp *comp)
pj_rbtree_node * pj_rbtree_next(pj_rbtree *tree, pj_rbtree_node *node)
pj_rbtree_node * pj_rbtree_last(pj_rbtree *tree)
unsigned pj_rbtree_max_height(pj_rbtree *tree, pj_rbtree_node *node)
pj_rbtree_node * pj_rbtree_find(pj_rbtree *tree, const void *key)
pj_rbcolor_t
Definition: rbtree.h:43
pj_rbtree_node * pj_rbtree_prev(pj_rbtree *tree, pj_rbtree_node *node)
pj_rbtree_node * pj_rbtree_erase(pj_rbtree *tree, pj_rbtree_node *node)
#define PJ_BEGIN_DECL
Definition: config.h:1284
#define PJ_END_DECL
Definition: config.h:1285
Definition: rbtree.h:52
const void * key
Definition: rbtree.h:63
pj_rbcolor_t color
Definition: rbtree.h:69
struct pj_rbtree_node * parent
Definition: rbtree.h:54
void * user_data
Definition: rbtree.h:66
struct pj_rbtree_node * right
Definition: rbtree.h:60
struct pj_rbtree_node * left
Definition: rbtree.h:57
Definition: rbtree.h:93
pj_rbtree_node * null
Definition: rbtree.h:95
unsigned size
Definition: rbtree.h:97
pj_rbtree_comp * comp
Definition: rbtree.h:98
pj_rbtree_node * root
Definition: rbtree.h:96
pj_rbtree_node null_node
Definition: rbtree.h:94
Declaration of basic types and utility.

 


PJLIB Open Source, high performance, small footprint, and very very portable framework
Copyright (C) 2006-2009 Teluu Inc.