Skip to content

Conversation

@adamnovak
Copy link
Member

This adds a fairly full-featured, read-only iterator to the various packed/paged vector types.

The iterator implementation just carries a pointer to the container and an index within it. It is not meant to be able to be stored in a memory mapping; that might need a lot more templating.

It supports the less-than/greater-than comparisons that we want for the hub labeling distance index integration, on top of being a random access iterator.

So far it has tests for forward iterator functions, but not for the bidirectional iterator, random access iterator, or comparison logic.

Much of this code was generated by Anthropic Claude, which wrote 4 times as many iterators and 4 times as many tests as were really necessary, since all the test and iterator code was really the same. When I asked it to try and consolidate, it attempted SFINAE and went on strike for increased subscription fees.

Then I spent a couple hours removing the duplicated code myself, and implementing the more powerful iterator categories. To avoid the SFINAE nonsense, I made the vectors and the deques both use STL-style push_back()/pop_back() instead of append() or append_back() and pop() or pop_back(). I have deprecated stubs under the old names to call the new ones, so we don't have to immediately run around fixing vg.

I haven't regenerated the Python bindings, but the old ones still build. We might want to exclude the iterators from being bound to avoid a profusion of types on the Python side that aren't really needed.

This also comes with the hints I gave to Anthropic Claude to teach it the project, although since it proceeded to generate 4 times as much code as it should have, they might not be very good.

@adamnovak adamnovak merged commit d9725de into master Nov 20, 2025
1 check passed
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