Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrOutOfBound = errors.New("moving to out of bound of state")
Returned by IncrementPointer and DecrementPointer state method on moving pointer out of state acceptable range
Functions ¶
This section is empty.
Types ¶
type DynamicSize ¶
type DynamicSize[T StateType] struct { // contains filtered or unexported fields }
A dynamic size state, implemented using linked list for flexibility.
func NewDynamicSize ¶
func NewDynamicSize[T StateType](leftExpandable bool) *DynamicSize[T]
Return a dynamic size state. if leftExpandable is false, would return ErrOutOfBound if trying to move pointer left on the first cell
func (*DynamicSize[T]) DecrementPointer ¶
func (s *DynamicSize[T]) DecrementPointer() error
func (*DynamicSize[T]) IncrementPointer ¶
func (s *DynamicSize[T]) IncrementPointer() error
func (*DynamicSize[T]) PointerValue ¶
func (s *DynamicSize[T]) PointerValue() T
func (*DynamicSize[T]) SetPointerValue ¶
func (s *DynamicSize[T]) SetPointerValue(value T)
type FixedSize ¶
type FixedSize[T StateType] struct { // contains filtered or unexported fields }
A fixed size state, implemented using slices for performance
func NewFixedSize ¶
Return a fixed size state
func (*FixedSize[T]) DecrementPointer ¶
func (*FixedSize[T]) IncrementPointer ¶
func (*FixedSize[T]) PointerValue ¶
func (s *FixedSize[T]) PointerValue() T
func (*FixedSize[T]) SetPointerValue ¶
func (s *FixedSize[T]) SetPointerValue(value T)
type State ¶
type State[T StateType] interface { // get the value which the pointer is pointing to PointerValue() T // set the value which the pointer is pointing to SetPointerValue(T) // move pointer right IncrementPointer() error // move pointer left DecrementPointer() error }
State interface define the set of changes which can be done on a state
Click to show internal directories.
Click to hide internal directories.