bitset

package
v1.7.0 Latest Latest
Warning

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

Go to latest
Published: Feb 21, 2024 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Iterator

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

Iterator is an iterator over a Set.

func (*Iterator) Get

func (it *Iterator) Get() int

Get returns the current element.

func (*Iterator) Move

func (it *Iterator) Move()

Move moves the iterator to the next element.

func (*Iterator) Remove

func (it *Iterator) Remove()

Remove removes the current element from the Set.

func (*Iterator) Valid

func (it *Iterator) Valid() bool

Valid returns true if the iterator is positioned at a valid element.

type Set

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

Set is a set implementation based on bit array.

func FromArray

func FromArray(arr *bitarray.Array) *Set

FromArray creates a set from the given array.

func New

func New(size int) *Set

New creates an empty set with the given size.

func NewFromIterable added in v1.6.1

func NewFromIterable(size int, iterable iter.Iterable[int]) *Set

NewFromIterable creates a set with the given size from the given iter.Iterable.

func (*Set) Add

func (s *Set) Add(value int)

Add adds the given value to the Set.

func (*Set) Array

func (s *Set) Array() *bitarray.Array

Array returns the underlying bit array.

func (*Set) Clear

func (s *Set) Clear()

Clear removes all elements from the Set.

func (*Set) Clone

func (s *Set) Clone() sets.Set[int]

Clone returns a shallow copy of the Set.

func (*Set) Contains

func (s *Set) Contains(value int) bool

Contains returns true if the Set contains the given value.

func (*Set) Iterator

func (s *Set) Iterator() iter.Iterator[int]

Iterator returns an iter.Iterator over the elements in the Set.

func (*Set) Remove

func (s *Set) Remove(value int)

Remove removes the given value from the Set. If the value is not in the Set, this method does nothing.

func (*Set) SetIterator added in v1.5.0

func (s *Set) SetIterator() sets.Iterator[int]

SetIterator returns an iterator over the elements in the Set.

func (*Set) Size

func (s *Set) Size() int

Size returns the number of elements in the Set.

func (*Set) Stream

func (s *Set) Stream(yield func(int) bool)

Stream streams the elements of the Set.

Jump to

Keyboard shortcuts

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