Documentation ¶
Overview ¶
package vecstring provides a space-efficient representation of a vector of strings of variable length.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type VecString ¶
type VecString interface { // Get returns V[ind] Get(ind uint64) string // Find returns true if c is found in V[ind], and returns false otherwise. Find(ind uint64, c byte) bool // KeysNum returns the number of strings Num() uint64 // TotalLen returns the total length of strings TotalLen() uint64 // ExactMatch returns true if V[ind] == str, and returns false otherwise ExactMatch(ind uint64, str string) bool // PrefixMatch returns true if V[ind] == Prefix of str, and returns false otherwise PrefixMatch(ind uint64, str string) (uint64, bool) // LenAndOffset returns the length of V[ind] and len(V[0]+...+len(V[ind-1]) LenAndOffset(ind uint64) (uint64, uint64) // MarshalBinary encodes VecString into a binary form and returns the result. MarshalBinary() ([]byte, error) // UnmarshalBinary decodes the FixVec form a binary from generated MarshalBinary UnmarshalBinary([]byte) error // PushBack set V[KeysNum] = v, and KeysNum++ PushBack(v string) }
VecString represents a vector V[0...KeysNum), and each value V[i] represents a string Internally, VecString are stored in space-efficient way. Strings are concatenated in a byte array, and each offset, length information is encoded in unary coding, and represented by rsdic to achieve further space reduction. // For strings of total lengths = TotalLen, VecString stores them in at most TotalLen + KeysNum * (2 + log_2 TotalLen / KeysNum) / 8 bytes.
type VecStringForWX ¶
type VecStringForWX interface { VecString // GetByte returns the (offset+1)-th byte in the concatenated strings. GetByte(offset uint64) byte // FindZeroRank finds c in V[ind], and returns (offset, true) if found, // and returns (0, false) otherwise. FindZeroRank(ind uint64, c byte) (uint64, bool) // IthCharInd returns the index corresponding to i-th child. // lens.Rank(lens.Select(i-1, false), true) - 1 IthCharInd(i uint64) uint64 }
VecStringForWX represents a vector of strings, and provides extended interface for library WX.