ds

package
v0.0.0-...-20810c9 Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ToSlice

func ToSlice[V any](value any) []V

Types

type Bits

type Bits[I index] struct {
	// contains filtered or unexported fields
}

func NewBits

func NewBits[I index](max uint32) Bits[I]

func (*Bits[I]) Clear

func (b *Bits[I]) Clear()

func (Bits[I]) Clone

func (b Bits[I]) Clone() IBits[I]

func (*Bits[I]) EnsureMax

func (b *Bits[I]) EnsureMax(index I)

func (Bits[I]) FirstOn

func (b Bits[I]) FirstOn() int32

func (Bits[I]) Get

func (b Bits[I]) Get(index I) bool

func (Bits[I]) IsEmpty

func (b Bits[I]) IsEmpty() bool

func (*Bits[I]) Iterator

func (b *Bits[I]) Iterator() Iterator[I]

func (Bits[I]) LastOn

func (b Bits[I]) LastOn() int32

func (Bits[I]) Max

func (b Bits[I]) Max() I

func (Bits[I]) OffAfter

func (b Bits[I]) OffAfter(index int32) int32

func (Bits[I]) OnAfter

func (b Bits[I]) OnAfter(index int32) int32

func (Bits[I]) Ons

func (b Bits[I]) Ons() uint32

func (*Bits[I]) SafeSet

func (b *Bits[I]) SafeSet(index I, on bool)

func (Bits[I]) SameOnes

func (b Bits[I]) SameOnes(a Bits[I]) bool

func (*Bits[I]) Set

func (b *Bits[I]) Set(index I, on bool)

func (*Bits[I]) TakeFirst

func (b *Bits[I]) TakeFirst() int32

func (*Bits[I]) TakeLast

func (b *Bits[I]) TakeLast() int32

type Bits64

type Bits64 = Bits64Indexed[uint32]

type Bits64Indexed

type Bits64Indexed[I index] uint64

func (Bits64Indexed[I]) All

func (b Bits64Indexed[I]) All(all Bits64Indexed[I]) bool

func (*Bits64Indexed[I]) Clear

func (b *Bits64Indexed[I]) Clear()

func (Bits64Indexed[I]) Clone

func (b Bits64Indexed[I]) Clone() IBits[I]

func (Bits64Indexed[I]) FirstOn

func (b Bits64Indexed[I]) FirstOn() int32

func (*Bits64Indexed[I]) Flip

func (b *Bits64Indexed[I]) Flip(flip Bits64Indexed[I])

func (Bits64Indexed[I]) Get

func (b Bits64Indexed[I]) Get(index I) bool

func (Bits64Indexed[I]) IsEmpty

func (b Bits64Indexed[I]) IsEmpty() bool

func (*Bits64Indexed[I]) Iterator

func (b *Bits64Indexed[I]) Iterator() Iterator[I]

func (Bits64Indexed[I]) LastOn

func (b Bits64Indexed[I]) LastOn() int32

func (Bits64Indexed[I]) Max

func (b Bits64Indexed[I]) Max() I

func (Bits64Indexed[I]) OffAfter

func (b Bits64Indexed[I]) OffAfter(index int32) int32

func (Bits64Indexed[I]) OnAfter

func (b Bits64Indexed[I]) OnAfter(index int32) int32

func (Bits64Indexed[I]) Ons

func (b Bits64Indexed[I]) Ons() uint32

func (*Bits64Indexed[I]) Set

func (b *Bits64Indexed[I]) Set(index I, on bool)

func (*Bits64Indexed[I]) TakeFirst

func (b *Bits64Indexed[I]) TakeFirst() int32

func (*Bits64Indexed[I]) TakeLast

func (b *Bits64Indexed[I]) TakeLast() int32

type CircularQueue

type CircularQueue[V any] struct {
	// contains filtered or unexported fields
}

func NewCircularQueue

func NewCircularQueue[V any](initialCapacity int) CircularQueue[V]

func (*CircularQueue[V]) At

