Documentation
¶
Index ¶
- type Index
- func (idx *Index) Add(camel token.Token, screaming token.Token) bool
- func (idx *Index) Clone() Index
- func (idx Index) ContainsForward(tok token.Token) bool
- func (idx Index) ContainsReverse(tok token.Token) bool
- func (idx *Index) Delete(key token.Token) bool
- func (idx Index) ForwardValue() IndexedReplacement
- func (idx Index) FowardIsEmpty() bool
- func (idx *Index) GetForward(t token.Token) (IndexedReplacement, bool)
- func (idx *Index) GetReverse(t token.Token) (IndexedReplacement, bool)
- func (idx Index) HasForwardValue() bool
- func (idx Index) HasMatch() bool
- func (idx Index) HasNode(tok token.Token) bool
- func (idx Index) HasPartialMatches() bool
- func (idx Index) HasReverseValue() bool
- func (idx Index) LastMatch() IndexedReplacement
- func (idx Index) MatchForward(t token.Token) (Index, bool)
- func (idx Index) MatchReverse(t token.Token) (Index, bool)
- func (idx *Index) Nodes() []Index
- func (idx Index) PartialMatches() []token.Token
- func (idx Index) ReverseIsEmpty() bool
- func (idx Index) ReverseValue() IndexedReplacement
- func (idx *Index) Values() []IndexedReplacement
- type IndexedReplacement
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Index ¶
type Index struct {
// contains filtered or unexported fields
}
Index is a double trie (forward and backward indexed) of token.Token.
func New ¶
NewIndex creates a new Index of Replacements, internally represented as Trie
reverseIndexes indicates whether or not
func (*Index) Add ¶
Add inserts r into the Index, indexed by the lowercase variant of r.Camel AND r.Screaming.
If the Index does not contains the IndexedReplacement repesentation of r, one is created, inserted, and true is returned. Otherwise, the previous value is replaced with a new IndexedReplacement.
If idx.IsReversed is true, the IndexedReplacement is inserted into the Index with the key in reverse order (e.g. AnExample -> elpmaxena).
func (Index) ForwardValue ¶
func (idx Index) ForwardValue() IndexedReplacement
func (Index) FowardIsEmpty ¶
func (*Index) GetForward ¶
func (idx *Index) GetForward(t token.Token) (IndexedReplacement, bool)
GetForwrad searches the index for the t, returning the IndexedReplacement and true if found.
To GetForward a reversed value, use GetReverse.
func (*Index) GetReverse ¶
func (idx *Index) GetReverse(t token.Token) (IndexedReplacement, bool)
GetReverse seeks the value at the reversed path of t, returning the IndexedReplacement and true if the value is found.
Note: the value itself is not reversed, but the path is. For example, a search for "nsoj" would return an IndexedReplacement with the value "JSON"/"Json" (assuming it exists)
func (Index) HasForwardValue ¶
func (Index) HasPartialMatches ¶
func (Index) HasReverseValue ¶
func (Index) LastMatch ¶
func (idx Index) LastMatch() IndexedReplacement
func (Index) MatchForward ¶
MatchForward searches the index for the given token, returning an Index node.
If t is empty, the root node is returned.
If the Index does not contain the node, an empty Index is returned ¶
Note: Use MatchReverse if seeking a reversed value
func (Index) MatchReverse ¶
MatchReverse attempts to find the Index at the reversed path of t, returning an Index containing partial matches and the last match found, if it exists.
Note: the value itself is not reversed, but the path is. For example, a search for "nsoj" would return an Index with the LastReverseMatch of "JSON"/"Json" (assuming it exists)
func (Index) PartialMatches ¶
func (Index) ReverseIsEmpty ¶
func (Index) ReverseValue ¶
func (idx Index) ReverseValue() IndexedReplacement
func (*Index) Values ¶
func (idx *Index) Values() []IndexedReplacement
type IndexedReplacement ¶
IndexedReplacement is a node in an Index created from a Replacement
func (IndexedReplacement) HasValue ¶
func (ir IndexedReplacement) HasValue() bool
func (IndexedReplacement) IsEmpty ¶
func (ir IndexedReplacement) IsEmpty() bool
IsEmpty reports whether or not ir is empty