Skip to content

AbstractSequentialIterator.of(T, UnaryOperator<T>) #3214

Open

Description

AbstractSequentialIterator is very rarely used, but we could still consider this helper, which might encourage more people to use it by permitting lambda expressions:

return new AbstractSequentialIterator<C>(first()) {
final C last = last();
@Override
protected C computeNext(C previous) {
return equalsOrThrow(previous, last) ? null : domain.next(previous);
}
};

...becomes...

C last = last();
return AbstractSequentialIterator.of(
    first(),
    previous -> equalsOrThrow(previous, last) ? null : domain.next(previous));

But I guess I'm not really that excited about that particular example. And I'm not sure what the best method name would be.

This is similar to #2785, where I apparently excluded all Abstract* classes, and #2853.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions