github.com/mymmsc/gox@v1.3.33/util/examples/arraystack/arraystack.go (about) 1 // Copyright (c) 2015, Emir Pasic. All rights reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 package main 6 7 import "github.com/mymmsc/gox/util/arraystack" 8 9 // ArrayStackExample to demonstrate basic usage of ArrayStack 10 func main() { 11 stack := arraystack.New() // empty 12 stack.Push(1) // 1 13 stack.Push(2) // 1, 2 14 stack.Values() // 2, 1 (LIFO order) 15 _, _ = stack.Peek() // 2,true 16 _, _ = stack.Pop() // 2, true 17 _, _ = stack.Pop() // 1, true 18 _, _ = stack.Pop() // nil, false (nothing to pop) 19 stack.Push(1) // 1 20 stack.Clear() // empty 21 stack.Empty() // true 22 stack.Size() // 0 23 }