Interface IStack
-
- All Known Implementing Classes:
Stack
public interface IStack
-
-
Method Summary
All Methods Instance Methods Abstract 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.
-
-
-
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
-
-