@ -88,6 +88,12 @@ func (stack *Stack) Size() int {
return stack.top + 1
}
// Removes all elements from the stack.
func (stack *Stack) Clear() {
stack.top = -1
stack.items = []interface{}{}
func (stack *Stack) String() string {
str := "ArrayStack\n"
values := []string{}
@ -84,6 +84,12 @@ func (stack *Stack) Size() int {
return stack.size
stack.top = nil
stack.size = 0
str := "LinkedListStack\n"
element := stack.top
@ -24,4 +24,5 @@ type Interface interface {
Peek() (value interface{}, ok bool)
Empty() bool
Size() int
Clear()