hashset

package
v0.0.0-...-9900226 Latest Latest
Warning

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

Go to latest
Published: Dec 10, 2023 License: AGPL-3.0-or-later Imports: 0 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AsSlice

func AsSlice[E Id, S Constraint[E]](s S) []E

transforms a hashset into a slice, order is not gauranteed

func Equal

func Equal[E Id, S Constraint[E], T Constraint[E]](s S, t T) bool

returns true if S and T have the same elements recorded

func IntersectMap

func IntersectMap[T Id, U any](target map[T]U, using Hash[T])

removes keys from the target map that do not exist in the provided set

Types

type Constraint

type Constraint[T Id] interface {
	~map[T]entry
}

type Hash

type Hash[T Id] map[T]entry

func Difference

func Difference[E Id, S Constraint[E], T Constraint[E]](s S, t T) Hash[E]

return a new set that contains all keys in S that are not in T

func FromMap

func FromMap[T Id, U any](from map[T]U) Hash[T]

func FromSlice

func FromSlice[T Id](from []T) Hash[T]

func Intersection

func Intersection[E Id, S Constraint[E], T Constraint[E]](s S, t T) Hash[E]

return a new set with only items present in both sets

func MapFromSlice

func MapFromSlice[T Id, U any](from []U, g func(U) T) Hash[T]

creates a new hashset by mapping over a slice to return the values

func New

func New[T Id]() Hash[T]

creates a new hashset w/ default capacity

func Union

func Union[E Id, S Constraint[E], T Constraint[E]](s S, t T) Hash[E]

returns new set that contains all keys from S and T

func (Hash[T]) Add

func (s Hash[T]) Add(t T)

func (Hash[T]) Exists

func (s Hash[T]) Exists(t T) bool

type Id

type Id interface {
	comparable
}

type Operation

type Operation[E Id, S Constraint[E], T Constraint[E]] func(s S, t T) Hash[E]

allows operations between types that wrap a hashset

Jump to

Keyboard shortcuts

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