func (q *CircularQueue[V]) At(index int) V

func (CircularQueue[V]) Cap

func (q CircularQueue[V]) Cap() int

func (*CircularQueue[V]) Clear

func (q *CircularQueue[V]) Clear()

func (CircularQueue[V]) IsEmpty

func (q CircularQueue[V]) IsEmpty() bool

func (*CircularQueue[V]) Iterator

func (q *CircularQueue[V]) Iterator() Iterator[V]

func (CircularQueue[V]) Len

func (q CircularQueue[V]) Len() int

func (*CircularQueue[V]) Peek

func (q *CircularQueue[V]) Peek() V

func (*CircularQueue[V]) Pop

func (q *CircularQueue[V]) Pop() V

func (*CircularQueue[V]) Push

func (q *CircularQueue[V]) Push(value V) bool

func (*CircularQueue[V]) RemoveAt

func (q *CircularQueue[V]) RemoveAt(index int)

type Clearable

type Clearable interface {
	Clear()
}

type EnumMap

type EnumMap[K constraints.Unsigned, V any] []V

func NewEnumMap

func NewEnumMap[K constraints.Unsigned, V any](m map[K]V) EnumMap[K, V]

func (EnumMap[K, V]) Empty

func (m EnumMap[K, V]) Empty() bool

func (EnumMap[K, V]) Get

func (m EnumMap[K, V]) Get(key K) (value V)

func (EnumMap[K, V]) Has

func (m EnumMap[K, V]) Has(key K) bool

func (EnumMap[K, V]) Len

func (m EnumMap[K, V]) Len() int

func (*EnumMap[K, V]) Merge

func (m *EnumMap[K, V]) Merge(other EnumMap[K, V], replace bool, isMissing func(V) bool)

func (EnumMap[K, V]) Remove

func (m EnumMap[K, V]) Remove(key K)

func (*EnumMap[K, V]) Set

func (m *EnumMap[K, V]) Set(key K, value V)

type IBits

type IBits[I index] interface {
	Iterable[I]

	Max() I
	Set(index I, on bool)
	Get(index I) bool
	Ons() uint32
	IsEmpty() bool
	FirstOn() int32
	TakeFirst() int32
	LastOn() int32
	TakeLast() int32
	OnAfter(index int32) int32
	OffAfter(index int32) int32
	Clear()
	Clone() IBits[I]
}

type Indexed

type Indexed[V any] interface {
	At(index int) V
	Len() int
}

type Iterable

type Iterable[T any] interface {
	Iterator() Iterator[T]
}

func NewEmptyIterable

func NewEmptyIterable[T any]() Iterable[T]

func NewFilterIterable

func NewFilterIterable[T any](iter Iterable[T], filter func(value *T) bool) Iterable[T]

func NewIterable

func NewIterable[T any](create func() Iterator[T]) Iterable[T]

func NewMapKeyIterable

func NewMapKeyIterable[K comparable, V any](m map[K]V) Iterable[K]

func NewMapKeyValueIterable

func NewMapKeyValueIterable[K comparable, V any](m map[K]V) Iterable[MapKeyValue[K, V]]

func NewMapValueIterable

func NewMapValueIterable[K comparable, V any](m map[K]V) Iterable[V]

func NewMultiIterable

func NewMultiIterable[T any](iterables []Iterable[T]) Iterable[T]

func NewSliceIterable

func NewSliceIterable[T any](data *[]T) Iterable[T]

func NewTranslateIterable

func NewTranslateIterable[T any, S any](iter Iterable[S], translate func(value *S) *T) Iterable[T]

type Iterator

type Iterator[T any] interface {
	Reset()
	HasNext() bool
	Next() *T
	Remove()
}

func NewEmptyIterator

func NewEmptyIterator[T any]() Iterator[T]

func NewFilterIterator

func NewFilterIterator[T any](iter Iterator[T], filter func(value *T) bool) Iterator[T]

func NewMapKeyIterator

