string2strings

package module
v0.0.0-...-6045090 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 9, 2014 License: BSD-2-Clause Imports: 6 Imported by: 0

README

String2Strings

String2Strings is an implementation of a map or dictionary of strings to slices of strings. The values are lists of strings which may be sorted or unsorted.

Sorted and Unsorted lists

When sorted, the data structure will maintain the slice of strings in lexicographical order. When unsorted, the data structure will maintain the slice of strings in insertion order.

Additional documentation available via 'godoc string2strings'

Documentation

Overview

Package string2strings provides concurrency safe implementation of a map of strings to slices of strings.

Index

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL