Search in sources :

Example 21 with Trie

use of org.trie4j.Trie in project trie4j by takawitter.

the class IterateDoubleArrayNodesTest method test.

@Test
public void test() throws Exception {
    Trie t = new TailPatriciaTrie();
    for (String w : new String[] { "hello", "world", "java", "hell", "he" }) {
        t.insert(w);
    }
    DoubleArray da = new DoubleArray(t);
    Assert.assertTrue(da.contains("hello"));
    Assert.assertEquals(15, da.nodeSize());
    CountingVisitor c = new CountingVisitor();
    Algorithms.traverseByBreadth(da.getRoot(), c);
    Assert.assertEquals(15, c.getCount());
}
Also used : TailPatriciaTrie(org.trie4j.patricia.TailPatriciaTrie) TailPatriciaTrie(org.trie4j.patricia.TailPatriciaTrie) Trie(org.trie4j.Trie) PatriciaTrie(org.trie4j.patricia.PatriciaTrie) Test(org.junit.Test)

Aggregations

Trie (org.trie4j.Trie)21 Test (org.junit.Test)15 PatriciaTrie (org.trie4j.patricia.PatriciaTrie)11 Node (org.trie4j.Node)10 AbstractTermIdTrieTest (org.trie4j.AbstractTermIdTrieTest)7 ByteArrayInputStream (java.io.ByteArrayInputStream)5 ByteArrayOutputStream (java.io.ByteArrayOutputStream)5 LOUDSPPBvTree (org.trie4j.louds.bvtree.LOUDSPPBvTree)5 WikipediaTitles (org.trie4j.test.WikipediaTitles)5 ObjectInputStream (java.io.ObjectInputStream)4 ObjectOutputStream (java.io.ObjectOutputStream)4 SuffixTrieDenseTailArrayBuilder (org.trie4j.tail.SuffixTrieDenseTailArrayBuilder)4 LapTimer (org.trie4j.test.LapTimer)4 PrintWriter (java.io.PrintWriter)3 MapTrie (org.trie4j.MapTrie)3 MapPatriciaTrie (org.trie4j.patricia.MapPatriciaTrie)3 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)2 AbstractImmutableTrieTest (org.trie4j.AbstractImmutableTrieTest)2 NodeVisitor (org.trie4j.NodeVisitor)2 LongsRank0OnlySuccinctBitVector (org.trie4j.bv.LongsRank0OnlySuccinctBitVector)2