LMMS
Loading...
Searching...
No Matches
Zix

Macros

#define ZIX_LOG_FUNC(fmt, arg1)
#define ZIX_UNUSED(name)
#define ZIX_LOG_FUNC(fmt, arg1)
#define ZIX_UNUSED(name)

Typedefs

typedef int(* ZixComparator) (const void *a, const void *b, const void *user_data)
typedef bool(* ZixEqualFunc) (const void *a, const void *b)
typedef void(* ZixDestroyFunc) (void *ptr)
typedef int(* ZixComparator) (const void *a, const void *b, const void *user_data)
typedef bool(* ZixEqualFunc) (const void *a, const void *b)
typedef void(* ZixDestroyFunc) (void *ptr)
typedef int(* ZixComparator) (const void *a, const void *b, void *user_data)
typedef bool(* ZixEqualFunc) (const void *a, const void *b)
typedef void(* ZixDestroyFunc) (void *ptr)
typedef int(* ZixComparator) (const void *a, const void *b, void *user_data)
typedef bool(* ZixEqualFunc) (const void *a, const void *b)
typedef void(* ZixDestroyFunc) (void *ptr)

Enumerations

enum  ZixStatus {
  ZIX_STATUS_SUCCESS , ZIX_STATUS_ERROR , ZIX_STATUS_NO_MEM , ZIX_STATUS_NOT_FOUND ,
  ZIX_STATUS_EXISTS , ZIX_STATUS_BAD_ARG , ZIX_STATUS_BAD_PERMS
}
enum  ZixStatus {
  ZIX_STATUS_SUCCESS , ZIX_STATUS_ERROR , ZIX_STATUS_NO_MEM , ZIX_STATUS_NOT_FOUND ,
  ZIX_STATUS_EXISTS , ZIX_STATUS_BAD_ARG , ZIX_STATUS_BAD_PERMS
}
enum  ZixStatus {
  ZIX_STATUS_SUCCESS , ZIX_STATUS_ERROR , ZIX_STATUS_NO_MEM , ZIX_STATUS_NOT_FOUND ,
  ZIX_STATUS_EXISTS , ZIX_STATUS_BAD_ARG , ZIX_STATUS_BAD_PERMS
}
enum  ZixStatus {
  ZIX_STATUS_SUCCESS , ZIX_STATUS_ERROR , ZIX_STATUS_NO_MEM , ZIX_STATUS_NOT_FOUND ,
  ZIX_STATUS_EXISTS , ZIX_STATUS_BAD_ARG , ZIX_STATUS_BAD_PERMS
}

Functions

static const char * zix_strerror (const ZixStatus status)

Tree

typedef struct ZixTreeImpl ZixTree
typedef struct ZixTreeNodeImpl ZixTreeIter
ZIX_API ZixTreezix_tree_new (bool allow_duplicates, ZixComparator cmp, void *cmp_data, ZixDestroyFunc destroy)
ZIX_API void zix_tree_free (ZixTree *t)
ZIX_PURE_API size_t zix_tree_size (const ZixTree *t)
ZIX_API ZixStatus zix_tree_insert (ZixTree *t, void *e, ZixTreeIter **ti)
ZIX_API ZixStatus zix_tree_remove (ZixTree *t, ZixTreeIter *ti)
ZIX_API ZixStatus zix_tree_find (const ZixTree *t, const void *e, ZixTreeIter **ti)
ZIX_PURE_API voidzix_tree_get (const ZixTreeIter *ti)
ZIX_PURE_API ZixTreeIterzix_tree_begin (ZixTree *t)
ZIX_CONST_API ZixTreeIterzix_tree_end (ZixTree *t)
ZIX_CONST_API bool zix_tree_iter_is_end (const ZixTreeIter *i)
ZIX_PURE_API ZixTreeIterzix_tree_rbegin (ZixTree *t)
ZIX_CONST_API ZixTreeIterzix_tree_rend (ZixTree *t)
ZIX_CONST_API bool zix_tree_iter_is_rend (const ZixTreeIter *i)
ZIX_PURE_API ZixTreeIterzix_tree_iter_next (ZixTreeIter *i)
ZIX_PURE_API ZixTreeIterzix_tree_iter_prev (ZixTreeIter *i)

BTree

typedef struct ZixBTreeImpl ZixBTree
typedef struct ZixBTreeNodeImpl ZixBTreeNode
typedef struct ZixBTreeIterImpl ZixBTreeIter
ZIX_API ZixBTreezix_btree_new (ZixComparator cmp, const void *cmp_data, ZixDestroyFunc destroy)
ZIX_API void zix_btree_free (ZixBTree *t)
ZIX_PURE_API size_t zix_btree_size (const ZixBTree *t)
ZIX_API ZixStatus zix_btree_insert (ZixBTree *t, void *e)
ZIX_API ZixStatus zix_btree_remove (ZixBTree *t, const void *e, void **out, ZixBTreeIter **next)
ZIX_API ZixStatus zix_btree_find (const ZixBTree *t, const void *e, ZixBTreeIter **ti)
ZIX_API ZixStatus zix_btree_lower_bound (const ZixBTree *t, const void *e, ZixBTreeIter **ti)
ZIX_PURE_API voidzix_btree_get (const ZixBTreeIter *ti)
ZIX_PURE_API ZixBTreeIterzix_btree_begin (const ZixBTree *t)
ZIX_API ZixBTreeIterzix_btree_end (const ZixBTree *t)
ZIX_API ZixBTreeIterzix_btree_iter_copy (const ZixBTreeIter *i)
ZIX_PURE_API bool zix_btree_iter_equals (const ZixBTreeIter *lhs, const ZixBTreeIter *rhs)
ZIX_PURE_API bool zix_btree_iter_is_end (const ZixBTreeIter *i)
ZIX_API void zix_btree_iter_increment (ZixBTreeIter *i)
ZIX_API void zix_btree_iter_free (ZixBTreeIter *i)

Hash

typedef struct ZixHashImpl ZixHash
typedef uint32_t(* ZixHashFunc) (const void *value)
typedef void(* ZixHashVisitFunc) (void *value, void *user_data)
ZIX_API ZixHashzix_hash_new (ZixHashFunc hash_func, ZixEqualFunc equal_func, size_t value_size)
ZIX_API void zix_hash_free (ZixHash *hash)
ZIX_PURE_API size_t zix_hash_size (const ZixHash *hash)
ZIX_API ZixStatus zix_hash_insert (ZixHash *hash, const void *value, void **inserted)
ZIX_API ZixStatus zix_hash_remove (ZixHash *hash, const void *value)
ZIX_API voidzix_hash_find (const ZixHash *hash, const void *value)
ZIX_API void zix_hash_foreach (ZixHash *hash, ZixHashVisitFunc f, void *user_data)

Tree

typedef struct ZixTreeImpl ZixTree
typedef struct ZixTreeNodeImpl ZixTreeIter

BTree

typedef struct ZixBTreeImpl ZixBTree
typedef struct ZixBTreeNodeImpl ZixBTreeNode
typedef struct ZixBTreeIterImpl ZixBTreeIter
ZIX_API ZixBTreezix_btree_new (ZixComparator cmp, void *cmp_data, ZixDestroyFunc destroy)

Hash

typedef struct ZixHashImpl ZixHash
typedef uint32_t(* ZixHashFunc) (const void *value)
typedef void(* ZixHashVisitFunc) (void *value, void *user_data)
ZIX_API ZixStatus zix_hash_insert (ZixHash *hash, const void *value, const void **inserted)

Detailed Description

Macro Definition Documentation

◆ ZIX_LOG_FUNC [1/2]

#define ZIX_LOG_FUNC ( fmt,
arg1 )

◆ ZIX_LOG_FUNC [2/2]

#define ZIX_LOG_FUNC ( fmt,
arg1 )

◆ ZIX_UNUSED [1/2]

#define ZIX_UNUSED ( name)
Value:
static const char * name
Definition pugl.h:1582

◆ ZIX_UNUSED [2/2]

#define ZIX_UNUSED ( name)
Value:

Typedef Documentation

◆ ZixBTree [1/2]

typedef struct ZixBTreeImpl ZixBTree

A B-Tree.

◆ ZixBTree [2/2]

typedef struct ZixBTreeImpl ZixBTree

A B-Tree.

◆ ZixBTreeIter [1/2]

An iterator over a B-Tree.

Note that modifying the trees invalidates all iterators, so all iterators are const iterators.

◆ ZixBTreeIter [2/2]

An iterator over a B-Tree.

Note that modifying the trees invalidates all iterators, so all iterators are const iterators.

◆ ZixBTreeNode [1/2]

A B-Tree node (opaque).

◆ ZixBTreeNode [2/2]

A B-Tree node (opaque).

◆ ZixComparator [1/4]

typedef int(* ZixComparator) (const void *a, const void *b, const void *user_data)

Function for comparing two elements.

◆ ZixComparator [2/4]

typedef int(* ZixComparator) (const void *a, const void *b, const void *user_data)

Function for comparing two elements.

◆ ZixComparator [3/4]

typedef int(* ZixComparator) (const void *a, const void *b, void *user_data)

Function for comparing two elements.

◆ ZixComparator [4/4]

typedef int(* ZixComparator) (const void *a, const void *b, void *user_data)

Function for comparing two elements.

◆ ZixDestroyFunc [1/4]

typedef void(* ZixDestroyFunc) (void *ptr)

Function to destroy an element.

◆ ZixDestroyFunc [2/4]

typedef void(* ZixDestroyFunc) (void *ptr)

Function to destroy an element.

◆ ZixDestroyFunc [3/4]

typedef void(* ZixDestroyFunc) (void *ptr)

Function to destroy an element.

◆ ZixDestroyFunc [4/4]

typedef void(* ZixDestroyFunc) (void *ptr)

Function to destroy an element.

◆ ZixEqualFunc [1/4]

typedef bool(* ZixEqualFunc) (const void *a, const void *b)

Function for testing equality of two elements.

◆ ZixEqualFunc [2/4]

typedef bool(* ZixEqualFunc) (const void *a, const void *b)

Function for testing equality of two elements.

◆ ZixEqualFunc [3/4]

typedef bool(* ZixEqualFunc) (const void *a, const void *b)

Function for testing equality of two elements.

◆ ZixEqualFunc [4/4]

typedef bool(* ZixEqualFunc) (const void *a, const void *b)

Function for testing equality of two elements.

◆ ZixHash [1/2]

typedef struct ZixHashImpl ZixHash

◆ ZixHash [2/2]

typedef struct ZixHashImpl ZixHash

◆ ZixHashFunc [1/2]

typedef uint32_t(* ZixHashFunc) (const void *value)

Function for computing the hash of an element.

◆ ZixHashFunc [2/2]

typedef uint32_t(* ZixHashFunc) (const void *value)

Function for computing the hash of an element.

◆ ZixHashVisitFunc [1/2]

typedef void(* ZixHashVisitFunc) (void *value, void *user_data)

Function to visit a hash element.

◆ ZixHashVisitFunc [2/2]

typedef void(* ZixHashVisitFunc) (void *value, void *user_data)

Function to visit a hash element.

◆ ZixTree [1/2]

typedef struct ZixTreeImpl ZixTree

A balanced binary search tree.

◆ ZixTree [2/2]

typedef struct ZixTreeImpl ZixTree

A balanced binary search tree.

◆ ZixTreeIter [1/2]

typedef struct ZixTreeNodeImpl ZixTreeIter

An iterator over a ZixTree.

◆ ZixTreeIter [2/2]

typedef struct ZixTreeNodeImpl ZixTreeIter

An iterator over a ZixTree.

Enumeration Type Documentation

◆ ZixStatus [1/4]

enum ZixStatus
Enumerator
ZIX_STATUS_SUCCESS 
ZIX_STATUS_ERROR 
ZIX_STATUS_NO_MEM 
ZIX_STATUS_NOT_FOUND 
ZIX_STATUS_EXISTS 
ZIX_STATUS_BAD_ARG 
ZIX_STATUS_BAD_PERMS 

◆ ZixStatus [2/4]

enum ZixStatus
Enumerator
ZIX_STATUS_SUCCESS 
ZIX_STATUS_ERROR 
ZIX_STATUS_NO_MEM 
ZIX_STATUS_NOT_FOUND 
ZIX_STATUS_EXISTS 
ZIX_STATUS_BAD_ARG 
ZIX_STATUS_BAD_PERMS 

◆ ZixStatus [3/4]

enum ZixStatus
Enumerator
ZIX_STATUS_SUCCESS 
ZIX_STATUS_ERROR 
ZIX_STATUS_NO_MEM 
ZIX_STATUS_NOT_FOUND 
ZIX_STATUS_EXISTS 
ZIX_STATUS_BAD_ARG 
ZIX_STATUS_BAD_PERMS 

◆ ZixStatus [4/4]

enum ZixStatus
Enumerator
ZIX_STATUS_SUCCESS 
ZIX_STATUS_ERROR 
ZIX_STATUS_NO_MEM 
ZIX_STATUS_NOT_FOUND 
ZIX_STATUS_EXISTS 
ZIX_STATUS_BAD_ARG 
ZIX_STATUS_BAD_PERMS 

Function Documentation

◆ zix_btree_begin()

ZIX_PURE_API ZixBTreeIter * zix_btree_begin ( const ZixBTree * t)

Return an iterator to the first (smallest) element in t.

The returned iterator must be freed with zix_btree_iter_free().

◆ zix_btree_end()

ZIX_API ZixBTreeIter * zix_btree_end ( const ZixBTree * t)

Return an iterator to the end of t (one past the last element).

The returned iterator must be freed with zix_btree_iter_free().

◆ zix_btree_find()

ZIX_API ZixStatus zix_btree_find ( const ZixBTree * t,
const void * e,
ZixBTreeIter ** ti )

Set ti to an element equal to e in t. If no such item exists, ti is set to NULL.

◆ zix_btree_free()

ZIX_API void zix_btree_free ( ZixBTree * t)

Free t.

◆ zix_btree_get()

ZIX_PURE_API void * zix_btree_get ( const ZixBTreeIter * ti)

Return the data associated with the given tree item.

◆ zix_btree_insert()

ZIX_API ZixStatus zix_btree_insert ( ZixBTree * t,
void * e )

Insert the element e into t.

◆ zix_btree_iter_copy()

ZIX_API ZixBTreeIter * zix_btree_iter_copy ( const ZixBTreeIter * i)

Return a new copy of i.

◆ zix_btree_iter_equals()

ZIX_PURE_API bool zix_btree_iter_equals ( const ZixBTreeIter * lhs,
const ZixBTreeIter * rhs )

Return true iff lhs is equal to rhs.

◆ zix_btree_iter_free()

ZIX_API void zix_btree_iter_free ( ZixBTreeIter * i)

Free i.

◆ zix_btree_iter_increment()

ZIX_API void zix_btree_iter_increment ( ZixBTreeIter * i)

Increment i to point to the next element in the tree.

◆ zix_btree_iter_is_end()

ZIX_PURE_API bool zix_btree_iter_is_end ( const ZixBTreeIter * i)

Return true iff i is an iterator to the end of its tree.

◆ zix_btree_lower_bound()

ZIX_API ZixStatus zix_btree_lower_bound ( const ZixBTree * t,
const void * e,
ZixBTreeIter ** ti )

Set ti to the smallest element in t that is not less than e.

Wildcards are supported, so if the search key e compares equal to many values in the tree, ti will be set to the least such element. The search key e is always passed as the second argument to the comparator.

◆ zix_btree_new() [1/2]

ZIX_API ZixBTree * zix_btree_new ( ZixComparator cmp,
const void * cmp_data,
ZixDestroyFunc destroy )

Create a new (empty) B-Tree.

◆ zix_btree_new() [2/2]

ZIX_API ZixBTree * zix_btree_new ( ZixComparator cmp,
void * cmp_data,
ZixDestroyFunc destroy )

Create a new (empty) B-Tree.

◆ zix_btree_remove()

ZIX_API ZixStatus zix_btree_remove ( ZixBTree * t,
const void * e,
void ** out,
ZixBTreeIter ** next )

Remove the value e from t.

Parameters
tTree to remove from.
eValue to remove.
outSet to point to the removed pointer (which may not equal e).
nextIf non-NULL, pointed to the value following e. If *next is also non-NULL, the iterator is reused, otherwise a new one is allocated. To reuse an iterator, no items may have been added since its creation.

◆ zix_btree_size()

ZIX_PURE_API size_t zix_btree_size ( const ZixBTree * t)

Return the number of elements in t.

◆ zix_hash_find()

ZIX_API void * zix_hash_find ( const ZixHash * hash,
const void * value )

Search for an item in hash.

Parameters
hashThe hash table.
valueThe value to search for.

◆ zix_hash_foreach()

ZIX_API void zix_hash_foreach ( ZixHash * hash,
ZixHashVisitFunc f,
void * user_data )

Call f on each value in hash.

Parameters
hashThe hash table.
fThe function to call on each value.
user_dataThe user_data parameter passed to f.

◆ zix_hash_free()

ZIX_API void zix_hash_free ( ZixHash * hash)

Free hash.

◆ zix_hash_insert() [1/2]

ZIX_API ZixStatus zix_hash_insert ( ZixHash * hash,
const void * value,
const void ** inserted )

Insert an item into hash.

If no matching value is found, ZIX_STATUS_SUCCESS will be returned, and inserted will be pointed to the copy of value made in the new hash node.

If a matching value already exists, ZIX_STATUS_EXISTS will be returned, and inserted will be pointed to the existing value.

Parameters
hashThe hash table.
valueThe value to be inserted.
insertedThe copy of value in the hash table.
Returns
ZIX_STATUS_SUCCESS, ZIX_STATUS_EXISTS, or ZIX_STATUS_NO_MEM.

◆ zix_hash_insert() [2/2]

ZIX_API ZixStatus zix_hash_insert ( ZixHash * hash,
const void * value,
void ** inserted )

Insert an item into hash.

If no matching value is found, ZIX_STATUS_SUCCESS will be returned, and inserted will be pointed to the copy of value made in the new hash node.

If a matching value already exists, ZIX_STATUS_EXISTS will be returned, and inserted will be pointed to the existing value.

Parameters
hashThe hash table.
valueThe value to be inserted.
insertedThe copy of value in the hash table.
Returns
ZIX_STATUS_SUCCESS, ZIX_STATUS_EXISTS, or ZIX_STATUS_NO_MEM.

◆ zix_hash_new()

ZIX_API ZixHash * zix_hash_new ( ZixHashFunc hash_func,
ZixEqualFunc equal_func,
size_t value_size )

Create a new hash table.

To minimize space overhead, unlike many hash tables this stores a single value, not a key and a value. Any size of value can be stored, but all the values in the hash table must be the same size, and the values must be safe to copy with memcpy. To get key:value behaviour, simply insert a struct with a key and value into the hash.

Parameters
hash_funcThe hashing function.
equal_funcA function to test value equality.
value_sizeThe size of the values to be stored.

◆ zix_hash_remove()

ZIX_API ZixStatus zix_hash_remove ( ZixHash * hash,
const void * value )

Remove an item from hash.

Parameters
hashThe hash table.
valueThe value to remove.
Returns
ZIX_STATUS_SUCCES or ZIX_STATUS_NOT_FOUND.

◆ zix_hash_size()

ZIX_PURE_API size_t zix_hash_size ( const ZixHash * hash)

Return the number of elements in hash.

◆ zix_strerror()

const char * zix_strerror ( const ZixStatus status)
inlinestatic

◆ zix_tree_begin()

ZIX_PURE_API ZixTreeIter * zix_tree_begin ( ZixTree * t)

Return an iterator to the first (smallest) element in t.

◆ zix_tree_end()

ZIX_API ZixTreeIter * zix_tree_end ( ZixTree * t)

Return an iterator the the element one past the last element in t.

◆ zix_tree_find()

ZIX_API ZixStatus zix_tree_find ( const ZixTree * t,
const void * e,
ZixTreeIter ** ti )

Set ti to an element equal to e in t. If no such item exists, ti is set to NULL.

◆ zix_tree_free()

ZIX_API void zix_tree_free ( ZixTree * t)

Free t.

◆ zix_tree_get()

ZIX_PURE_API void * zix_tree_get ( const ZixTreeIter * ti)

Return the data associated with the given tree item.

◆ zix_tree_insert()

ZIX_API ZixStatus zix_tree_insert ( ZixTree * t,
void * e,
ZixTreeIter ** ti )

Insert the element e into t and point ti at the new element.

◆ zix_tree_iter_is_end()

ZIX_CONST_API bool zix_tree_iter_is_end ( const ZixTreeIter * i)

Return true iff i is an iterator to the end of its tree.

◆ zix_tree_iter_is_rend()

ZIX_CONST_API bool zix_tree_iter_is_rend ( const ZixTreeIter * i)

Return true iff i is an iterator to the reverse end of its tree.

◆ zix_tree_iter_next()

ZIX_PURE_API ZixTreeIter * zix_tree_iter_next ( ZixTreeIter * i)

Return an iterator that points to the element one past i.

◆ zix_tree_iter_prev()

ZIX_PURE_API ZixTreeIter * zix_tree_iter_prev ( ZixTreeIter * i)

Return an iterator that points to the element one before i.

◆ zix_tree_new()

ZIX_API ZixTree * zix_tree_new ( bool allow_duplicates,
ZixComparator cmp,
void * cmp_data,
ZixDestroyFunc destroy )

Create a new (empty) tree.

◆ zix_tree_rbegin()

ZIX_PURE_API ZixTreeIter * zix_tree_rbegin ( ZixTree * t)

Return an iterator to the last (largest) element in t.

◆ zix_tree_remove()

ZIX_API ZixStatus zix_tree_remove ( ZixTree * t,
ZixTreeIter * ti )

Remove the item pointed at by ti from t.

◆ zix_tree_rend()

ZIX_API ZixTreeIter * zix_tree_rend ( ZixTree * t)

Return an iterator the the element one before the first element in t.

◆ zix_tree_size()

ZIX_PURE_API size_t zix_tree_size ( const ZixTree * t)

Return the number of elements in t.