Skip to content

Commit 0f6dc76

Browse files
author
phishman3579
committed
Converted Trie and PatriciaTrie to use char instead of Char
git-svn-id: https://java-algorithms-implementation.googlecode.com/svn/trunk@408 032fbc0f-8cab-eb90-e552-f08422b9a96a
1 parent d62bf74 commit 0f6dc76

File tree

7 files changed

+133
-130
lines changed

7 files changed

+133
-130
lines changed

src/com/jwetherell/algorithms/data_structures/BTree.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -587,8 +587,7 @@ private T getKey(int index) {
587587

588588
private int indexOf(T value) {
589589
for (int i = 0; i < keysSize; i++) {
590-
if (keys[i].equals(value))
591-
return i;
590+
if (keys[i].equals(value)) return i;
592591
}
593592
return -1;
594593
}

src/com/jwetherell/algorithms/data_structures/CompactSuffixTrie.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,10 @@ public boolean add(C sequence) {
6060
public boolean doesSubStringExist(C sequence) {
6161
char[] chars = sequence.toString().toCharArray();
6262
int length = chars.length;
63-
PatriciaTrie.Node<C> current = tree.root;
63+
PatriciaTrie.Node current = tree.root;
6464
int index = 0;
6565
for (int i = 0; i < length; i++) {
66-
int innerStringLength = (current.string != null) ? current.string.length() : 0;
66+
int innerStringLength = (current.string != null) ? current.string.length : 0;
6767
char c = chars[i];
6868
if (innerStringLength > index) {
6969
boolean inThis = current.partOfThis(c, index++);
@@ -96,7 +96,7 @@ public Set<String> getSuffixes() {
9696
* to get all suffixes at.
9797
* @return set of suffixes in trie at node.
9898
*/
99-
private Set<String> getSuffixes(PatriciaTrie.Node<C> node) {
99+
private Set<String> getSuffixes(PatriciaTrie.Node node) {
100100
StringBuilder builder = new StringBuilder();
101101
if (node.string != null)
102102
builder.append(node.string);
@@ -105,7 +105,7 @@ private Set<String> getSuffixes(PatriciaTrie.Node<C> node) {
105105
set.add(builder.toString());
106106
}
107107
for (int i = 0; i < node.getChildrenSize(); i++) {
108-
PatriciaTrie.Node<C> c = node.getChild(i);
108+
PatriciaTrie.Node c = node.getChild(i);
109109
set.addAll(getSuffixes(c, builder.toString()));
110110
}
111111
return set;
@@ -120,7 +120,7 @@ private Set<String> getSuffixes(PatriciaTrie.Node<C> node) {
120120
* to prepend to suffixes.
121121
* @return set of suffixes in trie at node.
122122
*/
123-
private Set<String> getSuffixes(PatriciaTrie.Node<C> node, String prefix) {
123+
private Set<String> getSuffixes(PatriciaTrie.Node node, String prefix) {
124124
StringBuilder builder = new StringBuilder(prefix);
125125
if (node.string != null)
126126
builder.append(node.string);
@@ -129,7 +129,7 @@ private Set<String> getSuffixes(PatriciaTrie.Node<C> node, String prefix) {
129129
set.add(builder.toString());
130130
}
131131
for (int i = 0; i < node.getChildrenSize(); i++) {
132-
PatriciaTrie.Node<C> c = node.getChild(i);
132+
PatriciaTrie.Node c = node.getChild(i);
133133
set.addAll(getSuffixes(c, builder.toString()));
134134
}
135135
return set;

0 commit comments

Comments
 (0)