Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static IEnumerable<T> TrimOrExpand<T>(this T[] items, int desiredCount)
- {
- var ratio = (double)items.Length / desiredCount;
- for (int i = 0; i < desiredCount; i++)
- yield return items[Convert.ToInt32(i * ratio)];
- }
- public static IEnumerable<T> NormalizeObjects<T>(this T[] items, int desiredCount)
- public static IEnumerable<T> ExpandOrContract<T>(this T[] items, int desiredCount)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement