Documentation ¶
Overview ¶
Package step implements a step vector type.
A step vector can be used to represent high volume data that would be efficiently stored by run-length encoding.
Index ¶
- Variables
- type Equaler
- type Float
- type Int
- type Mutator
- type Operation
- type Vector
- func (v *Vector) Apply(m Mutator)
- func (v *Vector) ApplyRange(from, to int, m Mutator) error
- func (v *Vector) At(i int) (Equaler, error)
- func (v *Vector) Count() int
- func (v *Vector) Do(fn Operation)
- func (v *Vector) DoRange(from, to int, fn Operation) error
- func (v *Vector) End() int
- func (v *Vector) Len() int
- func (v *Vector) Set(i int, e Equaler)
- func (v *Vector) SetRange(start, end int, e Equaler)
- func (v *Vector) Start() int
- func (v *Vector) StepAt(i int) (start, end int, e Equaler, err error)
- func (v *Vector) String() string
Constants ¶
This section is empty.
Variables ¶
Functions ¶
This section is empty.
Types ¶
type Mutator ¶
A Mutator is a function that is used by Apply and ApplyRange to alter values within a Vector.
var ( IncInt Mutator = incInt // Increment an int value. DecInt Mutator = decInt // Decrement an int value. IncFloat Mutator = incFloat // Increment a float64 value. DecFloat Mutator = decFloat // Decrement a float64 value. )
Convenience mutator functions. Mutator functions are used by Apply and ApplyRange to alter step values in a value-dependent manner. These mutators assume the stored type matches the function and will panic is this is not true.
type Operation ¶
An Operation is a non-mutating function that can be applied to a vector using Do and DoRange.
type Vector ¶
type Vector struct { Zero Equaler // Ground state for the step vector. Relaxed bool // If true, dynamic vector resize is allowed. // contains filtered or unexported fields }
A Vector is type that support the storage of array type data in a run-length encoding format.
func New ¶
New returns a new Vector with the extent defined by start and end, and the ground state defined by zero. The Vector's extent is mutable if the Relaxed field is set to true. If a zero length vector is requested an error is returned.
func (*Vector) Apply ¶
Apply applies the mutator function m to steps stored in the Vector in ascending sort order of start position. Redundant steps resulting from changes in step values are erased.
func (*Vector) ApplyRange ¶
Apply applies the mutator function m to steps stored in the Vector in over the range [from, to) in ascending sort order of start position. Redundant steps resulting from changes in step values are erased.
func (*Vector) At ¶
At returns the value of the vector at position i. If i is outside the extent of the vector an error is returned.
func (*Vector) Do ¶
Do performs the function fn on steps stored in the Vector in ascending sort order of start position. fn is passed the start, end and value of the step.
func (*Vector) DoRange ¶
Do performs the function fn on steps stored in the Vector over the range [from, to) in ascending sort order of start position. fn is passed the start, end and value of the step.
func (*Vector) Len ¶
Len returns the length of the represented data array, that is the distance between the start and end of the vector.