|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object edu.ksu.cis.viewer.PatriciaTrie
An immutable Patricia trie that can draw itself. The trie is immutable in the sense that any PatriciaTrie returned by a public constructor or method cannot subsequently be changed. A Patricia trie contains a set of strings. Each subtree stores in its root the longest common prefix of all strings contained within that subtree. For each string stored in the subtree, a suffix is computed by removing the prefix stored in the root. If there is more than one such suffix, each of the suffixes is stored in one of the children, a different child for each distinct character beginning a suffix, plus a child for the empty suffix if it is present. Note that according to these rules, no node other than the root or a leaf will store an empty string.
Constructor Summary | |
PatriciaTrie()
Constructs an empty PatriciaTrie. |
Method Summary | |
Object |
clone()
Because this structure is immutable, this method simply returns this PatriciaTrie. |
TreeInterface[] |
getChildren()
Returns the children of this PatriciaTrie. |
JComponent |
getDrawing()
Returns a drawing of this PatriciaTrie. |
JComponent |
getDrawing(Font fnt)
Returns a drawing of this tree using the given Font. |
Object |
getRoot()
Returns the root of this PatriciaTrie. |
boolean |
isEmpty()
Returns true if this PatriciaTrie is empty. |
BSTInterface |
put(String key)
Returns the PatriciaTrie resulting from the insertion of key into this PatriciaTrie. |
BSTInterface |
remove(String key)
Returns the PatriciaTrie resulting from the removal of key from this PatriciaTrie. |
Methods inherited from class java.lang.Object |
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public PatriciaTrie()
Method Detail |
public BSTInterface put(String key) throws NullPointerException
put
in interface BSTInterface
NullPointerException
- If key is nullpublic BSTInterface remove(String key) throws NullPointerException
remove
in interface BSTInterface
NullPointerException
- If key is nullpublic JComponent getDrawing()
getDrawing
in interface BSTInterface
public JComponent getDrawing(Font fnt) throws NullPointerException
getDrawing
in interface BSTInterface
NullPointerException
- if fnt is null.public Object clone()
clone
in interface BSTInterface
public Object getRoot()
getRoot
in interface TreeInterface
Object.toString()
public TreeInterface[] getChildren()
getChildren
in interface TreeInterface
public boolean isEmpty()
isEmpty
in interface TreeInterface
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |