C Collections

cbstmap · Section 3

cbstmap_create

cbstmap_create - create a BST map with default settings

C Collections (libccollections, -lccollections)

#include <ccollections/cbstmap.h>
 
cbmap cbstmap_create(ccol_data_type key_type, char **err);

Creates a self-balancing binary search tree map (an AVL tree) with the
default memory management and the default comparison for the key type.

key_type  Type of the keys that the map stores
err       Optional pointer that receives an error string on failure

A pointer to the new BST map on success, NULL on failure.

The default comparison depends on the key type:
  char: The platform's native char comparison, signed or unsigned to
  match how char behaves on this platform.
  The other signed integer types: A signed integer comparison.
  The unsigned integer types: An unsigned integer comparison.
  float, double and long double: A numeric comparison, in which a NaN key
  sorts above every non-NaN key and equal to every other NaN key.
  ccol_string: A lexicographic order equivalent to strcmp.
 
The map keeps the AVL balance, |height(left) - height(right)| <= 1, so
every operation is O(log n).
 
The caller must destroy the map with cbmap_destroy() after use.

cbstmap_create_full(3), cbstmap_create_mp(3), cbstmap_create_ch(3), cbmap_destroy(3), ccol_determine_ccol_data_type(3)