网上演练
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

82 lines
2.3 KiB

#if FAT
using System;
using System.Collections.Generic;
namespace LinqInternal.Collections
{
internal static partial class Extensions
{
public static void InsertRange<T, TCollection>(this TCollection source, int index, T item)
where TCollection : class, IList<T>
{
if (source == null)
{
throw new ArgumentNullException("source");
}
source.Insert(index, item);
}
public static void InsertRange<T, TCollection>(this TCollection source, int index, Func<T> item)
where TCollection : class, IList<T>
{
if (source == null)
{
throw new ArgumentNullException("source");
}
if (item == null)
{
throw new ArgumentNullException("item");
}
source.Insert(index, item());
}
public static int InsertRange<T, TCollection>(this TCollection source, int index, IEnumerable<T> items)
where TCollection : class, IList<T>
{
if (source == null)
{
throw new ArgumentNullException("source");
}
if (items == null)
{
throw new ArgumentNullException("items");
}
var initialIndex = index;
foreach (var item in items)
{
source.Insert(initialIndex, item);
checked
{
index++;
}
}
return index - initialIndex;
}
public static int InsertRange<T, TCollection>(this TCollection source, int index, IEnumerable<Func<T>> items)
where TCollection : class, IList<T>
{
if (source == null)
{
throw new ArgumentNullException("source");
}
if (items == null)
{
throw new ArgumentNullException("items");
}
var initialIndex = index;
foreach (var item in items)
{
source.Insert(initialIndex, item());
checked
{
index++;
}
}
return index - initialIndex;
}
}
}
#endif