using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace First_week { internal static class CollectionUtils { public static bool IsNullOrEmpty(this IEnumerable collection) { return collection == null || !collection.Any(); } public static List ToSafeList(this IEnumerable collection) { return collection?.ToList() ?? new List(); } public static void Shuffle(this IList list) { if (list == null) return; Random rng = new Random(); int n = list.Count; while (n > 1) { n--; int k = rng.Next(n + 1); T value = list[k]; list[k] = list[n]; list[n] = value; } } } }