cr8r_avl_ft Struct Reference

Function table for avl tree. More...

#include <avl.h>

Data Fields

cr8r_base_ft base
 Base function table values (data and size)
 
int(* cmp )(const cr8r_base_ft *, const void *, const void *)
 Function to compare elements. More...
 
int(* add )(cr8r_base_ft *, void *, void *)
 Function to combine two elements. More...
 
void *(* alloc )(cr8r_base_ft *)
 Function to allocate a new node. More...
 
void(* free )(cr8r_base_ft *, void *)
 Function to deallocate a node.
 

Detailed Description

Function table for avl tree.

Imagine this struct as the class of the hash table. This struct specifies the size of the elements in an avl nodes in bytes, as well as how to perform necessary operations (compare, free, etc).

Definition at line 48 of file avl.h.

Field Documentation

◆ cmp

int(* cr8r_avl_ft::cmp) (const cr8r_base_ft *, const void *, const void *)

Function to compare elements.

Should only depend on "key" data within the elements. Should return <0 if the first operand is "smaller", 0 if the two operands are "equal", or >0 if the second operand is "smaller".

Definition at line 53 of file avl.h.

◆ add

int(* cr8r_avl_ft::add) (cr8r_base_ft *, void *, void *)

Function to combine two elements.

Should only depend on "value" data within the elements. Specifying this function can be used to define behavior when cr8r_avl_insert_update is called and an element with the given key already exists, such as adding the int values in any key->int map to create a counter. The first operand (second argument) is the element in the node already in the tree, the second operand is the element that was attempted to add. Should return nonzero on success, zero on failure.

Definition at line 59 of file avl.h.

◆ alloc

void*(* cr8r_avl_ft::alloc) (cr8r_base_ft *)

Function to allocate a new node.

This should allocate offsetof(cr8r_avl_node, data) + size bytes. The slab allocator in this library is designed to work well for allocating nodes

Definition at line 62 of file avl.h.


The documentation for this struct was generated from the following file: