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

Function GetTransition

strings/ahocorasick/shared.go:121–130  ·  view source on GitHub ↗

GetTransition Returns ending state for transition σ(fromState,overChar), '-1' if there is none.

(fromState int, overChar uint8, at map[int]map[uint8]int)

Source from the content-addressed store, hash-verified

119
120// GetTransition Returns ending state for transition σ(fromState,overChar), '-1' if there is none.
121func GetTransition(fromState int, overChar uint8, at map[int]map[uint8]int) (toState int) {
122 if !StateExists(fromState, at) {
123 return -1
124 }
125 toState, ok := at[fromState][overChar]
126 if !ok {
127 return -1
128 }
129 return toState
130}
131
132// StateExists Checks if state 'state' exists. Returns 'true' if it does, 'false' otherwise.
133func StateExists(state int, at map[int]map[uint8]int) bool {

Callers 5

AhoCorasickFunction · 0.85
BuildAcFunction · 0.85
AdvancedFunction · 0.85
BuildExtendedAcFunction · 0.85
ConstructTrieFunction · 0.85

Calls 1

StateExistsFunction · 0.85

Tested by

no test coverage detected