Another post on extending LINQ. Anything you feel LINQ is missing?
LINQ Extensions 2: Minimum/Maximum by key – GameDev<T>
6 plus ones
Shared publicly•View activity
- I think Linq needs a Batch extension method to batch processing in blocks. I've written one on the following gist
https://gist.github.com/odytrice/e26370479b470d34b153Sep 17, 2015
- Interesting! Do you have a use case for the method?
Do you mind if I mention this in one of my upcoming posts?
Your current implementation is not the most efficient (O(n^2), while O(n) is possible). I might take a stab at optimizing it as well. :)Sep 18, 2015
- Not at all, You can go ahead and post it. That would be nice actually. I'd also like to see an optimized version of it especially for the IEnumerable<T>
I had two use cases where I used it:
1. I wanted to do a lot of computation a query that produced a very large result set and for performance, I wanted to break the processing into chunks such that I'd query each for chunk kinda like paging with Skip and Take mechanism
2. I wanted to display some records in a given number of columns on a web page. so It was easier to just batch them into the number of columns, the first iteration would return a batch and I'd generate the <tr> and then iterated through the batch to create the <td> something like thatSep 18, 2015
- Great! I'll make this the topic of my post for next Wednesday. :)Sep 19, 2015
- Sep 23, 2015
- Absolutely Brilliant! I was stumped several times on how I would be able to determine the number of batches so that I would know when to stop skipping. It never occurred to me that simply using the iterators directly would do the job.
That said, I prefer the totally deferred solution simply because IEnumerables could potentially be very expensive to iterate. I will probably implement the eager implementation on IList<T> instead.
Its a Great Post. Already shared it with my co-workers. :DSep 23, 2015
Add a comment...