Ejemplo n.º 1
0
 public static void CopyTo <T>(Array array, int index, int count, IEnumerable collection)
 {
     CopyToCheck(array, index, count);
     T[] array2 = array as T[];
     if (collection is ICollection <T> c2 && array2 != null)
     {
         c2.CopyTo(array2, index);
     }
     else
     {
         object[] objs = array as object[];
         if (objs == null)
         {
             Thrower.ArgumentException(ArgumentType.array, Resources.Argument_InvalidArrayType);
         }
         try
         {
             var enumerator = collection.GetEnumerator();
             while (enumerator.MoveNext() && index < count)
             {
                 objs[index++] = enumerator.Current;
             }
         }
         catch (ArrayTypeMismatchException)
         {
             Thrower.ArgumentException(ArgumentType.array, Resources.Argument_InvalidArrayType);
         }
     }
 }
 /// <summary>
 /// Return a view of a sublist in a <see cref="T:Academy.Collections.Generic.SortedLinkedList`1"/>.
 /// </summary>
 /// <param name="lowerValue">The lowest desired value in the view.</param>
 /// <param name="upperValue">The highest desired value in the view.</param>
 /// <returns>A sublist view that contains only the values in the specified range.</returns>
 public virtual SortedLinkedList <T> GetViewBetween(T lowerValue, T upperValue)
 {
     if (_comparer.Compare(lowerValue, upperValue) > 0)
     {
         Thrower.ArgumentException(ArgumentType.empty, Resources.Argument_lowerBiggerThanUpper);
     }
     return(new SubListView(this, lowerValue, upperValue));
 }
 /// <summary>
 /// Return a view of a subset in a <see cref="T:Academy.Collections.Generic.ReadOnlySortedSet`1"/>.
 /// </summary>
 /// <param name="lowerValue">The lowest desired value in the view.</param>
 /// <param name="upperValue">The highest desired value in the view.</param>
 /// <returns>A subset view that contains only the values in the specified range.</returns>
 public ReadOnlySortedSet <T> GetViewBetween(T lowerValue, T upperValue)
 {
     if (_comparer.Compare(lowerValue, upperValue) > 0)
     {
         Thrower.ArgumentException(ArgumentType.empty, Resources.Argument_lowerBiggerThanUpper);
     }
     return(GetSubset(lowerValue, upperValue));
 }
Ejemplo n.º 4
0
 public static void CopyToCheck <T>(T[] array, int index, int count)
 {
     if (array == null)
     {
         Thrower.ArgumentNullException(ArgumentType.array);
     }
     if (index < 0 || index > array.Length)
     {
         Thrower.ArgumentOutOfRangeException(ArgumentType.index, string.Format(Resources.ArgumentOutOfRange_Range_G, new object[] { 0, array.Length - 1 }));
     }
     if (array.Length - index < count)
     {
         Thrower.ArgumentException(ArgumentType.index, Resources.Argument_ArrayNotLongEnought);
     }
 }
Ejemplo n.º 5
0
 public static void CopyToCheck(Array array, int index, int count)
 {
     if (array == null)
     {
         Thrower.ArgumentNullException(ArgumentType.array);
     }
     if (array.Rank != 1)
     {
         Thrower.ArgumentException(ArgumentType.array, Resources.Argument_ArrayRank);
     }
     if (array.GetLowerBound(0) != 0)
     {
         Thrower.ArgumentException(ArgumentType.array, Resources.Argument_LowerBoundArrayNotZero);
     }
     if (index < 0 || index > array.Length)
     {
         Thrower.ArgumentOutOfRangeException(ArgumentType.index, string.Format(Resources.ArgumentOutOfRange_Range_G, new object[] { 0, array.Length - 1 }));
     }
     if ((array.Length - index) < count)
     {
         Thrower.ArgumentException(ArgumentType.empty, Resources.Argument_ArrayNotLongEnought);
     }
 }