Пример #1
0
        /// <summary>
        /// Использовать в случае перечислимого индекса
        /// </summary>
        /// <param name="literals"></param>
        /// <returns></returns>
        public static ResolvedDiscreteRange FormEnumerationIndexes(List <EnumerationLiteral> literals)
        {
            foreach (var v in FormedEnumerationRanges)
            {
                if (v.Key == literals)
                {
                    return(v.Value);
                }
            }

            List <Literal> indexes = new List <Literal>();

            indexes.AddRange(literals);
            ResolvedDiscreteRange res = new ResolvedDiscreteRange(1, literals.Count, indexes);

            FormedEnumerationRanges.Add(literals, res);
            return(res);
        }
Пример #2
0
 public bool IsContainSubRange(ResolvedDiscreteRange subrange)
 {
     if (subrange.RangeDirection != RangeDirection)
     {
         return(false);
     }
     else
     {
         if (RangeDirection == RangeDirection.To)
         {
             return((from <= subrange.from) && (to >= subrange.to));
         }
         else
         {
             return((to <= subrange.to) && (from >= subrange.from));
         }
     }
 }
Пример #3
0
        /// <summary>
        /// Использовать в случае целочисленных индексов
        /// </summary>
        /// <param name="From"></param>
        /// <param name="To"></param>
        /// <returns></returns>
        public static ResolvedDiscreteRange FormIntegerIndexes(int From, int To)
        {
            foreach (var v in FormedIntegerRanges)
            {
                if ((v.Key[0] == From) && (v.Key[1] == To))
                {
                    return(v.Value);
                }
            }

            List <Literal> indexes = new List <Literal>();

            if (From == To)
            {
                indexes.Add(new DecBasedInteger(From));
            }
            else
            {
                if (From < To)
                {
                    for (int i = From; i <= To; i++)
                    {
                        indexes.Add(new DecBasedInteger(i));
                    }
                }
                else
                {
                    for (int i = From; i >= To; i--)
                    {
                        indexes.Add(new DecBasedInteger(i));
                    }
                }
            }

            ResolvedDiscreteRange res = new ResolvedDiscreteRange(From, To, indexes);

            FormedIntegerRanges.Add(new int [] { From, To }, res);
            return(res);
        }
Пример #4
0
 static ResolvedDiscreteRange()
 {
     range1 = FormIntegerIndexes(0, 0);
 }