S
Steve Edwards
Hi,
With much help from this forum I've been using stl containers, but
always with other common - or stl - types as members. I've now run in to
a problem while trying to use some of my own structures:
enum MySym{symA, symB, symC, symD ... etc.}
typedef struct{
MySym s1, s2, s3;
}SymTriple;
I have a large (10k) collection of SymTriples, and many of them are
equal (i.e. have same values for s1, s2, s3).
What I'd like to do is have a smaller collection without duplicates, and
a count of how many times a particular one occurs.
Maybe...
typedef struct{
SymTriple st;
long numEntries;
}SymTripleCount;
I've tried various permutations of maps/multimaps, by using the
SymTriple as a key and keeping count of when that key already exists.
The problem is I always get this error:
error: no match for 'operator<' in '__x < __y'
I'm guessing this means that the stl container can not compare or sort
my structs?
Is there any way to store my structs in an stl container, with no
duplicates, but with a count the number of occurences of each matching
pattern?
Thanks
Steve
( I could do this in regular C by looping through every 10k structs and
then testing against every (0 - x,000) unique structs I've already
collected, but this is impossibly slow.)
With much help from this forum I've been using stl containers, but
always with other common - or stl - types as members. I've now run in to
a problem while trying to use some of my own structures:
enum MySym{symA, symB, symC, symD ... etc.}
typedef struct{
MySym s1, s2, s3;
}SymTriple;
I have a large (10k) collection of SymTriples, and many of them are
equal (i.e. have same values for s1, s2, s3).
What I'd like to do is have a smaller collection without duplicates, and
a count of how many times a particular one occurs.
Maybe...
typedef struct{
SymTriple st;
long numEntries;
}SymTripleCount;
I've tried various permutations of maps/multimaps, by using the
SymTriple as a key and keeping count of when that key already exists.
The problem is I always get this error:
error: no match for 'operator<' in '__x < __y'
I'm guessing this means that the stl container can not compare or sort
my structs?
Is there any way to store my structs in an stl container, with no
duplicates, but with a count the number of occurences of each matching
pattern?
Thanks
Steve
( I could do this in regular C by looping through every 10k structs and
then testing against every (0 - x,000) unique structs I've already
collected, but this is impossibly slow.)