Documentation
¶
Index ¶
- func DifferenceIntoSet[T any](s1, s2 SetView[T], dstSet Set[T])
- func IntersectionIntoSet[T any](s1, s2 SetView[T], dstSet Set[T])
- func IsSubsetOf[T any](child, parent SetView[T]) bool
- func IsSupersetOf[T any](parent, child SetView[T]) bool
- func UnionIntoSet[T any](s1, s2 SetView[T], dstSet Set[T])
- type HashSet
- func (s *HashSet[T]) Add(elem T) bool
- func (s *HashSet[T]) AddAll(elems []T) bool
- func (s *HashSet[T]) Clear()
- func (s *HashSet[T]) Contains(elem T) bool
- func (s *HashSet[T]) ContainsAll(elems []T) bool
- func (s *HashSet[T]) CopyInto(toSet Set[T])
- func (s *HashSet[T]) Difference(other SetView[T]) *HashSet[T]
- func (s *HashSet[T]) Equal(s2 SetView[T]) bool
- func (s *HashSet[T]) Intersection(other SetView[T]) *HashSet[T]
- func (s *HashSet[T]) IsSubsetOf(other SetView[T]) bool
- func (s *HashSet[T]) IsSupersetOf(other SetView[T]) bool
- func (s *HashSet[T]) Len() int
- func (s *HashSet[T]) Range(fn func(idx int, elem T) bool)
- func (s *HashSet[T]) Remove(elem T) bool
- func (s *HashSet[T]) RemoveAll(elems []T) bool
- func (s *HashSet[T]) ToSlice() []T
- func (s *HashSet[T]) Union(other SetView[T]) *HashSet[T]
- func (s *HashSet[T]) UnionInplace(other SetView[T]) *HashSet[T]
- type Set
- type SetView
- type SortedSet
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DifferenceIntoSet ¶
DifferenceIntoSet calc from Difference and copy into set.
func IntersectionIntoSet ¶
IntersectionIntoSet calc from Difference and copy into set.
func IsSubsetOf ¶
IsSubsetOf Determines if every element in child is in parent.
func IsSupersetOf ¶
IsSupersetOf Determines if every element in child is in parent.
func UnionIntoSet ¶
UnionIntoSet calc from Difference and copy into set.
Types ¶
type HashSet ¶
type HashSet[T comparable] struct { // contains filtered or unexported fields }
func NewHashSetFromSlice ¶
func NewHashSetFromSlice[T comparable](s []T) *HashSet[T]
func NewHashSetWithCap ¶
func NewHashSetWithCap[T comparable](capacity int) *HashSet[T]
func (*HashSet[T]) ContainsAll ¶
func (*HashSet[T]) Difference ¶
func (*HashSet[T]) Intersection ¶
Intersection returns an intersection of two sets as HashSet.
func (*HashSet[T]) IsSubsetOf ¶
func (*HashSet[T]) IsSupersetOf ¶
func (*HashSet[T]) UnionInplace ¶
UnionInplace union two sets and returns self.
type Set ¶
type Set[T any] interface { SetView[T] // Add adds the specified element to this set if it is not already present (optional operation). Add(T) bool // AddAll adds all of the elements in the specified collection to this set // if they're not already present (optional operation). AddAll(elems []T) bool // Remove removes the specified element from this set if it is present (optional operation). Remove(elem T) bool // RemoveAll Removes from this set all of its elements that are contained // in the specified collection (optional operation). RemoveAll(elems []T) bool // Clear removes all elements from this set. Clear() }
Set A collection that contains no duplicate elements. More formally, sets contain no pair of elements e1 and e2 such that e1.equals(e2), and at most one null element.
type SetView ¶
type SetView[T any] interface { // Contains returns true if this set contains the specified element. Contains(elem T) bool // ContainsAll returns true if this set contains all elements of the specified collection. ContainsAll(elems []T) bool // CopyInto Copies the current contents of this set view into an existing set. CopyInto(Set[T]) Equal(SetView[T]) bool Len() int // Range iterates elements, when fn returns false, iterates stop. // it does not provide any ordering guarantees(it depends on implements). Range(fn func(idx int, elem T) bool) // ToSlice transfer to slice. ToSlice() []T }
func Difference ¶
Difference returns a difference view from set s1 and s2 that contains all elements of s1 that are not also elements of s2.
func Intersection ¶
Intersection returns an intersection view of two sets.
type SortedSet ¶
type SortedSet[T any] interface { Set[T] // First returns a view of the portion of this set whose elements are strictly less than toElement. First() T // Last returns the last (highest) element currently in this set. Last() T // Sub returns a view of the portion of this set whose elements range from fromElement, inclusive, to toElement, exclusive. Sub(fromElem, to T) // HeadSet returns a view of the portion of this set whose elements are strictly less than toElement. HeadSet(toElem T) SortedSet[T] // TailSet returns a view of the portion of this set whose elements are greater than or equal to fromElement. TailSet(fromElem T) SortedSet[T] }