MCPcopy Create free account
hub / github.com/coregx/coregex / Add

Method Add

dfa/lazy/state.go:431–443  ·  view source on GitHub ↗

Add adds an NFA state to the set

(state nfa.StateID)

Source from the content-addressed store, hash-verified

429
430// Add adds an NFA state to the set
431func (ss *StateSet) Add(state nfa.StateID) {
432 // Grow if needed
433 if int(state) >= len(ss.sparse) {
434 ss.grow(int(state) + 1)
435 }
436 if ss.Contains(state) {
437 return
438 }
439 // Direct assignment (O(1))
440 ss.dense[ss.size] = state
441 ss.sparse[state] = uint32(ss.size)
442 ss.size++
443}
444
445// grow expands the capacity to at least newCap
446func (ss *StateSet) grow(newCap int) {

Callers 15

TestStateSetDuplicateAddFunction · 0.95
TestStateSetClearFunction · 0.95
TestStateSetToSliceFunction · 0.95
TestStateSetCloneFunction · 0.95
FuzzMatchStdlibFunction · 0.80
FuzzFindStdlibFunction · 0.80
FuzzFindAllStdlibFunction · 0.80
FuzzFindSubmatchStdlibFunction · 0.80

Calls 2

growMethod · 0.95
ContainsMethod · 0.95

Tested by 15

TestStateSetDuplicateAddFunction · 0.76
TestStateSetClearFunction · 0.76
TestStateSetToSliceFunction · 0.76
TestStateSetCloneFunction · 0.76
FuzzMatchStdlibFunction · 0.64
FuzzFindStdlibFunction · 0.64
FuzzFindAllStdlibFunction · 0.64
FuzzFindSubmatchStdlibFunction · 0.64