-
Notifications
You must be signed in to change notification settings - Fork 607
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement countByEach on RichIterable. #476
Comments
Should the implementation be lazy? |
Yes similar to countByEach(): |
the test case for this is failing with the error No iteration patterns should delegate to iterator().
My test case is here: https://github.com/TheLoneKing/eclipse-collections/blob/0dd3ca235272c9f9dc023ab9f90afee69c892b69/unit-tests-java8/src/test/java/org/eclipse/collections/test/RichIterableTestCase.java#L1626 Can someone please help me with the cause of this error? |
@TheLoneKing you are missing overrides for the Eclipse Collections Maps and Sets are backed by flattened arrays so iterating over them using an iterator() is inefficient. |
Signed-off-by: TheLoneKing <dkumar.kovai@gmail.com>
Signed-off-by: TheLoneKing <dkumar.kovai@gmail.com>
Signed-off-by: TheLoneKing <dkumar.kovai@gmail.com>
Signed-off-by: TheLoneKing <dkumar.kovai@gmail.com>
Signed-off-by: TheLoneKing <dkumar.kovai@gmail.com>
Working on this at UIUC HackNight. |
I'll help you work on this @joshuacheng |
me too @joshuacheng @joshuakim0724 |
Implement countByEach on RichIterable. Resolves #476
Signed-off-by: TheLoneKing <dkumar.kovai@gmail.com>
This can be implemented as a default method on RichIterable as countBy was. It will need appropriate co-variant overrides as default methods and optimizations for Bag implementations.
The signature of countByEach should be:
default <V> Bag<V> countByEach(Function<? super T, ? extends Iterable<V>> function)
The naming is based on the pattern we used for groupBy/groupByEach.
This code in the Pet Kata can then be improved.
Before:
After:
http://eclipse.github.io/eclipse-collections-kata/pet-kata/#/6/2
The text was updated successfully, but these errors were encountered: