Documentation
¶
Overview ¶
Package string2strings provides concurrency safe implementation of a map of strings to slices of strings.
Index ¶
- type SortedStrings
- type StringToStrings
- func (self *StringToStrings) Get(key string) (*SortedStrings, bool)
- func (self *StringToStrings) Keys() (keys []string)
- func (self *StringToStrings) MarshalJSON() ([]byte, error)
- func (self *StringToStrings) ScrubKey(key string)
- func (self *StringToStrings) ScrubValue(value string)
- func (self *StringToStrings) ScrubValueFromKey(value, key string)
- func (self *StringToStrings) Store(key, value string)
- func (self *StringToStrings) StoreStrings(key string, ss *SortedStrings)
- func (self *StringToStrings) String() string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type SortedStrings ¶
type SortedStrings struct {
// contains filtered or unexported fields
}
func NewSortedStrings ¶
func NewSortedStrings() *SortedStrings
func NewSortedStringsFromStrings ¶
func NewSortedStringsFromStrings(values []string) *SortedStrings
func (*SortedStrings) Delete ¶
func (self *SortedStrings) Delete(value string)
func (*SortedStrings) MarshalJSON ¶
func (self *SortedStrings) MarshalJSON() ([]byte, error)
func (*SortedStrings) Store ¶
func (self *SortedStrings) Store(value string)
func (*SortedStrings) String ¶
func (self *SortedStrings) String() string
func (*SortedStrings) Strings ¶
func (self *SortedStrings) Strings() []string
type StringToStrings ¶
type StringToStrings struct {
// contains filtered or unexported fields
}
func NewStringToStrings ¶
func NewStringToStrings() *StringToStrings
NewStringToStrings returns an initialized instance that maintains value strings in lexicographical order.
func (*StringToStrings) Get ¶
func (self *StringToStrings) Get(key string) (*SortedStrings, bool)
Get returns the list of strings associated with the specified key string.
func (*StringToStrings) Keys ¶
func (self *StringToStrings) Keys() (keys []string)
Keys returns a slice of strings representing the keys held in a StringToStrings instance. Note that the order of the keys returns is indeterminant because of Go's conscience decision to randomize map key values.
func (*StringToStrings) MarshalJSON ¶
func (self *StringToStrings) MarshalJSON() ([]byte, error)
MarshallJSON implements Marshaler interface for converting instance to JSON. This method is called by json.Marshal().
db := NewStringToStrings() bytes, err := json.Marshal(db)
func (*StringToStrings) ScrubKey ¶
func (self *StringToStrings) ScrubKey(key string)
ScrubKey removes the specified key from the instance, also removing the slice of strings associated with that key.
func (*StringToStrings) ScrubValue ¶
func (self *StringToStrings) ScrubValue(value string)
ScrubValue removes the specified value from all slices of strings in the instance. This handles both sorted and unsorted instances. Whereas the removal of a value from a sorted instance uses a binary tree to quickly remove the item, the removal of a value from an unsorted instance requires walking each slice of strings for each key in the instance.
func (*StringToStrings) ScrubValueFromKey ¶
func (self *StringToStrings) ScrubValueFromKey(value, key string)
func (*StringToStrings) Store ¶
func (self *StringToStrings) Store(key, value string)
Store either appends, when unsorted, or inserts, when sorted, the value to the slice of strings associated with the specified key string.
func (*StringToStrings) StoreStrings ¶
func (self *StringToStrings) StoreStrings(key string, ss *SortedStrings)
Store stores the entire list of SortedStrings at the specified key.
func (*StringToStrings) String ¶
func (self *StringToStrings) String() string