gods/cmd/sparse/main.go

35 lines
593 B
Go
Raw Normal View History

2023-08-28 12:06:51 +03:00
package main
import (
2024-01-06 18:41:04 +03:00
"vultras.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
}