ATLAS Offline Software
Macros | Typedefs | Functions
trie.h File Reference

Fast string lookups. More...

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define TRIE_NULL   ((void *) 0)
 A null TrieValue. More...
 

Typedefs

typedef struct _Trie Trie
 A trie structure. More...
 
typedef void * TrieValue
 Value stored in a Trie. More...
 

Functions

Trietrie_new (void)
 Create a new trie. More...
 
void trie_free (Trie *trie)
 Destroy a trie. More...
 
int trie_insert (Trie *trie, char *key, TrieValue value)
 Insert a new key-value pair into a trie. More...
 
TrieValue trie_lookup (Trie *trie, char *key)
 Look up a value from its key in a trie. More...
 
int trie_remove (Trie *trie, char *key)
 Remove an entry from a trie. More...
 
int trie_num_entries (Trie *trie)
 Find the number of entries in a trie. More...
 

Detailed Description

Fast string lookups.

A trie is a data structure which provides fast mappings from strings to values.

To create a new trie, use trie_new. To destroy a trie, use trie_free.

To insert a value into a trie, use trie_insert. To remove a value from a trie, use trie_remove.

To look up a value from its key, use trie_lookup.

To find the number of entries in a trie, use trie_num_entries.

Definition in file trie.h.

Macro Definition Documentation

◆ TRIE_NULL

#define TRIE_NULL   ((void *) 0)

A null TrieValue.

Definition at line 64 of file trie.h.

Typedef Documentation

◆ Trie

typedef struct _Trie Trie

A trie structure.

Definition at line 1 of file trie.h.

◆ TrieValue

typedef void* TrieValue

Value stored in a Trie.

Definition at line 57 of file trie.h.

Function Documentation

◆ trie_free()

void trie_free ( Trie trie)

Destroy a trie.

Parameters
trieThe trie to destroy.

◆ trie_insert()

int trie_insert ( Trie trie,
char *  key,
TrieValue  value 
)

Insert a new key-value pair into a trie.

Parameters
trieThe trie.
keyThe key to access the new value.
valueThe value.
Returns
Non-zero if the value was inserted successfully, or zero if it was not possible to allocate memory for the new entry.

◆ trie_lookup()

TrieValue trie_lookup ( Trie trie,
char *  key 
)

Look up a value from its key in a trie.

Parameters
trieThe trie.
keyThe key.
Returns
The value associated with the key, or TRIE_NULL if not found in the trie.

◆ trie_new()

Trie* trie_new ( void  )

Create a new trie.

Returns
Pointer to a new trie structure, or NULL if it was not possible to allocate memory for the new trie.

◆ trie_num_entries()

int trie_num_entries ( Trie trie)

Find the number of entries in a trie.

Parameters
trieThe trie.
Returns
Count of the number of entries in the trie.

◆ trie_remove()

int trie_remove ( Trie trie,
char *  key 
)

Remove an entry from a trie.

Parameters
trieThe trie.
keyThe key of the entry to remove.
Returns
Non-zero if the key was removed successfully, or zero if it is not present in the trie.