Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DefaultRangedValue ¶
type DefaultRangedValue struct {
// contains filtered or unexported fields
}
func (DefaultRangedValue) GetMax ¶
func (r DefaultRangedValue) GetMax() uint64
func (DefaultRangedValue) GetMin ¶
func (r DefaultRangedValue) GetMin() uint64
func (DefaultRangedValue) GetValue ¶
func (r DefaultRangedValue) GetValue() interface{}
type DefaultWeightedValue ¶
type DefaultWeightedValue struct {
Weight uint64
Value interface{}
}
func (DefaultWeightedValue) GetValue ¶
func (w DefaultWeightedValue) GetValue() interface{}
func (DefaultWeightedValue) GetWeight ¶
func (w DefaultWeightedValue) GetWeight() uint64
type ErrDiscontinuity ¶
type ErrDiscontinuity struct {
// contains filtered or unexported fields
}
func (ErrDiscontinuity) Error ¶
func (ex ErrDiscontinuity) Error() string
type ErrEmptyInput ¶
type ErrEmptyInput struct{}
func (ErrEmptyInput) Error ¶
func (ex ErrEmptyInput) Error() string
type ErrOutOfRange ¶
type ErrOutOfRange struct {
// contains filtered or unexported fields
}
func (ErrOutOfRange) Error ¶
func (ex ErrOutOfRange) Error() string
type ErrOverlap ¶
type ErrOverlap struct {
// contains filtered or unexported fields
}
func (ErrOverlap) Error ¶
func (ex ErrOverlap) Error() string
type ErrUnsignedIntegerOverflow ¶
type ErrUnsignedIntegerOverflow struct {
// contains filtered or unexported fields
}
func (ErrUnsignedIntegerOverflow) Error ¶
func (ex ErrUnsignedIntegerOverflow) Error() string
type Node ¶
type Node struct {
// contains filtered or unexported fields
}
func NewRangeStoreFromSorted ¶
Builds a optimal(ish) tree containing the range values as node values. For the computation of optimality, we assume that every value in the aggregate ranges is equally likely to be looked up. We then choose pivots so that roughly equal amounts of range are in each subtree.
That is, with a set of values like: * A [0,1] * B [1,2] * C [2,3] The tree produced will look like
B [2] ___|___ | | A C
[1] [3]
However with non-equal weights, such as * A [0,1] * B [1,2] * C [2,100] The tree produced will look more like
C
[100]
___|
|
A
[1]
|___
|
B
[2]
Although this tree is degenerate based on a counting of *nodes* it is optimal based on lookup frequency, since ~98% of lookups will terminate at the root node and only very infrequently will recursion down the tree occur.
_Note_: The items passed to RangeStoreFRomSorted must contain a monotonically increasing and continuous sequence of min and max values
_Note_: Construction of the tree is done using Mehlhorn's approximation for balancing the tree and uses an effective floor (unsigned integer division) when computing pivots. As a result, the produced data structure approaches, but may not always be exactly, optimal.
func (*Node) RangeSearch ¶
Searches for the range which contains the specified key and returns the associated value, or an error if the value is out of range