예제 #1
0
        // rules are ordered in our bucket from:
        //  most criteria -> least criteria
        // this is described in the responsesystem talk, and is because if a rule
        // with more criteria (that's more specific) matches, we don't need to find
        // a rule that's less specific, we've already got the most specific one \o/
        //
        //TODO(dan): apply critereon weight when doing this as well.
        public void Insert(RSRule rule)
        {
            int c = rule.CriteriaCount();

            if (this.rules.Count == 0)
            {
                this.rules.Add(rule);
                return;
            }

            for (int i = 0; i <= c; i++)
            {
                if (i == c)
                {
                    this.rules.Add(rule);
                    break;
                }
                else if (this.rules[i].CriteriaCount() < c)
                {
                    this.rules.Insert(i, rule);
                    break;
                }
            }
        }