Skip to content

HashSet should have a get function #21234

Closed
@mpdn

Description

@mpdn

I think HashSet should have a get function like HashMap has, as equality does not necessarily mean that two elements are identical.

The reason I think this is necessary is that I'm trying to create a voxel world (think Minecraft) that is split into 3D chunks. Many of these chunks are identical (a lot of it is just air, for example), so it would make sense to reuse the a chunk in several places. When a new chunk is generated, the hash of the chunk is looked up in a collection to see if there is an already identical chunk and if there is, then use that one.

If HashSet had a get function then I could use a HashSet<Arc<Chunk>>, but since it does not, I instead have to use a HashMap<Arc<Chunk>, Arc<Chunk>> where the key and value is always the same which does not seem totally logical and downright impossible if it were a non-cloneable key.

Likewise, it may be an idea to implement some sort of get_key_value that would return a key value pair for HashMap.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions