Documentation ¶
Overview ¶
Package symboltab is a symbol table. It converts strings to sequence numbers. This is useful for things like graph algorithms, where IDs are stored and compared a lot.
symboltab is optimised for storing a lot of strings, so things are optimised for reducing work for the GC
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Naive ¶ added in v1.1.2
type Naive struct {
// contains filtered or unexported fields
}
Naive implementation of the same function. Really just intended to compare against
func NewNaive ¶ added in v1.1.2
NewNaive creates a new, basic implementation of the symboltable function
func (*Naive) SequenceToString ¶ added in v1.1.2
SequenceToString retrieves the string for a sequence number
type SymbolTab ¶
type SymbolTab struct {
// contains filtered or unexported fields
}
SymbolTab is the symbol table. Allocate it via New()
Example ¶
st := SymbolTab{} seq, found := st.StringToSequence("10293-ahdb-28383-555", true) fmt.Println(found) fmt.Println(st.SequenceToString(seq))
Output: false 10293-ahdb-28383-555
func New ¶
New creates a new SymbolTab. cap is the initial capacity of the table - it will grow automatically when needed
func (*SymbolTab) SequenceToString ¶
SequenceToString looks up a string by its sequence number. Obtain the sequence number for a string with StringToSequence
func (*SymbolTab) StringToSequence ¶
StringToSequence looks up the string val and returns its sequence number seq. If val does not currently exist in the symbol table, it will add it if addNew is true. found indicates whether val was already present in the SymbolTab
func (*SymbolTab) SymbolSize ¶
SymbolSize contains the approximate size of string storage in the symboltable. This will be an over-estimate and includes as yet unused and wasted space