mirror of
https://github.com/ICDSystems/ICD.Common.Utils.git
synced 2026-02-16 13:15:07 +00:00
feat: Shims for adding a sequence of items to a sorted list
This commit is contained in:
@@ -10,6 +10,46 @@ namespace ICD.Common.Utils.Extensions
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public static class ListExtensions
|
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>
|
/// <summary>
|
||||||
/// Adds the item into a sorted list.
|
/// Adds the item into a sorted list.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
Reference in New Issue
Block a user