Newer
Older
package main;
import cse332.interfaces.trie.TrieMap;
import cse332.interfaces.trie.TrieSet;
import cse332.types.*;
import datastructures.dictionaries.HashTrieMap;
import datastructures.dictionaries.HashTrieSet;
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
public class TrieTest {
public static void main(String[] args) {
System.out.println("Here we go...");
TrieMap<Character, AlphabeticString, String> map = new HashTrieMap<Character, AlphabeticString, String>(AlphabeticString.class);
for (char a : new char[]{'a', 'b', 'c'}) {
for (char b : new char[]{'a', 'b', 'c'}) {
for (char c : new char[]{'a', 'b', 'c'}) {
String s = "" + a + b + c;
map.insert(new AlphabeticString(s), s.toUpperCase());
}
}
}
System.out.println(map);
for (char a : new char[]{'a', 'b', 'c', 'd'}) {
for (char b : new char[]{'a', 'b', 'c', 'd'}) {
for (char c : new char[]{'a', 'b', 'c', 'd'}) {
String s = "" + a + b + c;
System.out.println("find(" + s + "): " + map.find(new AlphabeticString(s)));
System.out.println("size: " + map.size());
map.delete(new AlphabeticString(s));
System.out.println("find(" + s + "): " + map.find(new AlphabeticString(s)));
System.out.println("size: " + map.size());
}
}
}
TrieSet<Byte, ByteString> trie = new HashTrieSet<Byte, ByteString>(ByteString.class);
trie.add(new ByteString("adam"));
trie.add(new ByteString("ada"));
trie.add(new ByteString("apple"));
trie.add(new ByteString("app"));
trie.add(new ByteString("add"));
trie.add(new ByteString("ads"));
System.out.println(trie);
for (ByteString s : trie) {
System.out.println(s);
}
}
}