Files
go-cuckoo/doc_example_test.go
M.V. Hutz b395d6e1f4
All checks were successful
CI / Check PR Title (pull_request) Successful in 32s
CI / Go Lint (pull_request) Successful in 54s
CI / Markdown Lint (pull_request) Successful in 34s
CI / Makefile Lint (pull_request) Successful in 54s
CI / Unit Tests (pull_request) Successful in 54s
CI / Fuzz Tests (pull_request) Successful in 1m25s
CI / Mutation Tests (pull_request) Successful in 1m8s
fix: tests were out of date
2026-04-16 21:12:39 -04:00

33 lines
528 B
Go

// This example
package cuckoo_test
import (
"fmt"
"git.maximhutz.com/tools/go-cuckoo"
)
func Example_basic() {
table := cuckoo.New[int, string]()
if err := table.Put(1, "Hello, World!"); err != nil {
fmt.Println("Put error:", err)
}
if item, ok := table.Get(1); !ok {
fmt.Println("Not Found 1!")
} else {
fmt.Println("Found 1:", item)
}
if item, ok := table.Get(0); !ok {
fmt.Println("Not Found 0!")
} else {
fmt.Println("Found 0:", item)
}
// Output:
// Found 1: Hello, World!
// Not Found 0!
}