SanAndreasUnity/Assets/Scripts/Utilities/CollectionExtensions.cs
2022-01-24 18:07:00 +01:00

26 lines
659 B
C#

using System.Collections.Generic;
namespace SanAndreasUnity.Utilities
{
public static class CollectionExtensions
{
public static T RemoveLast<T>(this IList<T> list)
{
T lastElement = list[list.Count - 1];
list.RemoveAt(list.Count - 1);
return lastElement;
}
public static T RemoveFirst<T>(this IList<T> list)
{
T firstElement = list[0];
list.RemoveAt(0);
return firstElement;
}
public static Queue<T> ToQueue<T>(this IEnumerable<T> enumerable)
{
return new Queue<T>(enumerable);
}
}
}