Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 025fca6

Browse files
Fix a root==null bug in the toString
1 parent dc60bca commit 025fca6

File tree

3 files changed

+6
-1
lines changed

3 files changed

+6
-1
lines changed

‎src/com/jwetherell/algorithms/data_structures/PatriciaTrie.java‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -524,6 +524,8 @@ protected static interface INodeCreator {
524524
protected static class PatriciaTriePrinter {
525525

526526
protected static <C extends CharSequence> String getString(PatriciaTrie<C> tree) {
527+
if (tree.root == null)
528+
return "Tree has no nodes.";
527529
return getString(tree.root, "", null, true);
528530
}
529531

‎src/com/jwetherell/algorithms/data_structures/Treap.java‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,8 @@ public String toString() {
182182
protected static class TreapPrinter {
183183

184184
public static <T extends Comparable<T>> String getString(Treap<T> tree) {
185-
if (tree.root == null) return "Tree has no nodes.";
185+
if (tree.root == null)
186+
return "Tree has no nodes.";
186187
return getString((TreapNode<T>) tree.root, "", true);
187188
}
188189

‎src/com/jwetherell/algorithms/data_structures/Trie.java‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -350,6 +350,8 @@ public static <C extends CharSequence> void print(Trie<C> trie) {
350350
}
351351

352352
public static <C extends CharSequence> String getString(Trie<C> tree) {
353+
if (tree.root == null)
354+
return "Tree has no nodes.";
353355
return getString(tree.root, "", null, true);
354356
}
355357

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /