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

Start working on a HashMap implementation using hashbrown::raw #627

Merged
merged 10 commits into from
Aug 26, 2023

Conversation

udoprog
Copy link
Collaborator

@udoprog udoprog commented Aug 23, 2023

This avoids pre-checking Value by converting them into Key and (eventually) cloning the entire contents of a map when iterating over it.

This can only be merged once rust-lang/hashbrown#456 resolves and is released or an alternative solution is found.

This allows for any type which implements HASH and EQ to be used in a map. Including floats assuming they only normal or subnormal values that can be rectified:

use std::collections::HashMap;

pub fn main() {
    let map = HashMap::new();
    map.insert(1.0, 2.0);
    map.insert(0.0, 3.0);
    dbg!(map);
    dbg!(map[1.0]);
    dbg!(map.get(-0.0));
    dbg!(map[0.0]);
}
{1.0: 2.0, 0.0: 3.0}
2.0
Some(3.0)
3.0

@udoprog udoprog added the enhancement New feature or request label Aug 23, 2023
@udoprog udoprog marked this pull request as draft August 23, 2023 15:13
@udoprog udoprog force-pushed the hashbrown-raw branch 3 times, most recently from cc81a5e to 066fb6e Compare August 23, 2023 20:50
@udoprog udoprog force-pushed the hashbrown-raw branch 2 times, most recently from 6dd54c5 to 1204dd4 Compare August 24, 2023 03:51
@udoprog udoprog marked this pull request as ready for review August 25, 2023 17:04
@udoprog udoprog force-pushed the hashbrown-raw branch 3 times, most recently from f7cd7e1 to 8e2f4e8 Compare August 25, 2023 17:31
@udoprog udoprog force-pushed the hashbrown-raw branch 3 times, most recently from 2d05353 to d782a3f Compare August 26, 2023 00:05
@udoprog udoprog merged commit aac1bdf into main Aug 26, 2023
@udoprog udoprog deleted the hashbrown-raw branch August 26, 2023 01:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant