コード例 #1
0
        /// <summary>
        /// Constructs a new occurence pattern-mather
        /// </summary>
        /// <param name="patternName"><see cref="PatternName"/>.</param>
        /// <param name="matchCount">The amount of matches necessary to constitute a pattern-match.</param>
        /// <param name="minLookBackCount"><see cref="MinLookBackCount"/>.</param>
        /// <param name="maxLookBackCount"><see cref="MaxLookBackCount"/>.</param>
        /// <param name="predicateBuilderFunction">The function that builds the predicate.</param>
        public OccurencePatternMatcher(string patternName, int matchCount, int minLookBackCount, int maxLookBackCount,
                                       Func <T, T, Func <T, bool> > predicateBuilderFunction)
        {
            //Cache the parameters.
            _matchCount      = matchCount;
            PatternName      = patternName;
            MinLookBackCount = minLookBackCount;
            MaxLookBackCount = maxLookBackCount;

            //Initialize the history.
            _history = new OccurenceHistory <T>(MaxLookBackCount - 1);

            //Initialize the predicate builder and property.
            _predicateBuilder   = new RangePredicateBuilder <T, T>(predicateBuilderFunction);
            _predicateContainer = new LazyContainer <Func <T, bool> >(_predicateBuilder.BuildPredicate);
        }
コード例 #2
0
        /// <summary>
        /// Creates a new Pattern filter.
        /// </summary>
        /// <param name="patternName">Name of the pattern this filter matches for.</param>
        /// <param name="checkAmount">The amount of concurrent previous values to check.</param>
        /// <param name="matchAmount">The amount of instances of the <paramref name="neighborComparison"/> at which point the pattern is matched.</param>
        /// <param name="neighbourOffset">The size of the step between the value to check and it's neighbour.</param>
        /// <param name="neighborComparison">The predicate to compare the value and it's neighbour <paramref name="neighbourOffset"/> before it.</param>
        public NeighbourPatternMatcher(string patternName, int checkAmount, int matchAmount, int neighbourOffset,
                                       Func <Pair <T>, bool> neighborComparison)
        {
            PatternName = patternName;

            //Cache values.
            _matchAmount     = matchAmount;
            _neighbourOffset = neighbourOffset;

            //Calculate the look back range.
            MinLookBackCount = matchAmount + neighbourOffset;
            MaxLookBackCount = checkAmount + neighbourOffset;

            _history = new NeighbourHistory <T>(MaxLookBackCount - 1, neighbourOffset);

            _predicateBuilder   = new DefaultPredicateBuilder <T, Pair <T> >(neighborComparison);
            _predicateContainer = new LazyContainer <Func <Pair <T>, bool> >(_predicateBuilder.BuildPredicate);
        }