-
Notifications
You must be signed in to change notification settings - Fork 11
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
Added PrefetchIterator #214
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a minor concern about naming the prefetch
method. Otherwise 👍 and we can merge this then.
* | ||
* @return Next value (or null on the end) | ||
*/ | ||
public T prefetch() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can be name this peek
? That is compliant with naming conventions of other methods performing this task.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm in doubt about peek()
.
It has different meaning in java 8 stream API and maybe someone would like to add PeekingStream
later doing the same thing on stream.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd say, that the naming of Stream#peek
seems unfortunate, but OK. Can we come up with some other naming that would be clear to users? I have a strong feeling that the current naming is not self-explanatory.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, more names:
LookupIterator::lookup()
PeekingIterator::peek()
PeepIterator::peep()
SurveyIterator::survey()
InspectIterator::inspect()
- ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I still vote for peek
, but maybe others might have some opinion on this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd also say that peek
is most self explanatory method and people are used to it. Stream::peak
method seems really unfortunate. I've just found out that Peeking iterator is already part of apache commons https://commons.apache.org/proper/commons-collections/apidocs/org/apache/commons/collections4/iterators/PeekingIterator.html and guava https://google.github.io/guava/releases/19.0/api/docs/com/google/common/collect/PeekingIterator.html
Shouldn't we use the one that guava provides?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Useful for construct like: