public static IEnumerable <SlidingWindow <T> > Slide <T>(IEnumerable <T> enumerable, int capacity) { var window = new SlidingWindow <T>(capacity); foreach (var item in enumerable) { window.Fill(item); if (window.IsFilled) { yield return(window); } } }
/// <summary> /// Determines whether the specified objects are equal to each other. /// </summary> /// <typeparam name="T"></typeparam> /// <param name="objs"></param> /// <returns></returns> public static bool CrossEquals <T>(params T[] objs) { if (objs.Length < 2) { return(true); } foreach (var window in SlidingWindow.Slide(objs, 2)) { if (!window[0].Equals(window[1])) { return(false); } } return(true); }