func NewMapKeyIterator[K comparable, V any](m map[K]V) Iterator[K]

func NewMapKeyValueIterator

func NewMapKeyValueIterator[K comparable, V any](m map[K]V) Iterator[MapKeyValue[K, V]]

func NewMapValueIterator

func NewMapValueIterator[K comparable, V any](m map[K]V) Iterator[V]

func NewMultiIterator

func NewMultiIterator[T any](data []Iterator[T]) Iterator[T]

func NewSliceIterator

func NewSliceIterator[T any](data *[]T) Iterator[T]

func NewTranslateIterator

func NewTranslateIterator[T any, S any](iter Iterator[S], translate func(value *S) *T) Iterator[T]

type Linear

type Linear[V any] interface {
	Peek() V
	Pop() V
	Push(value V) bool
}

type LinkQueue

type LinkQueue[V any] struct {
	// contains filtered or unexported fields
}

func (*LinkQueue[V]) Cap

func (q *LinkQueue[V]) Cap() int

func (*LinkQueue[V]) Clear

func (q *LinkQueue[V]) Clear()

func (*LinkQueue[V]) IsEmpty

func (q *LinkQueue[V]) IsEmpty() bool

func (*LinkQueue[V]) Iterator

func (q *LinkQueue[V]) Iterator() Iterator[V]

func (*LinkQueue[V]) Len

func (q *LinkQueue[V]) Len() int

func (*LinkQueue[V]) Peek

func (q *LinkQueue[V]) Peek() V

func (*LinkQueue[V]) Pop

func (q *LinkQueue[V]) Pop() V

func (*LinkQueue[V]) Push

func (q *LinkQueue[V]) Push(value V) bool

type List

type List[T any] struct {
	Items []T
	Size  int
}

func NewList

func NewList[T any](capacity int) *List[T]

func (*List[T]) Add

func (l *List[T]) Add(item T)

func (*List[T]) AddList

func (l *List[T]) AddList(list List[T])

func (*List[T]) Clear

func (l *List[T]) Clear()

func (*List[T]) Empty

func (l *List[T]) Empty() bool

func (*List[T]) Get

func (l *List[T]) Get(index int) T

func (*List[T]) IndexOf

func (l *List[T]) IndexOf(item T) int

func (*List[T]) Iterator

func (l *List[T]) Iterator() Iterator[T]

func (*List[T]) Last

func (l *List[T]) Last() T

func (*List[T]) Len

func (l *List[T]) Len() int

func (*List[T]) Pad

func (l *List[T]) Pad(space int)

func (*List[T]) Pop

func (l *List[T]) Pop() T

func (*List[T]) RemoveAt

func (l *List[T]) RemoveAt(index int)

func (*List[T]) Reserve

func (l *List[T]) Reserve(spaces int)

func (*List[T]) Swap

func (l *List[T]) Swap(i, j int)

type MapKeyValue

type MapKeyValue[K comparable, V any] struct {
	Key   K
	Value V
	// contains filtered or unexported fields
}

func (*MapKeyValue[K, V]) Delete

func (kv *MapKeyValue[K, V]) Delete()

func (*MapKeyValue[K, V]) Exists

func (kv *MapKeyValue[K, V]) Exists() bool

func (*MapKeyValue[K, V]) Refresh

func (kv *MapKeyValue[K, V]) Refresh()

func (*MapKeyValue[K, V]) Rekey

func (kv *MapKeyValue[K, V]) Rekey(key K) bool

func (*MapKeyValue[K, V]) Set

func (kv *MapKeyValue[K, V]) Set(value V)

type Pool

type Pool[V any] struct {
	// contains filtered or unexported fields
}

func NewPool

func NewPool[V any](inital int, create PoolCreate[V], prepare PoolPrepare[V]) Pool[V]

func (*Pool[V]) Free

func (p *Pool[V]) Free(value V)

func (*Pool[V]) Get

func (p *Pool[V]) Get() V

type PoolCreate

