trie

package
v0.0.0-...-1763559 Latest Latest
Warning

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

Go to latest
Published: Jun 29, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package trie :: nodeStack.go

Package trie :: runePhases.go

Package trie :: runeTrie.go

Package trie :: runeTrieNodeStack.go

Package trie :: trie.go

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Node

type Node struct {
	// contains filtered or unexported fields
}

Node struct

func NewNode

func NewNode(k string) *Node

NewNode constructs a Node and return its pointer

func (*Node) Add

func (n *Node) Add(k string) *Node

Add is a Node pointer receiver to add a new Node to children

func (*Node) Contains

func (n *Node) Contains(k string) bool

Contains is a Node pointer receiver to check if a child key exists

func (*Node) Equals

func (n *Node) Equals(p *Node) bool

Equals checks if two nodes have the same content

func (*Node) GetChildNode

func (n *Node) GetChildNode(k string) *Node

GetChildNode is a Node pointer receiver to get a node by key

func (*Node) GetChildren

func (n *Node) GetChildren() map[string]*Node

GetChildren is a Node pointer method receiver to get node's children

func (*Node) GetChildrenKeys

func (n *Node) GetChildrenKeys() []string

GetChildrenKeys is a Node pointer receiver to get children's keys

func (*Node) GetChildrenNodes

func (n *Node) GetChildrenNodes() []*Node

GetChildrenNodes is a Node pointer receiver to get children's nodes

func (*Node) GetContent

func (n *Node) GetContent() string

GetContent is a Node pointer method receiver to get content of the node

func (*Node) IsContent

func (n *Node) IsContent(k string) bool

IsContent func returns true if the node content is as same as specified string; otherwise, false

func (*Node) IsEnd

func (n *Node) IsEnd() bool

IsEnd checks if the node is the phase end

func (*Node) String

func (n *Node) String() string

String func

type NodeItem

type NodeItem struct {
	// contains filtered or unexported fields
}

NodeItem struct

func (*NodeItem) String

func (e *NodeItem) String() string

String func for NodeItem

type NodeStack

type NodeStack struct {
	// contains filtered or unexported fields
}

NodeStack struct

func (*NodeStack) Peek

func (s *NodeStack) Peek() *NodeItem

Peek is a pointer method receiver for NodeStack to peek the top item

func (*NodeStack) Pop

func (s *NodeStack) Pop() *NodeItem

Pop is a pointer method receiver for NodeStack to pop the top item

func (*NodeStack) Push

func (s *NodeStack) Push(p *NodeItem)

Push is a pointer method receiver for NodeStack to push into the stack

func (*NodeStack) Size

func (s *NodeStack) Size() int

Size is a pointer method receiver for NodeStack to return the stack size

func (*NodeStack) String

func (s *NodeStack) String() string

String func for NodeStack

type RunePhases

type RunePhases []string

RunePhases type

func (RunePhases) Len

func (rs RunePhases) Len() int

Len implements Len() in sort.Interface for RunePhases

func (RunePhases) Less

func (rs RunePhases) Less(x, y int) bool

Less implements Less() in sort.Interface for RunePhases

func (RunePhases) Swap

func (rs RunePhases) Swap(x, y int)

Swap implements Swap() in sort.Interface for RunePhases

type RuneTrie

type RuneTrie struct {
	// contains filtered or unexported fields
}

RuneTrie struct

func NewRuneTrie

func NewRuneTrie(endchar rune) *RuneTrie

NewRuneTrie constructs a RuneTrie with specific end and returns its pointer

func (*RuneTrie) FindMatchedPhases

func (t *RuneTrie) FindMatchedPhases(prefix string) []string

FindMatchedPhases returns a list of phases match the prefix

func (*RuneTrie) HasMatch

func (t *RuneTrie) HasMatch(prefix string) (bool, bool, *RuneTrieNode, int)

HasMatch checks if there is a matched prefix in the trie, additionally returns the last matched node and matched length

func (*RuneTrie) Load

func (t *RuneTrie) Load(phase string)

Load is a RuneTrie pointer receiver to add a string phase to the trie

type RuneTrieNode

