Add missing AddRange overloads for dictionary and sorted list
This commit is contained in:
1 parent
40074ce368
commit
976c5eb78b
2 files changed
+35
-7
No files matched your search
@@ -577,10 +577,24 @@ namespace Recyclable.Collections
|
||||
{
|
||||
AddRange(list, sourceQueue);
|
||||
}
|
||||
else if (typeof(T).IsGenericType && typeof(T).GetGenericTypeDefinition() == typeof(KeyValuePair<,>)
|
||||
&& items.GetType().IsGenericType && items.GetType().GetGenericTypeDefinition() == typeof(RecyclableDictionary<,>))
|
||||
{
|
||||
dynamic dynList = list;
|
||||
dynamic dynDict = items;
|
||||
AddRange(dynList, dynDict);
|
||||
}
|
||||
else if (typeof(T).IsGenericType && typeof(T).GetGenericTypeDefinition() == typeof(ValueTuple<,>)
|
||||
&& items.GetType().IsGenericType && items.GetType().GetGenericTypeDefinition() == typeof(RecyclableSortedList<,>))
|
||||
{
|
||||
dynamic dynList = list;
|
||||
dynamic dynSortedList = items;
|
||||
AddRange(dynList, dynSortedList);
|
||||
}
|
||||
else if (items is IReadOnlyList<T> sourceIReadOnlyList)
|
||||
{
|
||||
AddRange(list, sourceIReadOnlyList);
|
||||
}
|
||||
{
|
||||
AddRange(list, sourceIReadOnlyList);
|
||||
}
|
||||
else if (items.TryGetNonEnumeratedCount(out var requiredAdditionalCapacity) && requiredAdditionalCapacity != 0)
|
||||
{
|
||||
AddRangeWithKnownCount(list, items, list._count, requiredAdditionalCapacity);
|
||||
|
||||
@@ -438,10 +438,24 @@ namespace Recyclable.Collections
|
||||
targetList.AddRange(sourceQueue);
|
||||
return;
|
||||
|
||||
default:
|
||||
if (items.TryGetNonEnumeratedCount(out var requiredAdditionalCapacity))
|
||||
{
|
||||
targetList.AddRangeWithKnownCount(items, requiredAdditionalCapacity);
|
||||
case var _ when typeof(T).IsGenericType && typeof(T).GetGenericTypeDefinition() == typeof(KeyValuePair<,>)
|
||||
&& items.GetType().IsGenericType && items.GetType().GetGenericTypeDefinition() == typeof(RecyclableDictionary<,>):
|
||||
dynamic dynTargetList = targetList;
|
||||
dynamic dynDict = items;
|
||||
AddRange(dynTargetList, dynDict);
|
||||
return;
|
||||
|
||||
case var _ when typeof(T).IsGenericType && typeof(T).GetGenericTypeDefinition() == typeof(ValueTuple<,>)
|
||||
&& items.GetType().IsGenericType && items.GetType().GetGenericTypeDefinition() == typeof(RecyclableSortedList<,>):
|
||||
dynamic dynTargetList2 = targetList;
|
||||
dynamic dynSortedList = items;
|
||||
AddRange(dynTargetList2, dynSortedList);
|
||||
return;
|
||||
|
||||
default:
|
||||
if (items.TryGetNonEnumeratedCount(out var requiredAdditionalCapacity))
|
||||
{
|
||||
targetList.AddRangeWithKnownCount(items, requiredAdditionalCapacity);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user