mirror of
https://github.com/Luzifer/ansible-role-version.git
synced 2024-12-23 11:01:20 +00:00
23 lines
733 B
Go
23 lines
733 B
Go
// 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 examples
|
|
|
|
import lls "github.com/emirpasic/gods/stacks/linkedliststack"
|
|
|
|
// LinkedListStackExample to demonstrate basic usage of LinkedListStack
|
|
func LinkedListStackExample() {
|
|
stack := lls.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
|
|
}
|