type PoolCreate[V any] func() V

type PoolPrepare

type PoolPrepare[V any] func(V) V

type Queue

type Queue[V any] interface {
	Iterable[V]
	Linear[V]
	Clearable
	Sized
}

type Set

type Set[V comparable] map[V]struct{}

func (Set[V]) Add

func (s Set[V]) Add(v V)

func (Set[V]) Cap

func (s Set[V]) Cap() int

func (*Set[V]) Clear

func (s *Set[V]) Clear()

func (Set[V]) Has

func (s Set[V]) Has(v V) bool

func (Set[V]) IsEmpty

func (s Set[V]) IsEmpty() bool

func (Set[V]) Len

func (s Set[V]) Len() int

func (Set[V]) Peek

func (s Set[V]) Peek() V

func (Set[V]) Pop

func (s Set[V]) Pop() V

func (Set[V]) Push

func (s Set[V]) Push(v V) bool

func (Set[V]) Remove

func (s Set[V]) Remove(v V)

type Sized

type Sized interface {
	Len() int
	Cap() int
	IsEmpty() bool
}

type Sortable

type Sortable[T any] interface {
	Less(b T) bool
}

type SortableList

type SortableList[T Sortable[T]] struct {
	List[T]
}

func (*SortableList[T]) Less

func (l *SortableList[T]) Less(i, j int) bool

func (*SortableList[T]) Sort

func (l *SortableList[T]) Sort()

type SparseList

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

func NewSparseList

func NewSparseList[T any](capacity uint32) SparseList[T]

func (*SparseList[T]) Add

func (list *SparseList[T]) Add(value T) uint32

*

*

func (*SparseList[T]) At

func (list *SparseList[T]) At(index uint32) *T

func (*SparseList[T]) Cap

func (list *SparseList[T]) Cap() int

func (*SparseList[T]) Clear

func (list *SparseList[T]) Clear()

func (*SparseList[T]) Compress

func (list *SparseList[T]) Compress(keepOrder bool, moved func(newIndex uint32, oldIndex uint32, item *T))

func (*SparseList[T]) Free

func (list *SparseList[T]) Free(index uint32)

func (*SparseList[T]) IsEmpty

func (list *SparseList[T]) IsEmpty() bool

func (*SparseList[T]) IsFree

func (list *SparseList[T]) IsFree(index uint32) bool

func (*SparseList[T]) Iterate

func (list *SparseList[T]) Iterate(handle func(item *T, index uint32, liveIndex uint32) bool)

func (*SparseList[T]) Iterator

func (list *SparseList[T]) Iterator() Iterator[T]

func (*SparseList[T]) Len

func (list *SparseList[T]) Len() int

func (*SparseList[T]) Pointers

func (list *SparseList[T]) Pointers() []*T

func (*SparseList[T]) Remaining

func (list *SparseList[T]) Remaining() uint32

func (*SparseList[T]) Remove

func (list *SparseList[T]) Remove(index uint32) uint32

Removes the value at the given index and replaces it with the value at the end of the list and returns the index of that last item.

func (*SparseList[T]) Size

func (list *SparseList[T]) Size() uint32

func (*SparseList[T]) Take

func (list *SparseList[T]) Take() (*T, uint32)

Returns a pointer and the index to a value in the list. The value could be in any state since.

func (*SparseList[T]) Values

func (list *SparseList[T]) Values() []T

type Stack

type Stack[T any] struct {
	Items []T
	Count int
}

func NewStack

func NewStack[T any](capacity uint32) Stack[T]

func (*Stack[T]) Clear

func (s *Stack[T]) Clear()

func (Stack[T]) IsEmpty

func (s Stack[T]) IsEmpty() bool

func (*Stack[T]) Peek

func (s *Stack[T]) Peek() T

func (*Stack[T]) Pop

func (s *Stack[T]) Pop() T

func (*Stack[T]) Push

func (s *Stack[T]) Push(value T) bool

Jump to

Keyboard shortcuts

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