Skip to content

Redesign to Fully‐Lazy Iterators with Double‐Ended Support #92

@adriendellagaspera

Description

@adriendellagaspera

Background
Current iterators perform an initial descent to the leftmost leaf. To match BTreeMap’s “fully lazy” behavior, we need to defer any work until next() is called and support reverse iteration.

Goals

  • Eliminate pre-computation before the first next() call.
  • Support reverse traversal via DoubleEndedIterator.
  • Add lower/upper bound seeking methods.

Tasks

  1. Refactor Iter so that it only builds its traversal stack on the first next() call.
  2. Implement DoubleEndedIterator by maintaining two stacks (one for forward, one for backward).
  3. Add seek_lower_bound(&mut self, key: &K) and seek_upper_bound(&mut self, key: &K) methods.
  4. Write unit tests covering:
    • Forward iteration matches the in-order sequence.
    • Reverse iteration (.rev()) yields keys in descending order.
    • seek_lower_bound(&k) positions at the first key ≥ k, and seek_upper_bound(&k) at the first key > k.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions