Skip to content

Commit

Permalink
update documentation comments
Browse files Browse the repository at this point in the history
  • Loading branch information
dongyx committed Mar 1, 2023
1 parent db463c9 commit efcb69c
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions chtrie.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ typedef struct {
int maxn, alphsz, ecap;
} chtrie;

/* allocate a trie with at most `n` nodes, and the alphabet with size `m`
/* allocate a trie with at most `n` nodes, and the alphabet size `m`
*
* Symbols are defined to be non-negative integers less than `m`.
*
* Upon success, return a pointer to the trie.
* Otherwise, return `NULL` and set `errno`.
Expand All @@ -25,6 +27,10 @@ chtrie *chtrie_alloc(int n, int m);
* If the child didn't exist and `creat` is non-zero,
* a new node will be created.
*
* `from` must be a valid node index,
* and `sym` must be a non-negative integer less than the alphabet size,
* or the behavior is undefined.
*
* Upon success, return the index of the child.
* Otherwise, return -1.
*
Expand All @@ -36,7 +42,10 @@ int chtrie_walk(chtrie *tr, int from, int sym, int creat);
*
* If the child doesn't exist, the trie shall be left unchanged.
*
* The chile node must be a leaf, or the behavior is undefined.
* `from` must be a valid node index,
* and `sym` must be a non-negative integer less than the alphabet size,
* and the child node must be a leaf if it exists,
* or the behavior is undefined.
*/
void chtrie_del(chtrie *tr, int from, int sym);

Expand Down

0 comments on commit efcb69c

Please sign in to comment.