mirror of
https://github.com/emirpasic/gods.git
synced 2026-06-16 16:26:36 +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:
@@ -5,16 +5,17 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"github.com/emirpasic/gods/lists/arraylist"
|
||||
"github.com/emirpasic/gods/utils"
|
||||
"cmp"
|
||||
|
||||
"github.com/emirpasic/gods/v2/lists/arraylist"
|
||||
)
|
||||
|
||||
// ArrayListExample to demonstrate basic usage of ArrayList
|
||||
func main() {
|
||||
list := arraylist.New()
|
||||
list := arraylist.New[string]()
|
||||
list.Add("a") // ["a"]
|
||||
list.Add("c", "b") // ["a","c","b"]
|
||||
list.Sort(utils.StringComparator) // ["a","b","c"]
|
||||
list.Sort(cmp.Compare[string]) // ["a","b","c"]
|
||||
_, _ = list.Get(0) // "a",true
|
||||
_, _ = list.Get(100) // nil,false
|
||||
_ = list.Contains("a", "b", "c") // true
|
||||
|
||||
Reference in New Issue
Block a user