/// <summary>
        /// Gets all available (not in the brackets) functions.
        /// </summary>
        /// <param name="expression">The expression to get all variable functions there</param>
        /// <param name="intervals">List of intervals, where functions are not available</param>
        /// <returns>List of standard functions instances</returns>
        public List <StandardFunction> GetStandardFunctions(string expression, List <Interval> intervals)
        {
            List <StandardFunction> standardFunctions = new List <StandardFunction>();

            foreach (string function in StandardFunction.WellKnownFunctions)
            {
                List <int> funcIndexes = ExpressionParsingHelpers.GetAllSubstringIndexes(expression, function);

                foreach (int idx in funcIndexes)
                {
                    if (!Interval.BelongsToIntevals(idx, intervals))
                    {
                        standardFunctions.Add(new StandardFunction(idx, function));
                    }
                }
            }

            return(standardFunctions);
        }
Beispiel #2
0
        public void IntervalBelongsToIntevalsTest()
        {
            List <Interval> intervals = new List <Interval>
            {
                new Interval(0, 3),
                new Interval(10, 14)
            };

            int[] idxsInInervals   = new int[] { 0, 1, 3, 10, 11, 14 };
            int[] idxsOutIntervals = new int[] { -1, 4, 7, 15 };

            foreach (int idx in idxsInInervals)
            {
                Assert.AreEqual(true, Interval.BelongsToIntevals(idx, intervals));
            }

            foreach (int idx in idxsOutIntervals)
            {
                Assert.AreEqual(false, Interval.BelongsToIntevals(idx, intervals));
            }
        }