Implemented HAT trie longest prefix match + tests.
General idea is regular search with keeping node stack. If node is found, then return current node. If node is htable, search for suffixes in htable. If anything fails, walk up the visited nodes and check if any visited node has value. If yes, then it is a prefix. f.e. searching for 'abcd' visited nodes: root -a-> {1:trie} -b-> {2:htable} 1. search htable for 'cd', 'c' 2. retrace to node {1}, does it have value? 3. yes, node1 is prefix 'ab' for 'abcd' Change-Id: I622adbe9a127d8317b933af4bf56e1411e2d915f
Showing
- Knot.files 2 additions, 0 deletionsKnot.files
- src/Makefile.am 2 additions, 0 deletionssrc/Makefile.am
- src/common/hattrie/hat-trie.c 49 additions, 0 deletionssrc/common/hattrie/hat-trie.c
- src/common/hattrie/hat-trie.h 4 additions, 0 deletionssrc/common/hattrie/hat-trie.h
- src/tests/common/hattrie_tests.c 160 additions, 0 deletionssrc/tests/common/hattrie_tests.c
- src/tests/common/hattrie_tests.h 25 additions, 0 deletionssrc/tests/common/hattrie_tests.h
- src/tests/unittests_main.c 3 additions, 1 deletionsrc/tests/unittests_main.c
Loading
Please register or sign in to comment