gods/cmd/sparse/main.go

35 lines
593 B
Go
Raw Permalink Normal View History

2023-08-28 12:06:51 +03:00
package main
import (
2024-05-19 21:19:55 +03:00
"surdeus.su/core/gods/maps"
2023-08-28 12:06:51 +03:00
"fmt"
)
func main() {
2023-11-12 12:33:46 +03:00
arr := maps.NewSparse[float32, string]("default", map[float32]string{
5: "something at 5",
12: "new shit 12",
50: "die 50",
})
for i := 0; i <= 50; i++ {
2023-10-27 14:41:31 +03:00
fmt.Println(arr.Get(float32(i)))
}
fmt.Println(arr.Size())
2023-08-28 12:06:51 +03:00
2023-10-27 14:41:31 +03:00
arr.Del(5)
2023-08-28 12:06:51 +03:00
arr.Del(12)
2023-10-27 14:41:31 +03:00
arr.Del(50)
2023-11-12 12:33:46 +03:00
for i := 0; i <= 50; i++ {
2023-10-27 14:41:31 +03:00
fmt.Println(arr.Get(float32(i)))
2023-08-28 12:06:51 +03:00
}
2023-10-27 14:41:31 +03:00
fmt.Println(arr.Size())
fmt.Printf("%v\n", arr)
arr.Del(12)
arr.Set(10, "at 10")
arr.Set(100, "at 100")
arr.Set(49, "at 100")
arr.Set(48.5, "at 100")
fmt.Printf("%v\n", arr)
2023-08-28 12:06:51 +03:00
}