Documentation ¶
Index ¶
- type HashSet
- func (s *HashSet[T, K]) Add(items ...T) *HashSet[T, K]
- func (s *HashSet[T, K]) Clear() *HashSet[T, K]
- func (s *HashSet[T, K]) Clone() *HashSet[T, K]
- func (s HashSet[T, K]) Contains(items ...T) bool
- func (s HashSet[T, K]) ContainsAny(items ...T) bool
- func (s *HashSet[T, K]) Delete(items ...T)
- func (s *HashSet[T, K]) Difference(others ...*HashSet[T, K]) *HashSet[T, K]
- func (s *HashSet[T, K]) Equal(other *HashSet[T, K]) bool
- func (s *HashSet[T, K]) Filter(keep func(item T) bool) *HashSet[T, K]
- func (s *HashSet[T, K]) FilterItems(keep func(item T) bool) (res []T)
- func (s *HashSet[T, K]) Intersection(others ...*HashSet[T, K]) *HashSet[T, K]
- func (s *HashSet[T, K]) Items() (res []T)
- func (s *HashSet[T, K]) Size() int
- func (s *HashSet[T, K]) Union(others ...*HashSet[T, K]) *HashSet[T, K]
- type Hasher
- type ISet
- type Set
- func (s *Set[T]) Add(items ...T) *Set[T]
- func (s *Set[T]) Clear() *Set[T]
- func (s *Set[T]) Clone() *Set[T]
- func (s *Set[T]) Contains(items ...T) bool
- func (s *Set[T]) ContainsAny(items ...T) bool
- func (s *Set[T]) Delete(items ...T) *Set[T]
- func (s *Set[T]) Difference(others ...*Set[T]) *Set[T]
- func (s *Set[T]) Equal(other *Set[T]) bool
- func (s *Set[T]) Filter(f func(T) bool) *Set[T]
- func (s *Set[T]) FilterItems(f func(T) bool) (res []T)
- func (s *Set[T]) Intersection(others ...*Set[T]) *Set[T]
- func (s *Set[T]) Items() (res []T)
- func (s *Set[T]) Size() int
- func (s *Set[T]) Union(others ...*Set[T]) *Set[T]
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]) ContainsAny ¶
func (*HashSet[T, K]) Difference ¶ added in v0.12.1
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
Two sets are considered equal if they contain exactly the same elements.
func (*HashSet[T, K]) Filter ¶ added in v0.12.0
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
FilterItems will reduce this set to the items that match the provided filter function. This mutates the set.
func (*HashSet[T, K]) Intersection ¶
Intersection will reduce this set to the items that are present in this set and the other sets
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]) ContainsAny ¶
func (*Set[T]) Difference ¶ added in v0.12.1
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
Two sets are considered equal if they contain exactly the same elements.
func (*Set[T]) Filter ¶ added in v0.12.0
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
FilterItems will return a slice of items that match the provided filter function.
func (*Set[T]) Intersection ¶
Intersection will reduce this set to the items that are present in this set and the other sets. This mutates the set.