/** * returns the common prefix for all the items in the list. * * @param list the list to return the common prefix for * @return the common prefix of all the items */ public String getCommonPrefix(Vector<String> list) { String result; Trie trie; trie = new Trie(); trie.addAll(list); result = trie.getCommonPrefix(); if (m_Debug) { System.out.println(list + "\n --> common prefix: '" + result + "'"); } return result; } }
/** * returns the common prefix for all the items in the list. * * @param list the list to return the common prefix for * @return the common prefix of all the items */ public String getCommonPrefix(Vector<String> list) { String result; Trie trie; trie = new Trie(); trie.addAll(list); result = trie.getCommonPrefix(); if (m_Debug) { System.out.println(list + "\n --> common prefix: '" + result + "'"); } return result; } }
/** * tests whether the common prefix is determined correctly */ public void testCommonPrefix() { String returned = m_Trie.getCommonPrefix(); assertEquals("Common prefixes differ", 0, returned.length()); String expected = "this is a"; Trie t = buildTrie(new String[]{m_Data[0], m_Data[1]}); returned = t.getCommonPrefix(); assertEquals("Common prefixes differ", expected.length(), returned.length()); }
/** * tests whether the common prefix is determined correctly */ public void testCommonPrefix() { String returned = m_Trie.getCommonPrefix(); assertEquals("Common prefixes differ", 0, returned.length()); String expected = "this is a"; Trie t = buildTrie(new String[]{m_Data[0], m_Data[1]}); returned = t.getCommonPrefix(); assertEquals("Common prefixes differ", expected.length(), returned.length()); }