index

package
v0.4.11 Latest Latest
Warning

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

Go to latest
Published: Aug 31, 2022 License: MIT Imports: 1 Imported by: 0

Documentation

Overview

Package index contains a trie index used by Converter to lookup Replacements.

Index

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

func New(caser token.Caser) *Index

NewIndex creates a new Index of Replacements, internally represented as Trie

reverseIndexes indicates whether or not

func (*Index) Add

func (idx *Index) Add(camel token.Token, screaming token.Token) bool

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) Clone added in v0.3.5

func (idx *Index) Clone() Index

func (Index) Contains added in v0.4.0

func (idx Index) Contains(tok token.Token) bool

func (*Index) Delete

func (idx *Index) Delete(key token.Token) bool

func (*Index) Get added in v0.4.0

func (idx *Index) Get(t token.Token) (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) HasMatch

func (idx Index) HasMatch() bool

func (Index) HasNode

func (idx Index) HasNode(tok token.Token) bool

func (Index) HasPartialMatches

func (idx Index) HasPartialMatches() bool

func (Index) HasValue added in v0.4.0

func (idx Index) HasValue() bool

HasValue reports true if the current node has a value

func (Index) LastMatch

func (idx Index) LastMatch() IndexedReplacement

func (Index) Match added in v0.4.0

func (idx Index) Match(t token.Token) (Index, bool)

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) Nodes

func (idx *Index) Nodes() []Index

func (Index) PartialMatches

func (idx Index) PartialMatches() []token.Token

func (Index) Value added in v0.4.0

func (idx Index) Value() IndexedReplacement

func (*Index) Values

func (idx *Index) Values() []IndexedReplacement

type IndexedReplacement

type IndexedReplacement struct {
	Screaming token.Token
	Camel     token.Token
	Lower     token.Token
}

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

Jump to

Keyboard shortcuts

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