Advertisement
Guest User

Untitled

a guest
Jul 2nd, 2015
215
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.40 KB | None | 0 0
  1. public static IEnumerable<T> TrimOrExpand<T>(this T[] items, int desiredCount)
  2. {
  3. var ratio = (double)items.Length / desiredCount;
  4. for (int i = 0; i < desiredCount; i++)
  5. yield return items[Convert.ToInt32(i * ratio)];
  6. }
  7.  
  8. public static IEnumerable<T> NormalizeObjects<T>(this T[] items, int desiredCount)
  9.  
  10. public static IEnumerable<T> ExpandOrContract<T>(this T[] items, int desiredCount)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement