P
petertwocakes
Hi
I have
typedef vector<string> TokenVector
which is an array of string (words) making up a sentence.
For the purposes of my app I need it structured like this, rather than
a single composite string.
then I have
typedef set<TokenVector, compare > TokenVectorSet;
which is a set of such sentences.
I want to sort the set in to alphabetical order, as if I was dealing
with composite strings.
I think I need something like this to use as a compare function:
class compare
{
public:
std::vector<TokenVector> * myObjects;
compare(std::vector<TokenVector>* obj) : myObjects(obj) {}
bool operator ()(const int p1,const int p2)
{
.... construct composite strings from the TokenVectors and compare
them
}
};
Once I get down to operator (), I know to re-construct the strings and
compare them. It's the protocol/syntax of setting up the class/
function I'm struggling with.
Am I barking up the wrong tree? ...the compiler is just going mental!
Thanks for any clues.
I have
typedef vector<string> TokenVector
which is an array of string (words) making up a sentence.
For the purposes of my app I need it structured like this, rather than
a single composite string.
then I have
typedef set<TokenVector, compare > TokenVectorSet;
which is a set of such sentences.
I want to sort the set in to alphabetical order, as if I was dealing
with composite strings.
I think I need something like this to use as a compare function:
class compare
{
public:
std::vector<TokenVector> * myObjects;
compare(std::vector<TokenVector>* obj) : myObjects(obj) {}
bool operator ()(const int p1,const int p2)
{
.... construct composite strings from the TokenVectors and compare
them
}
};
Once I get down to operator (), I know to re-construct the strings and
compare them. It's the protocol/syntax of setting up the class/
function I'm struggling with.
Am I barking up the wrong tree? ...the compiler is just going mental!
Thanks for any clues.