setx

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2024 License: MIT Imports: 0 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DifferenceIntoSet

func DifferenceIntoSet[T any](s1, s2 SetView[T], dstSet Set[T])

DifferenceIntoSet calc from Difference and copy into set.

func IntersectionIntoSet

func IntersectionIntoSet[T any](s1, s2 SetView[T], dstSet Set[T])

IntersectionIntoSet calc from Difference and copy into set.

func IsSubsetOf

func IsSubsetOf[T any](child, parent SetView[T]) bool

IsSubsetOf Determines if every element in child is in parent.

func IsSupersetOf

func IsSupersetOf[T any](parent, child SetView[T]) bool

IsSupersetOf Determines if every element in child is in parent.

func UnionIntoSet

func UnionIntoSet[T any](s1, s2 SetView[T], dstSet Set[T])

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

func (s *HashSet[T]) Add(elem T) bool

func (*HashSet[T]) AddAll

func (s *HashSet[T]) AddAll(elems []T) bool

func (*HashSet[T]) Clear

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

func (*HashSet[T]) Contains

func (s *HashSet[T]) Contains(elem T) bool

func (*HashSet[T]) ContainsAll

func (s *HashSet[T]) ContainsAll(elems []T) bool

func (*HashSet[T]) CopyInto

func (s *HashSet[T]) CopyInto(toSet Set[T])

func (*HashSet[T]) Difference

func (s *HashSet[T]) Difference(other SetView[T]) *HashSet[T]

func (*HashSet[T]) Equal

func (s *HashSet[T]) Equal(s2 SetView[T]) bool

func (*HashSet[T]) Intersection

func (s *HashSet[T]) Intersection(other SetView[T]) *HashSet[T]

Intersection returns an intersection of two sets as HashSet.

func (*HashSet[T]) IsSubsetOf

func (s *HashSet[T]) IsSubsetOf(other SetView[T]) bool

func (*HashSet[T]) IsSupersetOf

func (s *HashSet[T]) IsSupersetOf(other SetView[T]) bool

func (*HashSet[T]) Len

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

func (*HashSet[T]) Range

func (s *HashSet[T]) Range(fn func(idx int, elem T) bool)

func (*HashSet[T]) Remove

func (s *HashSet[T]) Remove(elem T) bool

func (*HashSet[T]) RemoveAll

func (s *HashSet[T]) RemoveAll(elems []T) bool

func (*HashSet[T]) ToSlice

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

func (*HashSet[T]) Union

func (s *HashSet[T]) Union(other SetView[T]) *HashSet[T]

func (*HashSet[T]) UnionInplace

func (s *HashSet[T]) UnionInplace(other SetView[T]) *HashSet[T]

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

func Difference[T any](s1, s2 SetView[T]) SetView[T]

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

func Intersection[T any](s1, s2 SetView[T]) SetView[T]

Intersection returns an intersection view of two sets.

func Union

func Union[T any](s1, s2 SetView[T]) SetView[T]

Union unions two sets and returns a view.

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]
}

Jump to

Keyboard shortcuts

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