Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add iter_at_key & iter_at_key_mut #16

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Jupeyy
Copy link

@Jupeyy Jupeyy commented Jun 27, 2023

This implements an iterator that was starts at a specific key entry, which allows to iterate starting from this entry, instead of starting at the beginning.

My motivation for this is to be able to easily notify all entries in a queue that an entry was dropped. I use this crate to be able to quickly drop entries at any position. So basically like a queue with instant remove.
Additionally I want to be able to ping entries "after" the dropped entry. All entries "before" the dropped entry are not of interest.

I am not sure if you are generally open for such a change, I currently only implemented this iterator for the linked hash map

@kyren
Copy link
Owner

kyren commented Jun 27, 2023

Yeah, having this API makes sense to me, so this would be a good addition.

I haven't reviewed the PR super thoroughly yet, but I don't see at a glance why IterAtKey and IterMutAtKey need to contain an inner iter field? They only seem to use the Iter::tail field?

Also there seems to be a lot of infrastructure added via RawEntryBuilder for methods that aren't public and only end up being used in one place, I'm not sure all of that is necessary?

Also I think I'd prefer IterAtKeyMut rather than IterMutAtKey to follow pattern, like RawEntryBuilderMut.

@Jupeyy
Copy link
Author

Jupeyy commented Jun 27, 2023

I haven't reviewed the PR super thoroughly yet, but I don't see at a glance why IterAtKey and IterMutAtKey need to contain an inner iter field? They only seem to use the Iter::tail field?

Yeah this is rather a prototype, I can clean it up, and also add it for the linked hash set, if you want to.

Also there seems to be a lot of infrastructure added via RawEntryBuilder for methods that aren't public and only end up being used in one place, I'm not sure all of that is necessary?

As far as i have seen, the biggest problem was that i don't have access to the Nodes in the non mutable version, it only gives me the key-value pair. I guess i can simply implement that functionality directly inside the iter_at_key function using the map directly (since the code looked similary to what i wanted i implemented it there^^)

Also I think I'd prefer IterAtKeyMut rather than IterMutAtKey to follow pattern, like RawEntryBuilderMut.

alright

@Jupeyy Jupeyy force-pushed the pr-skipped-it branch 2 times, most recently from 9190c6e to 123d519 Compare June 27, 2023 20:45
An iterator that was starts at a specific key entry,
which allows to iterate starting from this entry, instead of starting at
the beginning
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