types

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2026 License: MIT Imports: 0 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Keys

func Keys[M ~map[K]V, K comparable, V any](m M) []K

func Max

func Max[T Ordered](item T, items ...T) T

func Min

func Min[T Ordered](item T, items ...T) T

func SliceContain

func SliceContain[T comparable](arr []T, target T) bool

func SliceEqual

func SliceEqual[T comparable](a, b []T) bool

func SliceToCountMap

func SliceToCountMap[T comparable](arr []T) map[T]int

func SliceToMap

func SliceToMap[T comparable](arr []T) map[T]struct{}

func Values

func Values[M ~map[K]V, K comparable, V any](m M) []V

Types

type Ordered

type Ordered interface {
	~int | ~int8 | ~int16 | ~int32 | ~int64 |
		~uint | ~uint8 | ~uint16 | ~uint32 | ~uint64 | ~uintptr |
		~float32 | ~float64 | ~string
}

type Set

type Set[T comparable] struct {
	// contains filtered or unexported fields
}

Set is a simple, non-concurrent-safe set.

func NewSet

func NewSet[T comparable](items []T) *Set[T]

NewSet builds a set from a typed slice.

func (*Set[T]) Add

func (s *Set[T]) Add(v T)

Add inserts an element.

func (*Set[T]) Clear

func (s *Set[T]) Clear()

Clear removes all elements.

func (*Set[T]) Has

func (s *Set[T]) Has(v T) bool

Has reports whether v is in the set.

func (*Set[T]) Items

func (s *Set[T]) Items() []T

Items returns all elements (order undefined).

func (*Set[T]) Remove

func (s *Set[T]) Remove(v T)

Remove deletes an element.

func (*Set[T]) Size

func (s *Set[T]) Size() int

Size returns the number of elements.

Jump to

Keyboard shortcuts

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