Dominique Devienne
On Thu, Mar 3, 2016 at 10:21 AM, Joaquin M LópezMuñoz
Suppose we use the following: template
struct punctured_less { bool operator()(const T& x,const T& y)const { if(x==puncture&&y==puncture)return true; But can we do better? If like in any initial email, you take into account that the to-be-indexed int is part of a larger struct with other fields, which can be used to "break ties" between elements who's index match the "puncture"?
[...]
struct entry { int uid; // real uuid in reality, but enough for our needs here int occurence; // the field to be indexed, uniquely "except for -1" };
OK, yes, we can do something with that. What you want is unique sorting
by occurrence, except when occurrence==-1 in which case you want to
(uniquely) sort lexicographically on uid. This *is* indeed a SWO, so
we can do:
struct entry
{
int uid;
int occurrence;
};
struct entry_occurrence_less
{
bool operator()(const entry& x,const entry& y)const
{
if(x.occurrence==-1&&y.occurrence==-1)return x.uid