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))); }
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))); }
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); }
public OclReal op_Division(OclInteger i) { if (IsNull(i)) { throw new ArgumentNullException(); } return(OclReal.valueOf(checked (toDouble() / i.toDouble()))); }
public OclInteger op_Multiply(OclInteger i) { if (IsNull(i)) { throw new ArgumentNullException(); } return(ValueOf(checked (ToInt() * i.ToInt()))); }
public OclInteger op_Subtraction(OclInteger i) { if (IsNull(i)) { throw new ArgumentNullException(); } return(ValueOf(checked (ToInt() - i.ToInt()))); }
public OclInteger min(OclInteger i) { if (IsNull(i)) { throw new ArgumentNullException(); } return(ValueOf(Math.Min(ToInt(), i.ToInt()))); }
public T at <T>(OclInteger i) where T : OclAny { if (IsNull(i)) { throw new ArgumentNullException(); } return((T)list[(int)i - 1]); }
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); }
public OclString at(OclInteger pos) { if (IsNull(pos)) { throw new ArgumentNullException(); } return(substring(pos, pos)); }
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))); }
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); }
/// <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; }
public OclInteger toInteger() { return(OclInteger.ValueOf(ToInt())); }
public OclInteger toInteger() { return(OclInteger.Parse(value)); }
public OclInteger floor() { return(OclInteger.ValueOf(checked ((int)Math.Floor(toDouble())))); }