Skip to content
This repository has been archived by the owner on Jul 10, 2024. It is now read-only.

Commit

Permalink
fpga insert order
Browse files Browse the repository at this point in the history
  • Loading branch information
HendrikMennen committed Mar 7, 2024
1 parent 0f5a3cd commit 27ebe7c
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/OneWare.Essentials/Extensions/ListExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,20 @@ public static int BinarySearchNext<TItem, TSearch>(this IList<TItem> list, TSear

return ~lower;
}

public static void InsertSorted<TItem>(this IList<TItem> list, TItem newItem, Func<TItem, TItem, int> comparer)
{
for (var i = 0; i < list.Count; i++)
{
var comparision = comparer(newItem, list[i]);

if (comparision <= 0)
{
list.Insert(i, newItem);
return;
}
}

list.Add(newItem);
}
}

0 comments on commit 27ebe7c

Please sign in to comment.