|
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System.Collections.Generic;
namespace Microsoft.ML.Tokenizers
{
internal static class IListExtensions
{
public static void AddRange<T>(this IList<T> list, IEnumerable<T> items)
{
if (list is List<T> concreteList)
{
concreteList.AddRange(items);
}
else if (items is IList<T> listToAdd)
{
int count = listToAdd.Count;
for (int i = 0; i < count; i++)
{
list.Add(listToAdd[i]);
}
}
else
{
foreach (var item in items)
{
list.Add(item);
}
}
}
}
}
|