data

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2024 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type SparseSlice

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

SparseSlice manages a sparse slice of elements, only allocating enough space to satisfy the current set. It uses a 64-bit int as its mask, and is limited to 64 elements. It performs no range checking, so use wisely

func NewSparseSlice

func NewSparseSlice[T any]() *SparseSlice[T]

NewSparseSlice initializes an empty SparseSlice

func (*SparseSlice[T]) All

func (s *SparseSlice[T]) All() iter.Seq2[int, T]

func (*SparseSlice[T]) Contains

func (s *SparseSlice[T]) Contains(idx int) bool

func (*SparseSlice[T]) Get

func (s *SparseSlice[T]) Get(idx int) (T, bool)

Get retrieves a value at a specific index, returning false if it’s not set.

func (*SparseSlice[T]) HighIndex

func (s *SparseSlice[T]) HighIndex() int

func (*SparseSlice[T]) IsEmpty

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

func (*SparseSlice[T]) LowIndex

func (s *SparseSlice[T]) LowIndex() int

func (*SparseSlice[T]) Set

func (s *SparseSlice[T]) Set(idx int, value T) *SparseSlice[T]

Set returns a new SparseSlice with the value set at the specified index.

func (*SparseSlice[T]) Unset

func (s *SparseSlice[T]) Unset(idx int) *SparseSlice[T]

Unset returns a new SparseSlice with the specified index possibly removed.

func (*SparseSlice[T]) Values

func (s *SparseSlice[T]) Values() iter.Seq[T]

Jump to

Keyboard shortcuts

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