SanAndreasUnity/Assets/Scripts/Utilities/CollectionExtensions.cs

27 lines
659 B
C#
Raw Normal View History

2022-01-24 13:21:17 +00:00
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;
}
2022-01-24 17:07:00 +00:00
public static Queue<T> ToQueue<T>(this IEnumerable<T> enumerable)
{
return new Queue<T>(enumerable);
}
2022-01-24 13:21:17 +00:00
}
}