Skip to content

Instantly share code, notes, and snippets.

@atheken
Created January 8, 2011 19:31
Show Gist options
  • Save atheken/771082 to your computer and use it in GitHub Desktop.
Save atheken/771082 to your computer and use it in GitHub Desktop.
ChunkIt
public class ChunkUtils
{
public static IEnumerable<T> Chunk(Func<int,IEnumerable<T>> chunkFunc){
var taken = 0;
var last = 0;
do{
last = taken;
var values = chunkFunc(taken);//taken is the "skip" count, the "take" count will have been closed into the chunkFunc.
foreach(var v in values)
{
taken++;
yield return v;
}
}while(taken == last);
yield break;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment