## DzlTrie DzlTrie — A generic prefix tree. |

## Functions

gboolean | (*DzlTrieTraverseFunc) ()
void | dzl_trie_destroy ()
void | dzl_trie_unref ()
DzlTrie * | dzl_trie_ref ()
void | dzl_trie_insert ()
gpointer | dzl_trie_lookup ()
DzlTrie * | dzl_trie_new ()
gboolean | dzl_trie_remove ()
void | dzl_trie_traverse ()

## Object Hierarchy

        GBoxed
        ╰── DzlTrie

## Description

The DzlTrie struct and its associated functions provide a DzlTrie data structure, where nodes in the tree can contain arbitrary data.

To create a new DzlTrie use `dzl_trie_new()`. You can free it with `dzl_trie_free()`. To insert a key and value pair into the DzlTrie use `dzl_trie_insert()`. To remove a key from the DzlTrie use `dzl_trie_remove()`. To traverse all children of the DzlTrie from a given key use `dzl_trie_traverse()`.

## Functions

### DzlTrieTraverseFunc ()

    gboolean
    (*DzlTrieTraverseFunc) (DzlTrie *dzl_trie,
                            const gchar *key,
                            gpointer value,
                            gpointer user_data);

### dzl_trie_destroy ()

    void
    dzl_trie_destroy (DzlTrie *trie);

This is an alias for `dzl_trie_unref()`.

#### Parameters

trie | A DzlTrie or `NULL`. |

### dzl_trie_unref ()

    void
    dzl_trie_unref (DzlTrie *trie);

Drops the reference count by one on `trie` . When it reaches zero, the structure is freed.

#### Parameters

trie | A DzlTrie or `NULL`. |

### dzl_trie_ref ()

    DzlTrie *
    dzl_trie_ref (DzlTrie *trie);

### dzl_trie_insert ()

    void
    dzl_trie_insert (DzlTrie *trie,
                     const gchar *key,
                     gpointer value);

Inserts `value` into `trie` located with `key` .

#### Parameters

trie | A DzlTrie. |
key | The key to insert. |
value | The value to insert. |

### dzl_trie_lookup ()

    gpointer
    dzl_trie_lookup (DzlTrie *trie,
                     const gchar *key);

Looks up `key` in `trie` and returns the value associated.

#### Parameters

trie | A DzlTrie. |
key | The key to lookup. |

#### Returns

The value inserted or `NULL`.

[transfer none]

### dzl_trie_new ()

    DzlTrie *
    dzl_trie_new (GDestroyNotify value_destroy);

Creates a new DzlTrie. When a value is removed from the trie, `value_destroy` will be called to allow you to release any resources.

#### Parameters

value_destroy | A GDestroyNotify, or `NULL`. |

#### Returns

A newly allocated DzlTrie that should be freed with `dzl_trie_unref()`.

[transfer full]

### dzl_trie_remove ()

    gboolean
    dzl_trie_remove (DzlTrie *trie,
                     const gchar *key);

Removes `key` from `trie` , possibly destroying the value associated with the key.

#### Parameters

trie | A DzlTrie. |
key | The key to remove. |

#### Returns

`TRUE` if `key` was found, otherwise `FALSE`.

### dzl_trie_traverse ()

    void
    dzl_trie_traverse (DzlTrie *trie,
                       const gchar *key,
                       GTraverseType order,
                       GTraverseFlags flags,
                       gint max_depth,
                       DzlTrieTraverseFunc func,
                       gpointer user_data);

Traverses all nodes of `trie` according to the parameters. For each node matching the traversal parameters, `func` will be executed.

Only `G_PRE_ORDER` and `G_POST_ORDER` are supported for `order` .

If `max_depth` is less than zero, the entire tree will be traversed. If max_depth is 1, then only the root will be traversed.

#### Parameters

trie | A DzlTrie. |
key | The key to start traversal from. |
order | The order to traverse. |
flags | The flags for which nodes to callback. |
max_depth | the maximum depth to process. |
func | The func to execute for each matching node. | [scope call][closure user_data]
user_data | User data for `func` . |