Example #1
0
        public OclOrderedSet subOrderedSet(OclInteger first, OclInteger last)
        {
            int firstI = (int)first;
            int lastI  = (int)last;

            return(new OclOrderedSet(elementType, list.Skip(firstI - 1).Take(lastI - firstI + 1)));
        }
Example #2
0
        public OclString substring(OclInteger from, OclInteger to)
        {
            if (IsNull(from))
            {
                throw new ArgumentNullException("from");
            }
            if (IsNull(to))
            {
                throw new ArgumentNullException("to");
            }

            //Convert to 32-bit integers.
            int fromInt = (int)from;
            int toInt   = (int)to;

            //Check valid bounds.
            if (fromInt < 1 || toInt < fromInt || CharOffsetToUnicode(value, value.Length) < fromInt)
            {
                throw new ArgumentOutOfRangeException();
            }

            //Convert to 0-offset and char offset.
            int fromUnicode = UnicodeOffsetToChar(value, fromInt - 1);
            int toUnicode   = UnicodeOffsetToChar(value, toInt);

            return(new OclString(value.Substring(fromUnicode, toUnicode - fromUnicode)));
        }
Example #3
0
        public OclOrderedSet insertAt <T>(OclClassifier newElementType, OclInteger index, T obj) where T : OclAny
        {
            OclOrderedSet o      = new OclOrderedSet(newElementType, list);
            int           indexI = (int)index;

            o.list.Insert(indexI - 1, obj);
            return(o);
        }
Example #4
0
 public OclReal op_Division(OclInteger i)
 {
     if (IsNull(i))
     {
         throw new ArgumentNullException();
     }
     return(OclReal.valueOf(checked (toDouble() / i.toDouble())));
 }
Example #5
0
 public OclInteger op_Multiply(OclInteger i)
 {
     if (IsNull(i))
     {
         throw new ArgumentNullException();
     }
     return(ValueOf(checked (ToInt() * i.ToInt())));
 }
Example #6
0
 public OclInteger op_Subtraction(OclInteger i)
 {
     if (IsNull(i))
     {
         throw new ArgumentNullException();
     }
     return(ValueOf(checked (ToInt() - i.ToInt())));
 }
Example #7
0
 public OclInteger min(OclInteger i)
 {
     if (IsNull(i))
     {
         throw new ArgumentNullException();
     }
     return(ValueOf(Math.Min(ToInt(), i.ToInt())));
 }
Example #8
0
 public T at <T>(OclInteger i) where T : OclAny
 {
     if (IsNull(i))
     {
         throw new ArgumentNullException();
     }
     return((T)list[(int)i - 1]);
 }
Example #9
0
        public OclSequence insertAt <T>(OclClassifier newElementType, OclInteger index, T item) where T : OclAny
        {
            OclSequence newList  = new OclSequence(newElementType, list);
            int         intIndex = (int)index;

            newList.list.Insert(intIndex - 1, item);
            return(newList);
        }
Example #10
0
 public OclString at(OclInteger pos)
 {
     if (IsNull(pos))
     {
         throw new ArgumentNullException();
     }
     return(substring(pos, pos));
 }
Example #11
0
        public OclInteger round()
        {
            double v    = toDouble();
            double vabs = Math.Abs(v);
            double d    = vabs - Math.Truncate(vabs);

            if (d == 0.5)
            {
                v = Math.Ceiling(v);
            }
            else
            {
                v = Math.Round(v);
            }
            return(OclInteger.ValueOf(checked ((int)v)));
        }
Example #12
0
        public OclSequence subSequence(OclInteger start, OclInteger end)
        {
            int intStart = (int)start, intEnd = (int)end;

            if (intEnd < intStart || intStart < 1 || intEnd > list.Count)
            {
                throw new IndexOutOfRangeException();
            }

            OclSequence newList = new OclSequence(elementType);

            for (int i = intStart - 1; i < intEnd; ++i)
            {
                newList.list.Add(list[i]);
            }
            return(newList);
        }
Example #13
0
        /// <summary>
        /// Create an instance of Real holding a specified value.
        /// </summary>
        /// <param name="value">The value. Should be finite</param>
        /// <returns>OclReal wrapping the value.</returns>
        internal static OclReal valueOf(double?valueOrNull)
        {
            if (valueOrNull == null)
            {
                return(null);
            }
            double value = (double)valueOrNull;

            if (Math.Truncate(value) == value && value >= int.MinValue && value <= int.MaxValue)
            {
                return(OclInteger.ValueOf((int)value));
            }
            else
            {
                return(new OclProperReal(value));
            }
        }
 public OclCollectionLiteralPartRange(OclInteger from, OclInteger to)
 {
     this.from = from;
     this.to   = to;
 }
Example #15
0
 public OclInteger toInteger()
 {
     return(OclInteger.ValueOf(ToInt()));
 }
Example #16
0
 public OclInteger toInteger()
 {
     return(OclInteger.Parse(value));
 }
Example #17
0
 public OclInteger floor()
 {
     return(OclInteger.ValueOf(checked ((int)Math.Floor(toDouble()))));
 }