Documentation
¶
Overview ¶
Package btreeset provides a set implementation using a red-black tree.
Index ¶
- type Set
- func (s *Set[T]) Add(values T) bool
- func (s *Set[T]) Append(values ...T) int
- func (s *Set[T]) Clear()
- func (s *Set[T]) Clone() container.Set[T]
- func (s *Set[T]) Contains(values ...T) bool
- func (s *Set[T]) ContainsAny(val ...T) bool
- func (s *Set[T]) ContainsAnyElement(other container.Set[T]) bool
- func (s *Set[T]) ContainsOne(v T) bool
- func (s *Set[T]) Difference(other container.Set[T]) container.Set[T]
- func (s *Set[T]) Each(f func(T) bool)
- func (s *Set[T]) Equal(other container.Set[T]) bool
- func (s *Set[T]) Intersect(other container.Set[T]) container.Set[T]
- func (s *Set[T]) IsEmpty() bool
- func (s *Set[T]) IsProperSubset(other container.Set[T]) bool
- func (s *Set[T]) IsProperSuperset(other container.Set[T]) bool
- func (s *Set[T]) IsSubset(other container.Set[T]) bool
- func (s *Set[T]) IsSuperset(other container.Set[T]) bool
- func (s *Set[T]) Iter() iter.Seq[T]
- func (s *Set[T]) Len() int
- func (set *Set[T]) MarshalJSON() ([]byte, error)
- func (s *Set[T]) Pop() (k T, ok bool)
- func (s *Set[T]) PopEnd() (k T, ok bool)
- func (s *Set[T]) Remove(values T)
- func (s *Set[T]) RemoveAll(values ...T)
- func (s *Set[T]) String() string
- func (s *Set[T]) SymmetricDifference(other container.Set[T]) container.Set[T]
- func (s *Set[T]) ToSlice() []T
- func (s *Set[T]) Union(other container.Set[T]) container.Set[T]
- func (set *Set[T]) UnmarshalJSON(data []byte) error
- func (s *Set[T]) Values() []T
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Set ¶
type Set[T comparable] struct { // contains filtered or unexported fields }
func NewWith ¶
func NewWith[T comparable](cmp cmp.Comparator[T], m int, values ...T) *Set[T]
func (*Set[T]) ContainsAny ¶ added in v0.9.0
func (*Set[T]) ContainsAnyElement ¶ added in v0.9.0
func (*Set[T]) ContainsOne ¶ added in v0.9.0
func (*Set[T]) Difference ¶
Difference returns a new set containing elements in s but not in other. Returns an empty set if comparators differ. Ref: https://proofwiki.org/wiki/Definition:Set_Difference
func (*Set[T]) Intersect ¶ added in v0.9.0
Intersect returns a new set containing elements present in both s and other. Returns an empty set if comparators differ. Ref: https://en.wikipedia.org/wiki/Intersection_(set_theory)
func (*Set[T]) IsProperSubset ¶ added in v0.9.0
func (*Set[T]) IsProperSuperset ¶ added in v0.9.0
func (*Set[T]) IsSuperset ¶ added in v0.9.0
func (*Set[T]) MarshalJSON ¶
MarshalJSON outputs the JSON representation of the set.
func (*Set[T]) SymmetricDifference ¶ added in v0.9.0
SymmetricDifference returns a new set with all elements which are in either this set or the other set but not in both. Returns an empty set if comparators differ. Ref: https://en.wikipedia.org/wiki/Symmetric_difference
func (*Set[T]) Union ¶
Union returns a new set containing all elements from s or other. Returns an empty set if comparators differ. Ref: https://en.wikipedia.org/wiki/Union_(set_theory)
func (*Set[T]) UnmarshalJSON ¶
UnmarshalJSON populates the set from the input JSON representation.