IMO jednym z najszybszych sposobów jest użycie kontenera unordered_map, i napisanie funkcji haszującej dla własnej struktury danych. Zaletą tego jest stały czas wyszukiwania - średnio O(1).
C++20
#include <iostream>
#include <unordered_set>
struct Point
{
int a {}, b {}, c {};
auto operator<=>(const Point&) const = default;
};
std::ostream& operator<<( std::ostream& out , const Point& point )
{
out << '(' << point.a << ',' << point.b << ',' << point.c << ')';
return out;
}
namespace std
{
template <>
struct hash<Point>
{
size_t operator()( const Point& point ) const noexcept
{
return ( std::hash<int>()(point.a) ^ ( std::hash<int>()(point.b) << 1) ) ^ std::hash<int>()(point.c);
}
};
}
int main()
{
std::unordered_set<Point> points;
for( int i {0} ; i<1000 ; ++i ) points.insert( { std::rand()%1000 , std::rand()%1000 , std::rand()%1000 } );
points.insert( {5,6,7} );
auto iter = points.find( {5,6,7} );
if( iter != std::end(points) ) std::cout << "Found point " << *iter << std::endl;
}
https://godbolt.org/z/8Yx6G7rbP