Unique key for 3D interger coordinates to insert into a std::unordered_set

Unique key for 3D interger coordinates to insert into a std::unordered_set

I have a stream of 3D integer coordinates that correspond to voxels and thus are aligned on a grid. I want to figure out if the current processed triplet is already existing in order to filter duplicates. I was able to build a simple solution to my problem with a std::set. Let x y z be 3 int and registrybe a std::set< std::array<int, 3> >. I made a function that return a bool like that

I have a stream of 3D integer coordinates that correspond to voxels and thus are aligned on a grid. I want to figure out if the current processed triplet is already existing in order to filter duplicates. I was able to build a simple solution to my problem with a std::set. Let x y z be 3 int and registrybe a std::set< std::array<int, 3> >. I made a function that return a bool like that

std::array<int, 3> key = {x, y, z};
return registry.insert(key).second;

But this is far to be optimized in term of computation time. Reading documentation and SO topics I understand that an unordered_set should be more appropriated. Indeed there is no need to sort anything here. In addition I guess that using a array<int,3> as key is not efficient for comparison at insert time.

An unordered_set requires a hash function. Studying hash functions I found boost::hash_combineas well as other options but the problem of hash is the collisions. In fact I need to build unique keys on 96 bits to ensure that I won't have collision.

How can I use an unordered_set efficiently in my situation? The key point is being as fast as possible. I don't need to access to values and I don't need to make any special computations.

Angular 9 Tutorial: Learn to Build a CRUD Angular App Quickly

What's new in Bootstrap 5 and when Bootstrap 5 release date?

Brave, Chrome, Firefox, Opera or Edge: Which is Better and Faster?

How to Build Progressive Web Apps (PWA) using Angular 9

What is new features in Javascript ES2020 ECMAScript 2020

C/C++ vs. Rust: A developer’s perspective

In this post, you'll see the difference between Rust and C/C++ in a developer’s perspective

Variable Introduction in C#[Bangla]

LIKE | COMMENT | SHARE | SUBSCRIBE A variable is nothing but a name given to a storage area that our programs can manipulate. Each variable in C# has a speci...