I have an array of vector-3 values:
struct Vector3 {
int x, y, z;
...
};
I would like to put these values into a binary search tree for quick search and finding duplicates. In a binary search tree we need to compare values to set them in a correct order. But would there be a way to compare vectors that makes sense?
I thought about comparing them by length but this will not find duplicates correctly, as two vectors can point in different directions but have the same length.
Comparing each element doesn't make sense either since it will give different results of comparison based on order in which you compare two vectors.
So does utilizing a binary search tree for multidimensional vectors makes sense? Or should I look into hash tables?
Edit: The suggested answer implements comparison between two two-dimensional vectors (points) like this (x < pt.x) || ((!(pt.x < x)) && (y < pt.y));. But there's no explanation as to how/why this comparison works.