Closed flamaniac closed 2 years ago
I regularly implement my own collections against an IList, that would mean I would have to add TrueForAll
even if I don't need it. Have you considered an extension method for your code?
Yes, but not why making this as a part of the framework?
BTW I have thought a little about extension method TrueForAll or any other predicate implementation based on interface (IList) and based on implemented type (List)
For extension method you cannot optimize iteration count. For example for:
IList<T> listInterface;
listInterface.Where(...).Where(...).TrueForAll()
will make 3 iterations... each iteration for each predicate.
For List you can optimize this just by remembering predicate that you need to apply on each item and just apply those 3 predicates in the single loop.
It seems that better is to add this method to IList and add optimized implementation for each class that implements this interface. But yes. I understand that interface change is breaking change for the framework and only possibility is to add another interface (child of IList) or create extension method witch will have not nice computational complexity. Hymm...
I prefer to always use interface IList when passing array collection but TrueForAll method is missing for this interface.