Documentation
¶
Index ¶
- Constants
- Variables
- func Byte4ToInt(b byte) int
- func BytesDifference(priorTerm, currentTerm []byte) (int, error)
- func HighestOneBit(i int32) int32
- func Int4ToLong(i int) int64
- func IntToByte4(i int) byte
- func Log(x, base int) int
- func LongToInt4(i int64) int
- func NextUp(f float64) float64
- func NumberOfLeadingZeros(i int32) int
- func RandomId() []byte
- func SelectK(k int, data sort.Interface)
- func SelectorCheckArgs(from, to, k int)
- func StringRandomId(bs []byte) string
- func SumRelativeErrorBound(numValues int) float64
- type Bits
- type FrequencyTrackingRingBuffer
- type IntroSelector
- type IntroSelectorConfig
- type RefCount
- type Selector
Constants ¶
const (
ID_LENGTH = 16
)
Variables ¶
var ( MaxInt4 = LongToInt4(math.MaxInt32) NumFreeValues = 255 - MaxInt4 )
Functions ¶
func Byte4ToInt ¶
func BytesDifference ¶
func HighestOneBit ¶
func Int4ToLong ¶
func IntToByte4 ¶
func LongToInt4 ¶
func NumberOfLeadingZeros ¶
func SelectorCheckArgs ¶
func SelectorCheckArgs(from, to, k int)
func StringRandomId ¶
func SumRelativeErrorBound ¶
SumRelativeErrorBound Return a relative error bound for a sum of numValues positive doubles, computed using recursive summation, ie. sum = x1 + ... + xn. NOTE: This only works if all values are POSITIVE so that Σ |xi| == |Σ xi|. This uses formula 3.5 from Higham, Nicholas J. (1993), "The accuracy of floating point summation", SIAM Journal on Scientific Computing.
Types ¶
type Bits ¶
type Bits interface { // Test // Returns the value of the bit with the specified index. // index: index, should be non-negative and < length(). The result of passing negative or out of bounds // values is undefined by this interface, just don't do it! // Returns: true if the bit is set, false otherwise. Test(index uint) bool // Len // Returns the number of bits in this set Len() uint }
Bits Interface for Bitset-like structures.
type FrequencyTrackingRingBuffer ¶
type FrequencyTrackingRingBuffer struct {
// contains filtered or unexported fields
}
FrequencyTrackingRingBuffer A ring buffer that tracks the frequency of the integers that it contains. This is typically useful to track the hash codes of popular recently-used items. This data-structure requires 22 bytes per entry on average (between 16 and 28). lucene. internal
func NewFrequencyTrackingRingBuffer ¶
func NewFrequencyTrackingRingBuffer(maxSize int, sentinel int32) *FrequencyTrackingRingBuffer
func (*FrequencyTrackingRingBuffer) Add ¶
func (f *FrequencyTrackingRingBuffer) Add(i int32)
Add a new item to this ring buffer, potentially removing the oldest entry from this buffer if it is already full.
func (*FrequencyTrackingRingBuffer) Frequency ¶
func (f *FrequencyTrackingRingBuffer) Frequency(key int32) int32
Frequency Returns the frequency of the provided key in the ring buffer.
type IntroSelector ¶
type IntroSelector struct {
// contains filtered or unexported fields
}
func NewIntroSelector ¶
func NewIntroSelector(cfg *IntroSelectorConfig) *IntroSelector
func (*IntroSelector) Select ¶
func (r *IntroSelector) Select(from, to, k int)
func (*IntroSelector) Swap ¶
func (r *IntroSelector) Swap(i, j int)
type IntroSelectorConfig ¶
type RefCount ¶
func NewRefCount ¶
func (*RefCount[T]) DecRef ¶
DecRef Decrements the reference counting of this object. When reference counting hits 0, calls release().
func (*RefCount[T]) GetRefCount ¶
GetRefCount Returns the current reference count.
type Selector ¶
type Selector interface { // Select Reorder elements so that the element at position k is the same as if all elements were // sorted and all other elements are partitioned around it: [from, k) only contains elements that // are less than or equal to k and (k, to) only contains elements that are greater than or equal to k. Select(from, to, k int) // Swap values at slots i and j. Swap(i, j int) }
Selector An implementation of a selection algorithm, ie. computing the k-th greatest value from a collection.