-
Notifications
You must be signed in to change notification settings - Fork 10
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
Adding stream operators to list flyweight #16
Comments
I couldn't find a way to return a stream without creating a backing of the individual instances. I tried the following ways of generating the stream
Perhaps we could add the Stream methods directly to the flyweight (like rename the flyweight StreamFlyweight). Otherwise we could look at stream support |
What about adding: public boolean anyMatch(Predicate<T> filter) {
for (int offset = offset(); offset < maxLimit(); offset = itemRO.limit()) {
itemRO.wrap(buffer(), offset, maxLimit());
if (filter.test(itemRO)) {
return true;
}
}
return false;
} |
Added anyMatch here: #22. This or related functionality is very useful as doing it in downstream code via forEach requires effectively final variable to be set (aka, need a reference to containing object field). |
anyMatch would be good addition as I am running into the same. For e.g: I want to check if there is any error in one of the items in the list. I am doing this now:
Stream has the same method, but signature is slightly different.
can you update the signature in the PR ? |
The PR currently generates
Are you saying it should be or I’m not sure which is correct but |
I think it should be |
Ok, I'll change both on the PR. Also, I would like to remove the quotes on the toString as I just spent quite some time debugging an issue where I did |
I hit the above today and needed the <? super T> for the forEach :-). PR is updated |
Reopening, I would still like this or something equivalent. Because stream().filter() requires intermediate objects (I believe), perhaps we could implement:
|
Need streaming operators on list flyweight to filter and reduce. For e.g: To filter an item, one could use the following:
Otherwise, forEach() needs to be used and store the item in a temporary holder and it is not convenient.
The text was updated successfully, but these errors were encountered: