zset

package
v0.12.7 Latest Latest
Warning

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

Go to latest
Published: Jul 24, 2024 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type HashSet

type HashSet[T any, K comparable] struct {
	// contains filtered or unexported fields
}

func NewHashSet

func NewHashSet[T any, K comparable](hash Hasher[T, K], vals ...T) *HashSet[T, K]

func NewHashSetUnion added in v0.11.4

func NewHashSetUnion[T any, K comparable](sets ...*HashSet[T, K]) (s *HashSet[T, K])

Create a new set that is the union of all provided sets

func (*HashSet[T, K]) Add

func (s *HashSet[T, K]) Add(items ...T) *HashSet[T, K]

func (*HashSet[T, K]) Clear

func (s *HashSet[T, K]) Clear() *HashSet[T, K]

func (*HashSet[T, K]) Clone

func (s *HashSet[T, K]) Clone() *HashSet[T, K]

func (HashSet[T, K]) Contains

func (s HashSet[T, K]) Contains(items ...T) bool

func (HashSet[T, K]) ContainsAny

func (s HashSet[T, K]) ContainsAny(items ...T) bool

func (*HashSet[T, K]) Delete

func (s *HashSet[T, K]) Delete(items ...T)

func (*HashSet[T, K]) Difference added in v0.12.1

func (s *HashSet[T, K]) Difference(others ...*HashSet[T, K]) *HashSet[T, K]

Difference will reduce this set to the items that are present in this set but not in the other sets. This mutates the set.

func (*HashSet[T, K]) Equal added in v0.11.4

func (s *HashSet[T, K]) Equal(other *HashSet[T, K]) bool

Two sets are considered equal if they contain exactly the same elements.

func (*HashSet[T, K]) Filter added in v0.12.0

func (s *HashSet[T, K]) Filter(keep func(item T) bool) *HashSet[T, K]

Filter will reduce this set to the items that match the provided filter function. This mutates the set.

func (*HashSet[T, K]) FilterItems added in v0.12.0

func (s *HashSet[T, K]) FilterItems(keep func(item T) bool) (res []T)

FilterItems will reduce this set to the items that match the provided filter function. This mutates the set.

func (*HashSet[T, K]) Intersection

func (s *HashSet[T, K]) Intersection(others ...*HashSet[T, K]) *HashSet[T, K]

Intersection will reduce this set to the items that are present in this set and the other sets

func (*HashSet[T, K]) Items

func (s *HashSet[T, K]) Items() (res []T)

func (*HashSet[T, K]) Size

func (s *HashSet[T, K]) Size() int

func (*HashSet[T, K]) Union

func (s *HashSet[T, K]) Union(others ...*HashSet[T, K]) *HashSet[T, K]

type Hasher

type Hasher[T any, K comparable] func(T) K

type ISet added in v0.12.0

type ISet[T comparable] interface {
	Add(items ...T) *Set[T]
	Delete(items ...T) *Set[T]
	Clear() *Set[T]
	Contains(items ...T) bool
	ContainsAny(items ...T) bool
	Equal(other *Set[T]) bool
	Size() int
	Items() []T
	Union(others ...*Set[T]) *Set[T]
	Difference(others ...*Set[T]) *Set[T]
	Clone() *Set[T]
	Intersection(others ...*Set[T]) *Set[T]
	Filter(f func(T) bool) *Set[T]
	FilterItems(f func(T) bool) []T
}

type Set

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

func New

func New[T comparable](vals ...T) *Set[T]

func NewUnion added in v0.11.4

func NewUnion[T comparable](sets ...*Set[T]) (s *Set[T])

Create a new set that is the union of all provided sets

func (*Set[T]) Add

func (s *Set[T]) Add(items ...T) *Set[T]

func (*Set[T]) Clear

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

func (*Set[T]) Clone

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

Clone will create a new set with the same items as this set. This

func (*Set[T]) Contains

func (s *Set[T]) Contains(items ...T) bool

func (*Set[T]) ContainsAny

func (s *Set[T]) ContainsAny(items ...T) bool

func (*Set[T]) Delete

func (s *Set[T]) Delete(items ...T) *Set[T]

func (*Set[T]) Difference added in v0.12.1

func (s *Set[T]) Difference(others ...*Set[T]) *Set[T]

Difference will reduce this set to the items that are present in this set but not in the other sets. This mutates the set.

func (*Set[T]) Equal added in v0.11.4

func (s *Set[T]) Equal(other *Set[T]) bool

Two sets are considered equal if they contain exactly the same elements.

func (*Set[T]) Filter added in v0.12.0

func (s *Set[T]) Filter(f func(T) bool) *Set[T]

Filter will reduce this set to the items that match the provided filter function. This mutates the set.

func (*Set[T]) FilterItems added in v0.12.0

func (s *Set[T]) FilterItems(f func(T) bool) (res []T)

FilterItems will return a slice of items that match the provided filter function.

func (*Set[T]) Intersection

func (s *Set[T]) Intersection(others ...*Set[T]) *Set[T]

Intersection will reduce this set to the items that are present in this set and the other sets. This mutates the set.

func (*Set[T]) Items

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

func (*Set[T]) Size

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

func (*Set[T]) Union

func (s *Set[T]) Union(others ...*Set[T]) *Set[T]

Union will add all items from the other sets to this set. This mutates the set.

Jump to

Keyboard shortcuts

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