Documentation ¶
Index ¶
- type SparseSlice
- func (s *SparseSlice[T]) All() iter.Seq2[int, T]
- func (s *SparseSlice[T]) Contains(idx int) bool
- func (s *SparseSlice[T]) Get(idx int) (T, bool)
- func (s *SparseSlice[T]) HighIndex() int
- func (s *SparseSlice[T]) IsEmpty() bool
- func (s *SparseSlice[T]) LowIndex() int
- func (s *SparseSlice[T]) Set(idx int, value T) *SparseSlice[T]
- func (s *SparseSlice[T]) Unset(idx int) *SparseSlice[T]
- func (s *SparseSlice[T]) Values() iter.Seq[T]
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]) 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]
Click to show internal directories.
Click to hide internal directories.