Documentation
¶
Overview ¶
Package segmented provides a 2-dimensional indexed append-only array type.
Index ¶
- type Array
- func (i *Array[K, T]) Append(t ...T)
- func (i *Array[K, T]) Cut(key K) (s Segment)
- func (i *Array[K, T]) Get(key K) Segment
- func (i *Array[K, T]) GetItems(key K) []T
- func (i *Array[K, T]) GetSegment(s Segment) []T
- func (i *Array[K, T]) Len() int
- func (i *Array[K, T]) Reset()
- func (i *Array[K, T]) VisitAll(fn func(key K, s Segment))
- type Segment
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Array ¶
type Array[K hamap.KeyInterface, T any] struct { // contains filtered or unexported fields }
Array is a 2D indexed append-only array where each segment is indexed by a key.
func New ¶
func New[K hamap.KeyInterface, T any]() *Array[K, T]
New allocates a new instance of an indexed 2D append-only array.
func (*Array[K, T]) Append ¶
func (i *Array[K, T]) Append(t ...T)
Append appends onto the last uncommited segment.
func (*Array[K, T]) Cut ¶
Cut commits the pending segment under key and returns the segment identifier. Returns Segment{Start: -1} if the key already exists.
func (*Array[K, T]) GetItems ¶
func (i *Array[K, T]) GetItems(key K) []T
GetItems returns the segment items by key. Returns nil if key doesn't exist.
func (*Array[K, T]) GetSegment ¶
GetSegment returns the segment.
Click to show internal directories.
Click to hide internal directories.