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

implement counter with ahash #48

Closed
wants to merge 4 commits into from

Conversation

chris-ha458
Copy link
Contributor

I'm pretty sure this isnt the way you'd like it, but it does work.

If it is a feature that you might be looking for maybe we could adjust from here.

@coriolinus
Copy link
Owner

Agree that I don't really want to take this approach; using feature flags for this is convenient but very restrictive.

The approach more aligned to my style would be to add another generic parameter, with a default. So instead of being Counter<T, N = usize>, it would be a Counter<T, N = usize, B = HashMap<T, N>>.

To do that we'd need to design an appropriate trait (keeping in mind the map trait limitations!). We bypass many of those limitations because we don't want a fully generic map trait; the fundamental primitive operation we want is get_mut.

We could not implement this for BTreeMap because that would involve adding a bound T: Ord, which I would prefer not to do for backwards-compatibility reasons.

The benefit of all this work in this approach is that changing the backend becomes a user problem: they just need to implement the appropriate trait for the backing map of their choice, and then plug it in: type ACounter<T> = Counter<T, usize, ahash::HashMap<T, N>>;.

@coriolinus
Copy link
Owner

Looks like work has stopped here; I'm going to close this to tidy up the repo. If implementation resumes, feel free to reopen.

@coriolinus coriolinus closed this Dec 3, 2023
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