Documentation ¶
Index ¶
- func CreateByteSliceCopy(b []byte) []byte
- func TotalRangeLength(ranges []*IndexRange) int64
- func Utf16BytesToString(b []byte, o binary.ByteOrder) string
- func Utf16BytesToStringBE(b []byte) string
- func Utf16BytesToStringLE(b []byte) string
- type IndexRange
- func (ir *IndexRange) Adjacent(other *IndexRange) bool
- func (ir *IndexRange) CompareTo(other *IndexRange) int64
- func (ir *IndexRange) Equals(other *IndexRange) bool
- func (ir *IndexRange) Gap(other *IndexRange) *IndexRange
- func (ir *IndexRange) Includes(other *IndexRange) bool
- func (ir *IndexRange) Intersection(other *IndexRange) *IndexRange
- func (ir *IndexRange) Intersects(other *IndexRange) bool
- func (ir *IndexRange) Length() int64
- func (ir *IndexRange) Merge(other *IndexRange) *IndexRange
- func (ir *IndexRange) PartitionBy(size int64) []*IndexRange
- func (ir *IndexRange) String() string
- func (ir *IndexRange) Subtract(other *IndexRange, result []*IndexRange) []*IndexRange
- func (ir *IndexRange) SubtractRanges(ranges []*IndexRange, sortandDedup bool, result []*IndexRange) []*IndexRange
- type UUID
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CreateByteSliceCopy ¶
CreateByteSliceCopy creates and returns a copy of the given slice.
func TotalRangeLength ¶
func TotalRangeLength(ranges []*IndexRange) int64
TotalRangeLength returns the total length of a given slice of ranges.
func Utf16BytesToString ¶
Utf16BytesToString decode the given UTF16 encoded byte sequence and returns Go UTF8 encoded string, the byte order of the sequence is determined by the given binary.ByteOrder parameter.
func Utf16BytesToStringBE ¶
Utf16BytesToStringBE decode the given UTF16 encoded byte sequence and returns Go UTF8 encoded string, the byte order of the given sequence is big-endian.
func Utf16BytesToStringLE ¶
Utf16BytesToStringLE decode the given UTF16 encoded byte sequence and returns Go UTF8 encoded string, the byte order of the given sequence is little-endian.
Types ¶
type IndexRange ¶
IndexRange represents sequence of integral numbers in a specified range, where range starts at Start and ends at End, inclusive
func ChunkRangesBySize ¶
func ChunkRangesBySize(ranges []*IndexRange, chunkSizeInBytes int64) []*IndexRange
ChunkRangesBySize produces a set of ranges by partitioning the ranges in the given ranges by the given partition-size. Each each range in the given ranges X will be partitioned by the given partition-size to produce a range set A. If the last range in A is not of partition-size and if it is adjacent to the next range in the X then we calculate the bytes required to reach partition-size and
- if next range has more bytes than required, then we borrow the required bytes from next range and advances the next range start
- if next range has less or equal to the required bytes, then we borrow available and skip next range
func NewIndexRange ¶
func NewIndexRange(start, end int64) *IndexRange
NewIndexRange creates a new range with start as value of the first integer in the sequence and end as value of last integer in the sequence.
func NewIndexRangeFromLength ¶
func NewIndexRangeFromLength(start, length int64) *IndexRange
NewIndexRangeFromLength creates a new range starting from start and ends at start + length - 1.
func SubtractRanges ¶
func SubtractRanges(minuends, subtrahends []*IndexRange) []*IndexRange
SubtractRanges produces a set of ranges, each subset of ranges in this set is produced by subtracting subtrahends from each range in minuends.
func (*IndexRange) Adjacent ¶
func (ir *IndexRange) Adjacent(other *IndexRange) bool
Adjacent checks this range starts immediately starts after the other range or vice-versa, a return value nil indicates the ranges intersects or there is a gap between the ranges.
func (*IndexRange) CompareTo ¶
func (ir *IndexRange) CompareTo(other *IndexRange) int64
CompareTo indicates whether the this range precedes, follows, or occurs in the same position in the sort order as the other A return value
Less than zero: This range precedes the other in the sort order, range A precedes range B if A start before B or both has the same start and A ends before B. Zero: This range occurs in the same position as other in sort order, two ranges are in the same sort position if both has the same start and end Greater than zero: This range follows the other in the sort order, a range A follows range B, if A start after B or both has the same start and A ends after B
func (*IndexRange) Equals ¶
func (ir *IndexRange) Equals(other *IndexRange) bool
Equals returns true if this and given range represents the same sequence, two sequences are same if both have the same start and end.
func (*IndexRange) Gap ¶
func (ir *IndexRange) Gap(other *IndexRange) *IndexRange
Gap compute the range representing the gap between this and the other range, a return value nil indicates there is no gap because either the ranges intersects or they are adjacent.
func (*IndexRange) Includes ¶
func (ir *IndexRange) Includes(other *IndexRange) bool
Includes checks this range includes the other range, a range A includes range B if B starts and ends within A, inclusive. In other words a range A includes range B if their intersection produces B
func (*IndexRange) Intersection ¶
func (ir *IndexRange) Intersection(other *IndexRange) *IndexRange
Intersection computes the range representing the intersection of two ranges, a return value nil indicates the ranges does not intersects.
func (*IndexRange) Intersects ¶
func (ir *IndexRange) Intersects(other *IndexRange) bool
Intersects checks this and other range intersects, two ranges A and B intersects if either of them starts or ends within the range of other, inclusive.
func (*IndexRange) Length ¶
func (ir *IndexRange) Length() int64
Length returns number of sequential integers in the range.
func (*IndexRange) Merge ¶
func (ir *IndexRange) Merge(other *IndexRange) *IndexRange
Merge produces a range by merging this and other range if they are adjacent. Trying to merge non-adjacent ranges are panic.
func (*IndexRange) PartitionBy ¶
func (ir *IndexRange) PartitionBy(size int64) []*IndexRange
PartitionBy produces a slice of adjacent ranges of same size, first range in the slice starts where this range starts and last range ends where this range ends. The length of last range will be less than size if length of this range is not multiple of size.
func (*IndexRange) String ¶
func (ir *IndexRange) String() string
String returns the string representation of this range, this satisfies stringer interface.
func (*IndexRange) Subtract ¶
func (ir *IndexRange) Subtract(other *IndexRange, result []*IndexRange) []*IndexRange
Subtract subtracts other range from this range and appends the ranges representing the differences to result slice.
Given two ranges A and B, A - B produces
- No result a. If they are equal or b. B includes A i.e 'A n B' = A OR
- A, if they don't intersects OR
- [(A n B).End + 1, A.End], if A and 'A n B' has same start OR
- [A.Start, (A n B).Start - 1], if A and 'A n B' has same end OR
- { [A.Start, (A n B).Start - 1], [(A n B).End + 1, A.End] }, otherwise
func (*IndexRange) SubtractRanges ¶
func (ir *IndexRange) SubtractRanges(ranges []*IndexRange, sortandDedup bool, result []*IndexRange) []*IndexRange
SubtractRanges subtracts a set of ranges from this range and appends the ranges representing the differences to result slice. The result slice will be sorted and de-duped if sortandDedup is true.
type UUID ¶
type UUID struct {
// contains filtered or unexported fields
}
UUID represents a Universally Unique Identifier.
func (*UUID) String ¶
String returns the string representation of the UUID which is 16 hex digits separated by hyphens int form xxxx-xx-xx-xx-xxxxxx
func (*UUID) ToByteSlice ¶
ToByteSlice returns the UUID as byte slice.