I have been cruising through SGI's STL website:
I have a complex data structure X that only defines operator==(). I have a std::vector<X>, and I am trying to find the unique elements of this vector, using std::unique.
I can use std::unique on this data structure if data type X defines operator==(), but std::unique also requires that similar entires are grouped together. For an integral type, calling std::sort will do this for me, such as this bunch of code:
I am looking for a function contained in <algorithm> that will group identical entires of a complex data structure together
//MatRef is an std::vector<int>
//This should be renamed to 'NewEnd'
RetVal = std::unique(MatRef.begin(),MatRef.end());
Here is what I am trying to achieve:
I could easily write my own implementation of this, but I have a hard time believing this isn't already implemented in the stl.
void NT_MODEL::BuildFromMS3DModel(CMS3D_MODEL & model)
std::vector<NT_VERTEX> all_model_vertexes; //not necessarily unique at this point
//In order for unique to work, operator== must be overloaded, and the entries must be 'sorted'
//which, in this case, means all of the same vertexes are grouped together
//works on any data structure that defines operator ==
//std::sort(all_model_vertexes.begin(),all_model_vertexes.end());//doh, can't do this
std::vector<NT_VERTEX>::iterator new_end =