Documentation ¶
Overview ¶
Package utils provides utility functions and types that are needed in elprep.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Find ¶
Find returns the first index in a slice of StringMap where the predicate returns true, or -1 if predicate never returns true.
func SymbolHash ¶
SymbolHash computes a hash value for the given Symbol.
Types ¶
type SmallMap ¶
type SmallMap []SmallMapEntry
A SmallMap maps keys to values, similar to Go's built-in maps. A SmallMap can be more efficient in terms of memory and runtime performance than a native map if it has only few entries. SmallMap keys are always symbols.
func (SmallMap) Delete ¶
Delete returns a SmallMap from which the first entry has been removed that has the same key as the given key.
It also returns true if an entry was removed, and false if no entry was removed because there was no entry for the given key.
func (SmallMap) DeleteIf ¶
DeleteIf returns a SmallMap from which all entries have been removed that satisfy the given test.
It also returns true if any entry was removed, and false if no entry was removed because no entry matched the given test.
func (SmallMap) Get ¶
Get returns the first entry in the SmallMap that has the same key as the given key.
It returns the found value and true if the key was found, otherwise nil and false.
type SmallMapEntry ¶
type SmallMapEntry struct { Key Symbol Value interface{} }
SmallMapEntry is an entry in a SmallMap.
type StringMap ¶
A StringMap maps strings to strings.
func (StringMap) SetUniqueEntry ¶
SetUniqueEntry checks if a mapping for the given key already exists in the StringMap. If this is the case, it returns false and the StringMap is not modified. Otherwise, the given key/value pair is added to the StringMap.
type Symbol ¶
type Symbol *string
A Symbol is a unique pointer to a string.
func Intern ¶
Intern returns a Symbol for the given string.
It always returns the same pointer for strings that are equal, and different pointers for strings that are not equal. So for two strings s1 and s2, if s1 == s2, then Intern(s1) == Intern(s2), and if s1 != s2, then Intern(s1) != Intern(s2).
Dereferencing the pointer always yields a string that is equal to the original string: *Intern(s) == s always holds.
It is safe for multiple goroutines to call Intern concurrently.