Class Stack
- java.lang.Object
-
- Stack
-
-
Field Summary
Fields Modifier and Type Field Description static int
MAX
The macro definition similar to the C header files.
-
Constructor Summary
Constructors Constructor Description Stack()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
displayStack()
Pretty prints the stack's elements, starting from the top-most element to the bottom.void
insertBottom(char elem)
Inserts the specified element to the bottom of the stack.boolean
isEmpty()
Checks if the stack is empty.boolean
isFull()
Checks if the stack is full.int
length()
Returns the length of the stack.void
makeNull()
Clears the stack.void
pop()
Removes the element at the top of the stack if the stack is not empty.void
push(char elem)
Pushes a character element onto the top of the stack if there is space.char
top()
Returns the element at the top of the stack, otherwise '\0' if the stack is empty.
-
-
-
Field Detail
-
MAX
public static final int MAX
The macro definition similar to the C header files.- See Also:
- Constant Field Values
-
-
Method Detail
-
length
public int length()
Description copied from interface:IStack
Returns the length of the stack.
-
push
public void push(char elem)
Description copied from interface:IStack
Pushes a character element onto the top of the stack if there is space.
-
pop
public void pop()
Description copied from interface:IStack
Removes the element at the top of the stack if the stack is not empty.
-
top
public char top()
Description copied from interface:IStack
Returns the element at the top of the stack, otherwise '\0' if the stack is empty.
-
isEmpty
public boolean isEmpty()
Description copied from interface:IStack
Checks if the stack is empty.
-
isFull
public boolean isFull()
Description copied from interface:IStack
Checks if the stack is full.
-
displayStack
public void displayStack()
Description copied from interface:IStack
Pretty prints the stack's elements, starting from the top-most element to the bottom.- Specified by:
displayStack
in interfaceIStack
-
makeNull
public void makeNull()
Description copied from interface:IStack
Clears the stack.
-
insertBottom
public void insertBottom(char elem)
Description copied from interface:IStack
Inserts the specified element to the bottom of the stack.- Specified by:
insertBottom
in interfaceIStack
- Parameters:
elem
- the element to add to the stack
-
-