add Clear() method to stack interface

This commit is contained in:
Emir Pasic
2015-03-05 22:37:25 +01:00
parent 6a23043927
commit ce767c333d
3 changed files with 13 additions and 0 deletions
+6
View File
@@ -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{}