MCPcopy Create free account
hub / github.com/TheAlgorithms/Go / GetParent

Function GetParent

strings/ahocorasick/shared.go:99–108  ·  view source on GitHub ↗

GetParent Function that finds the first previous state of a state and returns it. Used for trie where there is only one parent.

(state int, at map[int]map[uint8]int)

Source from the content-addressed store, hash-verified

97// GetParent Function that finds the first previous state of a state and returns it.
98// Used for trie where there is only one parent.
99func GetParent(state int, at map[int]map[uint8]int) (uint8, int) {
100 for beginState, transitions := range at {
101 for c, endState := range transitions {
102 if endState == state {
103 return c, beginState
104 }
105 }
106 }
107 return 0, 0 //unreachable
108}
109
110// CreateNewState Automaton function for creating a new state 'state'.
111func CreateNewState(state int, at map[int]map[uint8]int) {

Callers 2

BuildAcFunction · 0.85
BuildExtendedAcFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected