Class Stack
- java.lang.Object
-
- Stack
-
-
Field Summary
Fields Modifier and Type Field Description static intMAXThe 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 voiddisplayStack()Pretty prints the stack's elements, starting from the top-most element to the bottom.voidinsertBottom(char elem)Inserts the specified element to the bottom of the stack.booleanisEmpty()Checks if the stack is empty.booleanisFull()Checks if the stack is full.intlength()Returns the length of the stack.voidmakeNull()Clears the stack.voidpop()Removes the element at the top of the stack if the stack is not empty.voidpush(char elem)Pushes a character element onto the top of the stack if there is space.chartop()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:IStackReturns the length of the stack.
-
push
public void push(char elem)
Description copied from interface:IStackPushes a character element onto the top of the stack if there is space.
-
pop
public void pop()
Description copied from interface:IStackRemoves the element at the top of the stack if the stack is not empty.
-
top
public char top()
Description copied from interface:IStackReturns the element at the top of the stack, otherwise '\0' if the stack is empty.
-
isEmpty
public boolean isEmpty()
Description copied from interface:IStackChecks if the stack is empty.
-
isFull
public boolean isFull()
Description copied from interface:IStackChecks if the stack is full.
-
displayStack
public void displayStack()
Description copied from interface:IStackPretty prints the stack's elements, starting from the top-most element to the bottom.- Specified by:
displayStackin interfaceIStack
-
makeNull
public void makeNull()
Description copied from interface:IStackClears the stack.
-
insertBottom
public void insertBottom(char elem)
Description copied from interface:IStackInserts the specified element to the bottom of the stack.- Specified by:
insertBottomin interfaceIStack- Parameters:
elem- the element to add to the stack
-
-