btreeset

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Jun 13, 2025 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package btreeset provides a set implementation using a red-black tree.

Index

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 New

func New[T cmp.Ordered](values ...T) *Set[T]

func NewWith

func NewWith[T comparable](cmp cmp.Comparator[T], m int, values ...T) *Set[T]

func (*Set[T]) Add

func (s *Set[T]) Add(values T) bool

func (*Set[T]) Append added in v0.9.0

func (s *Set[T]) Append(values ...T) int

func (*Set[T]) Clear

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

func (*Set[T]) Clone added in v0.9.0

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

func (*Set[T]) Contains

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

func (*Set[T]) ContainsAny added in v0.9.0

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

func (*Set[T]) ContainsAnyElement added in v0.9.0

func (s *Set[T]) ContainsAnyElement(other container.Set[T]) bool

func (*Set[T]) ContainsOne added in v0.9.0

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

func (*Set[T]) Difference

func (s *Set[T]) Difference(other container.Set[T]) container.Set[T]

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]) Each

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

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

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

func (*Set[T]) Intersect added in v0.9.0

func (s *Set[T]) Intersect(other container.Set[T]) container.Set[T]

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]) IsEmpty added in v0.9.0

func (s *Set[T]) IsEmpty() bool

func (*Set[T]) IsProperSubset added in v0.9.0

func (s *Set[T]) IsProperSubset(other container.Set[T]) bool

func (*Set[T]) IsProperSuperset added in v0.9.0

func (s *Set[T]) IsProperSuperset(other container.Set[T]) bool

func (*Set[T]) IsSubset added in v0.9.0

func (s *Set[T]) IsSubset(other container.Set[T]) bool

func (*Set[T]) IsSuperset added in v0.9.0

func (s *Set[T]) IsSuperset(other container.Set[T]) bool

func (*Set[T]) Iter

func (s *Set[T]) Iter() iter.Seq[T]

func (*Set[T]) Len

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

func (*Set[T]) MarshalJSON

func (set *Set[T]) MarshalJSON() ([]byte, error)

MarshalJSON outputs the JSON representation of the set.

func (*Set[T]) Pop added in v0.9.0

func (s *Set[T]) Pop() (k T, ok bool)

func (*Set[T]) PopEnd added in v0.9.0

func (s *Set[T]) PopEnd() (k T, ok bool)

func (*Set[T]) Remove

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

func (*Set[T]) RemoveAll added in v0.9.0

func (s *Set[T]) RemoveAll(values ...T)

func (*Set[T]) String

func (s *Set[T]) String() string

String returns a string representation of the set.

func (*Set[T]) SymmetricDifference added in v0.9.0

func (s *Set[T]) SymmetricDifference(other container.Set[T]) container.Set[T]

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]) ToSlice added in v0.9.0

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

func (*Set[T]) Union

func (s *Set[T]) Union(other container.Set[T]) container.Set[T]

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

func (set *Set[T]) UnmarshalJSON(data []byte) error

UnmarshalJSON populates the set from the input JSON representation.

func (*Set[T]) Values

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

Jump to

Keyboard shortcuts

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