#include <antlr3collections.h>
For this particular implementation, as you might expect, the key is turned into a "string" by looking at bit(key, depth) of the integer key. Using 64 bit keys gives us a depth limit of 64 (or bit 0..63) and potentially a huge trie. This is the algorithm for a Patricia Trie. Note also that this trie [can] accept multiple entries for the same key and is therefore a kind of elastic bucket patricia trie.
If you find this code useful, please feel free to 'steal' it for any purpose as covered by the BSD license under which ANTLR is issued. You can cut the code but as the ANTLR library is only about 50K (Windows Vista), you might find it easier to just link the library. Please keep all comments and licenses and so on in any version of this you create of course.
Jim Idle.
Data Fields | |
ANTLR3_BOOLEAN(* | add )(struct ANTLR3_INT_TRIE_struct *trie, ANTLR3_INTKEY key, ANTLR3_UINT32 type, ANTLR3_INTKEY intVal, void *data, void(ANTLR3_CDECL *freeptr)(void *)) |
ANTLR3_BOOLEAN | allowDups |
ANTLR3_UINT32 | count |
pANTLR3_INT_TRIE_NODE | current |
ANTLR3_BOOLEAN(* | del )(struct ANTLR3_INT_TRIE_struct *trie, ANTLR3_INTKEY key) |
void(* | free )(struct ANTLR3_INT_TRIE_struct *trie) |
pANTLR3_TRIE_ENTRY(* | get )(struct ANTLR3_INT_TRIE_struct *trie, ANTLR3_INTKEY key) |
pANTLR3_INT_TRIE_NODE | root |
ANTLR3_BOOLEAN(* ANTLR3_INT_TRIE_struct::add)(struct ANTLR3_INT_TRIE_struct *trie, ANTLR3_INTKEY key, ANTLR3_UINT32 type, ANTLR3_INTKEY intVal, void *data, void(ANTLR3_CDECL *freeptr)(void *)) |
Referenced by antlr3IntTrieNew(), getRuleMemoization(), and memoize().
Referenced by intTrieAdd().
Referenced by antlr3IntTrieNew(), intTrieAdd(), and intTrieGet().
ANTLR3_BOOLEAN(* ANTLR3_INT_TRIE_struct::del)(struct ANTLR3_INT_TRIE_struct *trie, ANTLR3_INTKEY key) |
Referenced by antlr3IntTrieNew().
void(* ANTLR3_INT_TRIE_struct::free)(struct ANTLR3_INT_TRIE_struct *trie) |
Referenced by antlr3IntTrieNew(), freeBR(), and reset().
pANTLR3_TRIE_ENTRY(* ANTLR3_INT_TRIE_struct::get)(struct ANTLR3_INT_TRIE_struct *trie, ANTLR3_INTKEY key) |
Referenced by antlr3IntTrieNew(), getRuleMemoization(), and memoize().
Referenced by antlr3IntTrieNew(), intTrieAdd(), intTrieDel(), intTrieFree(), and intTrieGet().