GRPC Core  18.0.0
Functions
avl.cc File Reference
#include <grpc/support/port_platform.h>
#include "src/core/lib/avl/avl.h"
#include <assert.h>
#include <stdlib.h>
#include <grpc/support/alloc.h>
#include <grpc/support/string_util.h>
#include "src/core/lib/gpr/useful.h"

Functions

grpc_avl grpc_avl_create (const grpc_avl_vtable *vtable)
 Create an immutable AVL tree. More...
 
grpc_avl_nodenew_node (void *key, void *value, grpc_avl_node *left, grpc_avl_node *right)
 
void * grpc_avl_get (grpc_avl avl, void *key, void *user_data)
 Lookup key, and return the associated value. More...
 
int grpc_avl_maybe_get (grpc_avl avl, void *key, void **value, void *user_data)
 Return 1 if avl contains key, 0 otherwise; if it has the key, sets *value to its value. More...
 
grpc_avl grpc_avl_add (grpc_avl avl, void *key, void *value, void *user_data)
 Return a new tree with (key, value) added to avl. More...
 
grpc_avl grpc_avl_remove (grpc_avl avl, void *key, void *user_data)
 Return a new tree with key deleted implicitly unrefs avl to allow easy chaining. More...
 
grpc_avl grpc_avl_ref (grpc_avl avl, void *)
 Add a reference to an existing tree - returns the tree as a convenience. More...
 
void grpc_avl_unref (grpc_avl avl, void *user_data)
 Remove a reference to a tree - destroying it if there are no references left. More...
 
int grpc_avl_is_empty (grpc_avl avl)
 Return 1 if avl is empty, 0 otherwise. More...
 

Function Documentation

◆ grpc_avl_add()

grpc_avl grpc_avl_add ( grpc_avl  avl,
void *  key,
void *  value,
void *  user_data 
)

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). The optional user_data will be passed to vtable functions.

◆ grpc_avl_create()

grpc_avl grpc_avl_create ( const grpc_avl_vtable vtable)

Create an immutable AVL tree.

◆ grpc_avl_get()

void* grpc_avl_get ( grpc_avl  avl,
void *  key,
void *  user_data 
)

Lookup key, and return the associated value.

Does not mutate avl. Returns NULL if key is not found. The optional user_data will be passed to vtable functions.

◆ grpc_avl_is_empty()

int grpc_avl_is_empty ( grpc_avl  avl)

Return 1 if avl is empty, 0 otherwise.

◆ grpc_avl_maybe_get()

int grpc_avl_maybe_get ( grpc_avl  avl,
void *  key,
void **  value,
void *  user_data 
)

Return 1 if avl contains key, 0 otherwise; if it has the key, sets *value to its value.

The optional user_data will be passed to vtable functions.

◆ grpc_avl_ref()

grpc_avl grpc_avl_ref ( grpc_avl  avl,
void *  user_data 
)

Add a reference to an existing tree - returns the tree as a convenience.

The optional user_data will be passed to vtable functions.

◆ grpc_avl_remove()

grpc_avl grpc_avl_remove ( grpc_avl  avl,
void *  key,
void *  user_data 
)

Return a new tree with key deleted implicitly unrefs avl to allow easy chaining.

The optional user_data will be passed to vtable functions.

◆ grpc_avl_unref()

void grpc_avl_unref ( grpc_avl  avl,
void *  user_data 
)

Remove a reference to a tree - destroying it if there are no references left.

The optional user_data will be passed to vtable functions.

◆ new_node()

grpc_avl_node* new_node ( void *  key,
void *  value,
grpc_avl_node left,
grpc_avl_node right 
)