https://github.com/hymkor/go-ignorecase-sorted
Container library like map[(ignore-cased)string]T using Generics
https://github.com/hymkor/go-ignorecase-sorted
go golang
Last synced: 24 days ago
JSON representation
Container library like map[(ignore-cased)string]T using Generics
- Host: GitHub
- URL: https://github.com/hymkor/go-ignorecase-sorted
- Owner: hymkor
- Created: 2022-04-16T14:49:03.000Z (about 3 years ago)
- Default Branch: master
- Last Pushed: 2024-03-10T19:21:50.000Z (about 1 year ago)
- Last Synced: 2025-02-10T15:50:55.834Z (3 months ago)
- Topics: go, golang
- Language: Go
- Homepage:
- Size: 22.5 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
go-ignorecase-sorted.Dictionary
===============================- Container library like map[string]T using Generics
- Ignore cases of string-keys
- Iterators can read elements by sorted-order
- It can be used with `GOEXPERIMENT=rangefunc` of Go 1.22
- This package is the version 2 now. Therefore, please import `github.com/hymkor/go-ignorecase-sorted/v2````example.go
package mainimport (
"github.com/hymkor/go-ignorecase-sorted/v2"
)func main() {
var dic ignoreCaseSorted.Dictionary[int]dic.Set("a", 1)
dic.Set("b", 2)
dic.Set("c", 3)
dic.Set("d", 3)println("------ test the case of keys are ignored ------")
if val, ok := dic.Get("A"); ok {
println("dic[`A`]=", val, "whose key is set as `a`")
}
dic.Delete("D")
println()println("------ iterate with callback function -----")
dic.Each(func(key string, value int) bool {
println("dic[`"+key+"`]=", value)
return true
})
println()println("------ iterate with rangefunc of Go 1.22 -----")
for key, value := range dic.Each {
println("dic[`"+key+"`]=", value)
}
println()
}
```**env GOEXPERIMENT=rangefunc go run example.go**
```env GOEXPERIMENT=rangefunc go run example.go|
------ test the case of keys are ignored ------
dic[`A`]= 1 whose key is set as `a`------ iterate with callback function -----
dic[`a`]= 1
dic[`b`]= 2
dic[`c`]= 3------ iterate with rangefunc of Go 1.22 -----
dic[`a`]= 1
dic[`b`]= 2
dic[`c`]= 3```