Documentation
¶
Overview ¶
Package collectable provides interfaces for hashable and comparable types used in Map and Set data structures.
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrUnsupportedType = errors.New("unsupported type for hashing")
ErrUnsupportedType is returned when attempting to hash an unsupported type.
Functions ¶
This section is empty.
Types ¶
type Collectable ¶
type Collectable[T any] interface { hashing.Hashable compare.Comparable[T] }
Collectable is an interface that combines the Hashable and Comparable interfaces. This is useful for objects that need to be stored in a Map or Set, where uniqueness is determined by the hashing value, and collisions are resolved by comparing the objects.
func FromComparable ¶
func FromComparable[T comparable](value T) Collectable[T]
FromComparable creates a Collectable[T] from any comparable value. It supports all numeric types, strings, byte slices, and booleans. For unsupported types, the UpdateHash method will return an error.
Click to show internal directories.
Click to hide internal directories.