summaryrefslogtreecommitdiff
path: root/lib.go
diff options
context:
space:
mode:
Diffstat (limited to 'lib.go')
-rw-r--r--lib.go46
1 files changed, 46 insertions, 0 deletions
diff --git a/lib.go b/lib.go
index 83cdb4a..79c7cd4 100644
--- a/lib.go
+++ b/lib.go
@@ -12,6 +12,7 @@ package excelize
import (
"archive/zip"
"bytes"
+ "container/list"
"fmt"
"io"
"log"
@@ -305,3 +306,48 @@ func genSheetPasswd(plaintext string) string {
password ^= 0xCE4B
return strings.ToUpper(strconv.FormatInt(password, 16))
}
+
+// Stack defined an abstract data type that serves as a collection of elements.
+type Stack struct {
+ list *list.List
+}
+
+// NewStack create a new stack.
+func NewStack() *Stack {
+ list := list.New()
+ return &Stack{list}
+}
+
+// Push a value onto the top of the stack.
+func (stack *Stack) Push(value interface{}) {
+ stack.list.PushBack(value)
+}
+
+// Pop the top item of the stack and return it.
+func (stack *Stack) Pop() interface{} {
+ e := stack.list.Back()
+ if e != nil {
+ stack.list.Remove(e)
+ return e.Value
+ }
+ return nil
+}
+
+// Peek view the top item on the stack.
+func (stack *Stack) Peek() interface{} {
+ e := stack.list.Back()
+ if e != nil {
+ return e.Value
+ }
+ return nil
+}
+
+// Len return the number of items in the stack.
+func (stack *Stack) Len() int {
+ return stack.list.Len()
+}
+
+// Empty the stack.
+func (stack *Stack) Empty() bool {
+ return stack.list.Len() == 0
+}