Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
Grpc
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
tci-gateway-module
Grpc
Commits
20d99c0c
Commit
20d99c0c
authored
9 years ago
by
Craig Tiller
Browse files
Options
Downloads
Patches
Plain Diff
AVL: add documentation
parent
0593622d
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
include/grpc/support/avl.h
+23
-0
23 additions, 0 deletions
include/grpc/support/avl.h
with
23 additions
and
0 deletions
include/grpc/support/avl.h
+
23
−
0
View file @
20d99c0c
...
...
@@ -36,6 +36,7 @@
#include
<grpc/support/sync.h>
/** internal node of an AVL tree */
typedef
struct
gpr_avl_node
{
gpr_refcount
refs
;
void
*
key
;
...
...
@@ -46,23 +47,45 @@ typedef struct gpr_avl_node {
}
gpr_avl_node
;
typedef
struct
gpr_avl_vtable
{
/** destroy a key */
void
(
*
destroy_key
)(
void
*
key
);
/** copy a key, returning new value */
void
*
(
*
copy_key
)(
void
*
key
);
/** compare key1, key2; return <0 if key1 < key2,
>0 if key1 > key2, 0 if key1 == key2 */
long
(
*
compare_keys
)(
void
*
key1
,
void
*
key2
);
/** destroy a value */
void
(
*
destroy_value
)(
void
*
value
);
/** copy a value */
void
*
(
*
copy_value
)(
void
*
value
);
}
gpr_avl_vtable
;
/** "pointer" to an AVL tree - this is a reference
counted object - use gpr_avl_ref to add a reference,
gpr_avl_unref when done with a reference */
typedef
struct
gpr_avl
{
const
gpr_avl_vtable
*
vtable
;
gpr_avl_node
*
root
;
}
gpr_avl
;
/** create an immutable AVL tree */
gpr_avl
gpr_avl_create
(
const
gpr_avl_vtable
*
vtable
);
/** add a reference to an existing tree - returns
the tree as a convenience */
gpr_avl
gpr_avl_ref
(
gpr_avl
avl
);
/** remove a reference to a tree - destroying it if there
are no references left */
void
gpr_avl_unref
(
gpr_avl
avl
);
/** return a new tree with (key, value) added to avl.
implicitly unrefs avl to allow easy chaining.
if key exists in avl, the new tree's key entry updated
(i.e. a duplicate is not created) */
gpr_avl
gpr_avl_add
(
gpr_avl
avl
,
void
*
key
,
void
*
value
);
/** return a new tree with key deleted */
gpr_avl
gpr_avl_remove
(
gpr_avl
avl
,
void
*
key
);
/** lookup key, and return the associated value.
does not mutate avl.
returns NULL if key is not found. */
void
*
gpr_avl_get
(
gpr_avl
avl
,
void
*
key
);
#endif
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment