|
Sharkysoft home | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--lava.string.CharacterStack
Character stack.
Details: A CharacterStack
is a LIFO queue of characters suitable for use in various text parsing applications. Characters are popped and pushed one at a time, but entire strings of characters can also be pushed with a single call. For character stacking, this class is more efficient than the java.util.Stack
class because it does not require object encapsulation for the characters.
Constructor Summary | |
CharacterStack()
Initializes empty character stack. |
Method Summary | |
java.lang.Object |
clone()
Clones stack. |
int |
pop()
Pops character. |
void |
push(char c)
Pushes character. |
void |
push(char[] src)
Pushes characters. |
void |
push(char[] src,
int offset,
int amt)
Pushes characters. |
void |
push(java.lang.String s)
Pushes string. |
int |
size()
Returns stack height. |
Methods inherited from class java.lang.Object |
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public CharacterStack()
Method Detail |
public void push(char c)
Details: push
pushes a character onto the stack.
c
- the characterpublic void push(java.lang.String s)
Details: Pushes a string of characters onto the stack. The first character of the string is pushed first.
s
- the stringpublic final void push(char[] src)
Details: push
pushes an array of characters onto the stack.
src
- the arraypublic void push(char[] src, int offset, int amt)
Details: push
pushes an array of characters (src) onto the stack, starting with the character at the given offset (offset), and pushing only amt characters.
src
- the arrayoffset
- the offsetamt
- number of characterspublic int pop()
Details: Pops a single character from the stack and returns it. If the stack is empty, -1 is returned.
public int size()
Details: Returns the number of characters currently on the stack.
public java.lang.Object clone()
Details: Returns an independent copy of this character stack. Useful for "backing up" the stack.
clone
in class java.lang.Object
|
Sharkysoft home | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |