//AddRule will add a given rule with the given priority and priority in the group
//It will also build the kmp pattern for the rule
AddRule will add a given rule with the given priority and priority in the group
It will also build the kmp pattern for the rule
// AddRule will add a given rule with the given priority and priority in the group // It will also build the kmp pattern for the rule
func AddRule(rule Rule, priority, groupPriority int, tag string) {
	if len(rules) > priority && rules[priority] == nil {
		rules[priority] = &RuleGroup{Rules: []Rule{}, Tag: tag}
	} else if len(rules) <= priority {
		rules = append(rules, make([]*RuleGroup, priority-len(rules)+1)...)
		rules[priority] = &RuleGroup{Rules: []Rule{}, Tag: tag}
	} else if len(rules) > priority && rules[priority] != nil && rules[priority].Tag != tag {
		rules[priority] = &RuleGroup{Rules: []Rule{}, Tag: tag}
	}
	groupRules := rules[priority].Rules
	if len(groupRules) <= groupPriority {
		groupRules = append(groupRules, make([]Rule, groupPriority-len(groupRules)+1)...)
	}
	rule.Pattern = NewKMP(rule.Template)
	groupRules[groupPriority] = rule
	rules[priority].Rules = groupRules
}
func AddRule ( rule Rule , priority , groupPriority int , tag string ) { if len ( rules ) > priority && rules [ priority ] == nil { rules [ priority ] = & RuleGroup { Rules : [ ] Rule { } , Tag : tag } } else if len ( rules ) <= priority { rules = append ( rules , make ( [ ] * RuleGroup , priority - len ( rules ) + 1 ) ... ) rules [ priority ] = & RuleGroup { Rules : [ ] Rule { } , Tag : tag } } else if len ( rules ) > priority && rules [ priority ] != nil && rules [ priority ] . Tag != tag { rules [ priority ] = & RuleGroup { Rules : [ ] Rule { } , Tag : tag } } groupRules := rules [ priority ] . Rules if len ( groupRules ) <= groupPriority { groupRules = append ( groupRules , make ( [ ] Rule , groupPriority - len ( groupRules ) + 1 ) ... ) } rule . Pattern = NewKMP ( rule . Template ) groupRules [ groupPriority ] = rule rules [ priority ] . Rules = groupRules }
AddRule will add a given rule with the given priority and priority in the group
It will also build the kmp pattern for the rule
AddRule will add a given rule with the given priority and priority in the group It will also build the kmp pattern for the rule
/*
	 * If the group rules doesn't exist add a new one
	 * If a different group exist replace it
	 * If the group doesn't have space to add a new rule. Increase the size of the rules
	 * Initialize the rule pattern
	 * Add the rule
	 */ //Adding new group if required //replacing an existing group //add space for rules to group if necessary //initialize the rule pattern //adding thr rule