Documentation
¶
Overview ¶
Package index contains a trie index used by StdConverter to lookup Replacements.
Index ¶
- type Index
- func (idx *Index) Add(camel string, screaming string) bool
- func (idx *Index) Clone() Index
- func (idx Index) Contains(s string) bool
- func (idx *Index) Delete(key string) bool
- func (idx *Index) Get(s string) (IndexedReplacement, bool)
- func (idx Index) HasMatched() bool
- func (idx Index) HasPartialMatches() bool
- func (idx Index) HasValue() bool
- func (idx Index) LastMatch() IndexedReplacement
- func (idx Index) Match(s string) (Index, bool)
- func (idx *Index) Nodes() []Index
- func (idx Index) PartialMatchRunes() []rune
- func (idx Index) PartialMatches() string
- func (idx Index) Value() 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 trie index used by Converter to lookup Replacements.
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) Get ¶ added in v0.4.0
func (idx *Index) Get(s string) (IndexedReplacement, bool)
Get searches the index for the t, returning the IndexedReplacement and true if found.
To GetForward a reversed value, use GetReverse.
func (Index) HasMatched ¶ added in v0.7.0
func (Index) HasPartialMatches ¶
func (Index) LastMatch ¶
func (idx Index) LastMatch() IndexedReplacement
func (Index) Match ¶ added in v0.4.0
Match 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 ¶
func (Index) PartialMatchRunes ¶ added in v0.8.2
func (Index) Value ¶ added in v0.4.0
func (idx Index) Value() IndexedReplacement
func (*Index) Values ¶
func (idx *Index) Values() []IndexedReplacement
Values returns all IndexedReplacements in the Index
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