|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object edu.ksu.cis.viewer.Trie
An immutable trie that can draw itself. The trie is immutable in the sense that any Trie returned by a public constructor or method cannot subsequently be changed. A trie is comprised of a nonempty tree containing all of the characters used in the strings that it stores. The root of the tree stores null, and its children store the first characters of all of the strings stored. Characters occurring in subsequent positions of a string are stored in children of the characters they follow. Nodes that end contained strings are colored red, and other nodes are colored black. Thus a string is contained in the trie if its first character is a child of the root, its second character is a child of that character, and so on until its last character is reached, and this character is red. If the empty string is to be stored, the root will be drawn red. The children of a given node will be drawn in order of their Unicode values.
Constructor Summary | |
Trie()
Constructs an empty Trie. |
Method Summary | |
Object |
clone()
Because this structure is immutable, this method simply returns this Trie. |
TreeInterface[] |
getChildren()
Returns the children of this Trie. |
JComponent |
getDrawing()
Returns a drawing of this Trie. |
JComponent |
getDrawing(Font fnt)
Returns a drawing of this tree using the given Font. |
Object |
getRoot()
Returns the root of this Trie. |
boolean |
isEmpty()
Always returns false. |
BSTInterface |
put(String key)
Returns the Trie resulting from the insertion of key into this Trie. |
BSTInterface |
remove(String key)
Returns the Trie resulting from the removal of key from this Trie. |
Methods inherited from class java.lang.Object |
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public Trie()
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 |