summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDimitri Sokolyuk <demon@dim13.org>2015-04-12 23:31:36 +0200
committerDimitri Sokolyuk <demon@dim13.org>2015-04-12 23:31:36 +0200
commita557d8c9354653917f746cfc001b8ea28fbc5e26 (patch)
tree7dadcb3710bd712d4aec965c8a886a66f09e70bd
parent231e2367fc520c9bbfcb7e3c21bb0a65f6b63f9b (diff)
Simplify
-rw-r--r--stack.go13
1 files changed, 5 insertions, 8 deletions
diff --git a/stack.go b/stack.go
index 33c8357..ed8917d 100644
--- a/stack.go
+++ b/stack.go
@@ -1,11 +1,8 @@
// Package stack implements a simple LIFO Stack for generic values
package stack
-// Value is a generic value
-type Value interface{}
-
// Stack contains generic values
-type Stack []Value
+type Stack []interface{}
// NewStack returns a new Stack
func NewStack() Stack {
@@ -13,17 +10,17 @@ func NewStack() Stack {
}
// Push adds value at tail
-func (s *Stack) Push(v Value) {
+func (s *Stack) Push(v interface{}) {
*s = append(*s, v)
}
// Insert inserts value at head
-func (s *Stack) Insert(v Value) {
+func (s *Stack) Insert(v interface{}) {
*s = append(Stack{v}, *s...)
}
// Pop retrieves value from tail
-func (s *Stack) Pop() (v Value) {
+func (s *Stack) Pop() (v interface{}) {
if size := len(*s); size > 0 {
v, *s = (*s)[size-1], (*s)[:size-1]
}
@@ -31,7 +28,7 @@ func (s *Stack) Pop() (v Value) {
}
// Peek returns top value from Stack
-func (s Stack) Peek() Value {
+func (s Stack) Peek() interface{} {
return s[len(s)-1]
}