@Test public void testAddSuffixesToRadixTree_DuplicateHandling() { LCSubstringSolver solver = new LCSubstringSolver(new DefaultCharSequenceNodeFactory()); solver.addSuffixesToRadixTree("FOO"); solver.addSuffixesToRadixTree("FOO"); String expected = "○\n" + "├── ○ FOO ([FOO])\n" + "└── ○ O ([FOO])\n" + " └── ○ O ([FOO])\n"; Assert.assertEquals(expected, PrettyPrinter.prettyPrint(solver.suffixTree)); }
void addSuffixesToRadixTree(String keyAsString) { Iterable<CharSequence> suffixes = CharSequences.generateSuffixes(keyAsString); for (CharSequence suffix : suffixes) { Set<String> originalKeyRefs = suffixTree.getValueForExactKey(suffix); if (originalKeyRefs == null) { originalKeyRefs = createSetForOriginalKeys(); suffixTree.put(suffix, originalKeyRefs); } originalKeyRefs.add(keyAsString); } }
LCSubstringSolver { void addSuffixesToRadixTree(String keyAsString) { Iterable<CharSequence> suffixes = CharSequences.generateSuffixes(keyAsString); for (CharSequence suffix : suffixes) { Set<String> originalKeyRefs = suffixTree.getValueForExactKey(suffix); if (originalKeyRefs == null) { originalKeyRefs = createSetForOriginalKeys(); suffixTree.put(suffix, originalKeyRefs); } originalKeyRefs.add(keyAsString); } } }
LCSubstringSolver { void addSuffixesToRadixTree(String keyAsString) { Iterable<CharSequence> suffixes = CharSequences.generateSuffixes(keyAsString); for (CharSequence suffix : suffixes) { Set<String> originalKeyRefs = suffixTree.getValueForExactKey(suffix); if (originalKeyRefs == null) { originalKeyRefs = createSetForOriginalKeys(); suffixTree.put(suffix, originalKeyRefs); } originalKeyRefs.add(keyAsString); } } LCSubstringSolver(NodeFactory nodeFactory); }
LCSubstringSolver { void addSuffixesToRadixTree(String keyAsString) { Iterable<CharSequence> suffixes = CharSequences.generateSuffixes(keyAsString); for (CharSequence suffix : suffixes) { Set<String> originalKeyRefs = suffixTree.getValueForExactKey(suffix); if (originalKeyRefs == null) { originalKeyRefs = createSetForOriginalKeys(); suffixTree.put(suffix, originalKeyRefs); } originalKeyRefs.add(keyAsString); } } LCSubstringSolver(NodeFactory nodeFactory); boolean add(CharSequence document); CharSequence getLongestCommonSubstring(); }
LCSubstringSolver { void addSuffixesToRadixTree(String keyAsString) { Iterable<CharSequence> suffixes = CharSequences.generateSuffixes(keyAsString); for (CharSequence suffix : suffixes) { Set<String> originalKeyRefs = suffixTree.getValueForExactKey(suffix); if (originalKeyRefs == null) { originalKeyRefs = createSetForOriginalKeys(); suffixTree.put(suffix, originalKeyRefs); } originalKeyRefs.add(keyAsString); } } LCSubstringSolver(NodeFactory nodeFactory); boolean add(CharSequence document); CharSequence getLongestCommonSubstring();  }