mirror of
https://github.com/emirpasic/gods.git
synced 2026-06-15 16:16:35 +03:00
Generics migration (#237)
* Generics migration This attempts to migrate this library in the least invasive way by preserving as much of the original API as possible. It does not change the tests in a meaningful way nor does it attempt to upgrade any logic that can be simplified or improved with generics. This is purely an API migration, and still requires a lot of additional work to be fully ready. * Fix a few broken tests around serialization * Add v2 suffix * Temporarily change mod name for testing * Rename module to /v2
This commit is contained in:
@@ -4,20 +4,20 @@
|
||||
|
||||
package main
|
||||
|
||||
import "github.com/emirpasic/gods/stacks/arraystack"
|
||||
import "github.com/emirpasic/gods/v2/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
|
||||
stack := arraystack.New[int]() // 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