/** * creates a deep copy of itself * * @return a deep copy of itself */ @Override public Object clone() { TrieNode result; Enumeration<Character> keys; Character key; TrieNode child; result = new TrieNode(getChar()); keys = m_Children.keys(); while (keys.hasMoreElements()) { key = keys.nextElement(); child = (TrieNode) m_Children.get(key).clone(); result.add(child); result.m_Children.put(key, child); } return result; }
/** * creates a deep copy of itself * * @return a deep copy of itself */ @Override public Object clone() { TrieNode result; Enumeration<Character> keys; Character key; TrieNode child; result = new TrieNode(getChar()); keys = m_Children.keys(); while (keys.hasMoreElements()) { key = keys.nextElement(); child = (TrieNode) m_Children.get(key).clone(); result.add(child); result.m_Children.put(key, child); } return result; }
/** * adds the given charater to its children * * @param c the character to add * @return the generated child node */ protected TrieNode add(Character c) { TrieNode child; child = new TrieNode(c); add(child); m_Children.put(c, child); return child; }
/** * adds the given charater to its children * * @param c the character to add * @return the generated child node */ protected TrieNode add(Character c) { TrieNode child; child = new TrieNode(c); add(child); m_Children.put(c, child); return child; }
/** * initializes the data structure */ public Trie() { super(); m_Root = new TrieNode(null); m_RecalcHashCode = true; }
/** * initializes the data structure */ public Trie() { super(); m_Root = new TrieNode(null); m_RecalcHashCode = true; }