intset

package
v1.1.0-beta.0...-652cee2 Latest Latest
Warning

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

Go to latest
Published: Dec 27, 2024 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FastIntSet

type FastIntSet struct {
	// contains filtered or unexported fields
}

FastIntSet is wrapper of sparse with an optimization that number [0 ~ 64) can be cached for quick access. From the benchmark in fd_graph_test.go, we choose to use sparse to accelerate int set. And when the set size is quite small we can just skip the block allocation in the sparse chain list.

func NewFastIntSet

func NewFastIntSet(values ...int) FastIntSet

NewFastIntSet is used to make the instance of FastIntSet with initial values.

func (*FastIntSet) AddRange

func (s *FastIntSet) AddRange(from, to int)

AddRange adds the interval [from, to] to the Set.

func (*FastIntSet) Clear

func (s *FastIntSet) Clear()

Clear is used to clear a fastIntSet and reuse it as an empty one.

func (FastIntSet) Copy

func (s FastIntSet) Copy() FastIntSet

Copy returns a copy of s.

func (*FastIntSet) CopyFrom

func (s *FastIntSet) CopyFrom(target FastIntSet)

CopyFrom clear the receiver to be a copy of the param.

func (FastIntSet) Difference

func (s FastIntSet) Difference(rhs FastIntSet) FastIntSet

Difference is used to return the s without elements in rhs.

func (*FastIntSet) DifferenceWith

func (s *FastIntSet) DifferenceWith(rhs FastIntSet)

DifferenceWith removes any elements in rhs from source.

func (FastIntSet) Equals

func (s FastIntSet) Equals(rhs FastIntSet) bool

Equals returns whether two int-set are identical.

func (FastIntSet) ForEach

func (s FastIntSet) ForEach(f func(i int))

ForEach call a function for each value in the int-set. (Ascend)

func (FastIntSet) Has

func (s FastIntSet) Has(i int) bool

Has is used ot judge whether a value is in the set.

func (*FastIntSet) Insert

func (s *FastIntSet) Insert(i int)

Insert is used to insert a value into int-set.

func (FastIntSet) Intersection

func (s FastIntSet) Intersection(rhs FastIntSet) FastIntSet

Intersection is used to return the intersection of s and rhs.

func (*FastIntSet) IntersectionWith

func (s *FastIntSet) IntersectionWith(rhs FastIntSet)

IntersectionWith removes any elements not in rhs from source.

func (FastIntSet) Intersects

func (s FastIntSet) Intersects(rhs FastIntSet) bool

Intersects is used to judge whether two set has something in common.

func (FastIntSet) IsEmpty

func (s FastIntSet) IsEmpty() bool

IsEmpty is used to judge whether the int-set is empty.

func (FastIntSet) Len

func (s FastIntSet) Len() int

Len return the size of the int set.

func (FastIntSet) Next

func (s FastIntSet) Next(startVal int) (int, bool)

Next returns the next existing number in the Set. If there's no larger one than the given start val, return (MaxInt, false).

func (FastIntSet) Only1Zero

func (s FastIntSet) Only1Zero() bool

Only1Zero is a usage function for convenience judgement.

func (*FastIntSet) Remove

func (s *FastIntSet) Remove(i int)

Remove is used to remove a value from the set. Nothing done if the value is not in the set.

func (*FastIntSet) Shift

func (s *FastIntSet) Shift(delta int) FastIntSet

Shift generates a new set which contains elements i+delta for elements i in the original set.

func (FastIntSet) SortedArray

func (s FastIntSet) SortedArray() []int

SortedArray is used to return the in array of the set.

func (FastIntSet) String

func (s FastIntSet) String() string

func (FastIntSet) SubsetOf

func (s FastIntSet) SubsetOf(rhs FastIntSet) bool

SubsetOf is used to judge whether rhs contains source set.

func (FastIntSet) Union

func (s FastIntSet) Union(rhs FastIntSet) FastIntSet

Union is used to return a union of s and rhs as new set.

func (*FastIntSet) UnionWith

func (s *FastIntSet) UnionWith(rhs FastIntSet)

UnionWith is used to copy all the elements of rhs to source.

Jump to

Keyboard shortcuts

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