type RuneTrieNode struct {
	// contains filtered or unexported fields
}

RuneTrieNode struct

func NewRuneTrieNode

func NewRuneTrieNode(k rune) *RuneTrieNode

NewRuneTrieNode constructs a RuneTrieNode and return its pointer

func (*RuneTrieNode) Add

func (n *RuneTrieNode) Add(k rune) *RuneTrieNode

Add is a RuneTrieNode pointer receiver to add a new RuneTrieNode to children

func (*RuneTrieNode) Contains

func (n *RuneTrieNode) Contains(k rune) bool

Contains is a RuneTrieNode pointer receiver to check if a child key exists

func (*RuneTrieNode) Equals

func (n *RuneTrieNode) Equals(p *RuneTrieNode) bool

Equals checks if two nodes have the same content

func (*RuneTrieNode) GetChildNode

func (n *RuneTrieNode) GetChildNode(k rune) *RuneTrieNode

GetChildNode is a RuneTrieNode pointer receiver to get a node by key

func (*RuneTrieNode) GetChildren

func (n *RuneTrieNode) GetChildren() map[rune]*RuneTrieNode

GetChildren is a RuneTrieNode pointer method receiver to get node's children

func (*RuneTrieNode) GetChildrenKeys

func (n *RuneTrieNode) GetChildrenKeys() []rune

GetChildrenKeys is a RuneTrieNode pointer receiver to get children's keys

func (*RuneTrieNode) GetChildrenNodes

func (n *RuneTrieNode) GetChildrenNodes() []*RuneTrieNode

GetChildrenNodes is a RuneTrieNode pointer receiver to get children's nodes

func (*RuneTrieNode) GetContent

func (n *RuneTrieNode) GetContent() rune

GetContent is a RuneTrieNode pointer method receiver to get content of the node

func (*RuneTrieNode) IsContent

func (n *RuneTrieNode) IsContent(k rune) bool

IsContent func returns true if the node content is as same as specified rune; otherwise, false

func (*RuneTrieNode) IsEnd

func (n *RuneTrieNode) IsEnd() bool

IsEnd checks if the node is the phase end

func (*RuneTrieNode) String

func (n *RuneTrieNode) String() string

String func

type RuneTrieNodeItem

type RuneTrieNodeItem struct {
	// contains filtered or unexported fields
}

RuneTrieNodeItem struct

func (*RuneTrieNodeItem) String

func (e *RuneTrieNodeItem) String() string

String func for RuneTrieItem

type RuneTrieStack

type RuneTrieStack struct {
	// contains filtered or unexported fields
}

RuneTrieStack struct

func (*RuneTrieStack) Peek

func (s *RuneTrieStack) Peek() *RuneTrieNodeItem

Peek is a pointer method receiver for RuneTrieStack to peek the top item

func (*RuneTrieStack) Pop

func (s *RuneTrieStack) Pop() *RuneTrieNodeItem

Pop is a pointer method receiver for RuneTrieStack to pop the top item

func (*RuneTrieStack) Push

func (s *RuneTrieStack) Push(p *RuneTrieNodeItem)

Push is a pointer method receiver for RuneTrieStack to push into the stack

func (*RuneTrieStack) Size

func (s *RuneTrieStack) Size() int

Size is a pointer method receiver for RuneTrieStack to return the stack size

func (*RuneTrieStack) String

func (s *RuneTrieStack) String() string

String func for RuneTrieStack

type Trie

type Trie struct {
	// contains filtered or unexported fields
}

Trie struct

func NewTrie

func NewTrie() *Trie

NewTrie constructs a Trie with specific end and returns its pointer

func (*Trie) FindMatchedPhases

func (t *Trie) FindMatchedPhases(prefix string) []string

FindMatchedPhases returns a list of phases match the prefix

func (*Trie) HasMatch

func (t *Trie) HasMatch(prefix string) (bool, bool, *Node, int)

HasMatch checks if there is a matched prefix in the trie, additionally returns the last matched node and matched length

func (*Trie) Load

func (t *Trie) Load(phase string)

Load is a Trie pointer receiver to add a string phase to the trie

Jump to

Keyboard shortcuts

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