-
Notifications
You must be signed in to change notification settings - Fork 2
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
Incrementing Subsequences #88
Comments
Hi! These two ( Not sure how happy I am with the names "nonIncrementing/nonDecrementing" even if they do describe what's happening. I'll take a walk and think about the name. Thanks again @nipafx! |
Hey @nipafx - I put in a PR which is my take on this. I did have one question about your example: Stream.of(1, 3, 5, 6, 2, 4)
.gather(incrementing()) // Stream<List<Integer>>
.forEach(System.out::println); // [1, 3, 5] [6] [2, 4] I think the result should be |
Oh, yes. 🙈 I wanted to show that a group may consist of just one element, but got the numbers wrong. |
…reasing/NonIncreasing/NonDecreasing (#93) + Group elements to Lists so long as they are increasing, decreasing, non-increasing, or non-decreasing + Ensure that streams are increasing, decreasing, non-increasing, or non-decreasing and fail otherwise + Filter streams to be increasing, decreasing, non-increasing, or non-decreasing + Group, Filter, and Ensure functions can operate on a stream of `Comparable` objects or caller can specify a `Comparator`
Merged something I'm happy with. I realize this is not fully documented in README, but I have plans to fully document each operation in an adoc-powered website so I'll save the work for that. :) |
I found one more operation in my notes, but I've only implemented that for fun and haven't used it in practice, so not sure how much sense it makes: It's about creating groups of variable length, where within each group the elements are in increasing order according to their natural order or a given comparator. E.g.:
Thanks to generics, it should be possible to make
incrementing()
(or whatever it ends up being called) non-applicable to a stream whose elements don't extendComparable
. The alternativeincrementing(Comparator)
would of course apply to all streams.The symmetrical
decrementing
variant should probably be added together with this one.The text was updated successfully, but these errors were encountered: