using Exsersewo.Common.Extensions;

namespace Kynareth.Extensions;

public static class CollectionExtensions
{
	public static ICollection<T> GetRandomAmount<T>(this ICollection<T> stack, int amount)
	{
		T[] entries = new T[amount];

		for (int x = 0; x < amount; x++)
		{
			entries[x] = stack.CryptoRandom();
		}
		
		return entries;
	}
	
	public static ICollection<T> GetRandomAmount<T>(this IEnumerable<T> stack, int amount)
	{
		T[] entries = new T[amount];

		for (int x = 0; x < amount; x++)
		{
			entries[x] = stack.CryptoRandom();
		}
		
		return entries;
	}
	
	public static IList<int> Range(int start, int stop, int step)
	{
		var list = new List<int>();
		
		for (int i = start; i < stop; i += step) {
			list.Add(i);
		}

		return list;
	}

	public static T[] Except<T>(this T[] array, T specificValue) where T : IComparable
	{
		return array.Where<T>(val => val.CompareTo(specificValue) != 0).ToArray();
	}
}