Iterator method that remembers it's content's positions from the original data structure

Critique is welcome!

I have an iterator of elements from a vector, But I need to remember the elements position from the original vector. I don't want to store the element's original position in a tuple with the element, Because that could bloat the iterators size.

I checked out the Standard Library Iterator Page, But I couldn't find what I needed.

Is this by chance what you are looking for?

enumerate()

2 Likes

I tested it in the playground, But it doesn't seem work properly :frowning:

Obviously, you need to enumerate before you filter.

enumerate first, then filter.

Oh man, that was stupid of me. Thanks!

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.