Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Nov 26, 2025

Implements an iterator over ProgTree that traverses elements following the progressive tree structure defined in EIP-7916.

Implementation

  • ProgTreeIter<'a, T>: Iterator that maintains a single reference to the current progressive node and wraps iter::Iter instances for each binary subtree
  • Traversal order: Visits right children in sequence—root's right child, then right child of each left node down the spine
  • iter(&self, length: usize) -> ProgTreeIter<'_, T>: Public API on ProgTree

Example

let mut tree = ProgTree::<u64>::empty();
for i in 1..=65 {
    tree = tree.push(i, i - 1).unwrap();
}

// Iterate all elements in progressive tree order
for value in tree.iter(65) {
    println!("{}", value);  // Prints 1, 2, 3, ..., 65
}

The iterator handles both packed (u64, u8) and non-packed (Hash256) types. The implementation uses a single reference that follows the left spine sequentially, making it simple and memory-efficient.


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI and others added 2 commits November 26, 2025 06:13
Copilot AI changed the title [WIP] Add iterator for ProgTree to traverse nodes Add iterator over ProgTree elements Nov 26, 2025
Copilot AI requested a review from michaelsproul November 26, 2025 06:22
Copilot AI requested a review from michaelsproul November 26, 2025 07:49
@michaelsproul michaelsproul marked this pull request as ready for review November 27, 2025 04:21
@michaelsproul michaelsproul merged commit fef31df into progressive-list Nov 27, 2025
8 of 10 checks passed
@michaelsproul michaelsproul deleted the copilot/sub-pr-82 branch November 27, 2025 04:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants