-
Notifications
You must be signed in to change notification settings - Fork 60
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
Investigate augmenting RawTable
directly
#30
Comments
As in you want upstream to expose RawTable? |
More like having |
What I want to do here is define struct RawTable<K, V, A = ()> {
capacity: usize,
size: usize,
hashes: Unique<u64>, // dynamic allocation of `cap` `u64`s | `cap` `K`s | `cap` `V`s | `cap` `A`s
aug: A, // used to store the head/tail indices for the linked version
marker: marker::PhantomData<(K, V)>,
} and then struct Link {
next: usize,
prev: usize,
}
pub struct LinkedHashMap<K, V> {
table: RawTable<K, V, Link>,
...
} This will let us remove the extra key/value indirection in the current impl along with the dummy node, though the performance implications remain to be determined. |
Forking std's impl seems more viable, honestly. |
I think we should look into this, even if it involves maintaining an internal copy of CC @carllerche. |
To follow up, I extracted the hash table as a standalone library that runs on stable Rust. https://github.com/carllerche/hash-table |
This crate wraps
HashMap
to provide ordered iteration with very little additional code, but its approach is essentially a hack and requires additional heap allocation in order to work. We should consider augmentingRawTable
with a type parameter in order to implement this more efficiently. NormalHashMap
s would use()
internally for this parameter, whileLinkedHashMap
would use astruct Link { next: usize, prev: usize }
.CC @gankro.
The text was updated successfully, but these errors were encountered: