Interface IStack
-
- All Known Implementing Classes:
Stack
public interface IStack
-
-
Method Summary
All Methods Instance Methods Abstract 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.
-
-
-
Method Detail
-
push
void push(char elem)
Pushes a character element onto the top of the stack if there is space.- Parameters:
elem- The character element to push onto the stack.
-
pop
void pop()
Removes the element at the top of the stack if the stack is not empty.
-
top
char top()
Returns the element at the top of the stack, otherwise '\0' if the stack is empty.- Returns:
- char
-
isEmpty
boolean isEmpty()
Checks if the stack is empty.- Returns:
- true if the stack is empty, false otherwise.
-
isFull
boolean isFull()
Checks if the stack is full.- Returns:
- true if the stack is full, false otherwise.
-
displayStack
void displayStack()
Pretty prints the stack's elements, starting from the top-most element to the bottom.
-
length
int length()
Returns the length of the stack.- Returns:
- int
-
makeNull
void makeNull()
Clears the stack.- Parameters:
s- a pointer to the Stack object (struct Stack *)
-
insertBottom
void insertBottom(char elem)
Inserts the specified element to the bottom of the stack.- Parameters:
s- a pointer to the Stack object (struct Stack *)elem- the element to add to the stack
-
-