collectable

package
v0.0.0-...-c514b9c Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 13, 2026 License: MIT Imports: 5 Imported by: 0

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL