sorted_set

package
v0.27.0 Latest Latest
Warning

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

Go to latest
Published: Jun 5, 2024 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type SortedSet

type SortedSet[T any] struct {
	// contains filtered or unexported fields
}

SortedSet is a Set whose elements are traversable in sorted ordered.

func NewSortedSet

func NewSortedSet[T btree.Ordered](in []T) *SortedSet[T]

NewSortedSet makes a SortedSet of the elements in the passed slice. The original slice is not modified.

func NewSortedSetFn

func NewSortedSetFn[T any](in []T, less btree.LessFunc[T]) *SortedSet[T]

NewSortedSetFn makes a SortedSet of the elements in the passed slice. The original slice is not modified.

func (*SortedSet[T]) Add

func (s *SortedSet[T]) Add(v T)

Add adds an element to the SortedSet. If adding another SortedSet, AddAll is more efficient than repeated calls to Add as it avoids needing to materialize an intermediate slice.

func (*SortedSet[T]) AddAll

func (s *SortedSet[T]) AddAll(other *SortedSet[T])

AddAll adds all of the elements from the other SortedSet to this one.

func (*SortedSet[T]) Clone

func (s *SortedSet[T]) Clone() *SortedSet[T]

Clone makes a copy of this SortedSet. Behaviorally, the copy is completely independent of the original, but as the copying is done lazily with copy-on-write structures, performance of mutations on both sets may be worse while initial copies are (lazily) made.

func (*SortedSet[T]) Contains

func (s *SortedSet[T]) Contains(v T) bool

Contains returns whether the SortedSet contains the given value.

func (*SortedSet[T]) Filter

func (s *SortedSet[T]) Filter(predicate func(T) bool) *SortedSet[T]

Filter creates a new SortedSet containing only the elements from this one for which the passed predicate evaluates true.

func (*SortedSet[T]) Len

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

func (*SortedSet[T]) SortedSlice

func (s *SortedSet[T]) SortedSlice() []T

SortedSlice returns a sorted slice of the values in the SortedSet. The returned slice is owned by the caller, and may be modified freely.

Jump to

Keyboard shortcuts

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