mirror of
https://github.com/emirpasic/gods.git
synced 2026-06-14 16:06:42 +03:00
- update documentation, closes #73
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
// Copyright (c) 2015, Emir Pasic. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package main
|
||||
|
||||
import "github.com/emirpasic/gods/stacks/arraystack"
|
||||
|
||||
// ArrayStackExample to demonstrate basic usage of ArrayStack
|
||||
func main() {
|
||||
stack := arraystack.New() // empty
|
||||
stack.Push(1) // 1
|
||||
stack.Push(2) // 1, 2
|
||||
stack.Values() // 2, 1 (LIFO order)
|
||||
_, _ = stack.Peek() // 2,true
|
||||
_, _ = stack.Pop() // 2, true
|
||||
_, _ = stack.Pop() // 1, true
|
||||
_, _ = stack.Pop() // nil, false (nothing to pop)
|
||||
stack.Push(1) // 1
|
||||
stack.Clear() // empty
|
||||
stack.Empty() // true
|
||||
stack.Size() // 0
|
||||
}
|
||||
Reference in New Issue
Block a user