Skip to content

Feature request: Implement DoubleEndedIterator for MergeBy if the source iterators implement DoubleEndedIterator #749

@frankdavid

Description

@frankdavid

The current implementation of next() makes use of Peekable. Both iterators get peeked and a comparator is used to decide which element is picked / which iterator gets advanced.

The main difficulty when implementing next_back() for DoubleEndedIterator would be that Peekable only allows peeking the front and not the back. The MergeBy struct would either manually have to store the front and back peeked values or use a data structure like DoubleEndedPeekable.

If we could peek the back, the rest of the implementation would be straightforward, only the comparator's return value would need to be negated when iterating from the back.

Metadata

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