feat: Shims for adding a sequence of items to a sorted list

This commit is contained in:
Chris Cameron
2018-04-13 14:03:13 -04:00
parent 8f2c2ba091
commit 0859e7433f

View File

@@ -10,6 +10,46 @@ namespace ICD.Common.Utils.Extensions
/// </summary>
public static class ListExtensions
{
/// <summary>
/// Adds the items into a sorted list.
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="extends"></param>
/// <param name="items"></param>
[PublicAPI]
public static void AddSorted<T>(this List<T> extends, IEnumerable<T> items)
{
if (extends == null)
throw new ArgumentNullException("extends");
if (items == null)
throw new ArgumentNullException("items");
extends.AddSorted(items, Comparer<T>.Default);
}
/// <summary>
/// Adds the item into a sorted list.
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="extends"></param>
/// <param name="items"></param>
/// <param name="comparer"></param>
[PublicAPI]
public static void AddSorted<T>(this List<T> extends, IEnumerable<T> items, IComparer<T> comparer)
{
if (extends == null)
throw new ArgumentNullException("extends");
if (items == null)
throw new ArgumentNullException("items");
if (comparer == null)
throw new ArgumentNullException("comparer");
items.ForEach(i => extends.AddSorted(i, comparer));
}
/// <summary>
/// Adds the item into a sorted list.
/// </summary>