28 lines
698 B
C#
28 lines
698 B
C#
namespace Quadtree
|
|
{
|
|
internal static class ListExtensions
|
|
{
|
|
public static bool RemoveUnordered<T>(this List<T> list, T obj)
|
|
{
|
|
if (obj != null)
|
|
{
|
|
for (int i = 0; i < list.Count; i++)
|
|
{
|
|
if (obj.Equals(list[i]))
|
|
{
|
|
list.RemoveUnorderedAt(i);
|
|
return true;
|
|
}
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
|
|
public static void RemoveUnorderedAt<T>(this List<T> list, int index)
|
|
{
|
|
list[index] = list[^1];
|
|
list.RemoveAt(list.Count - 1);
|
|
}
|
|
}
|
|
}
|