D
Der Andere
I posted this reaction in a thread quite far below so I fear people won't
read it. I got stuck now for quite a while and just don't know what to try
else.
Thanks,
Matthias
The following sample program does not compile but I have no idea what to do
about it. Might be a beginner's fault. If I substitute pv(comp()) with
pv(std::less<Vertex*>()) the compiler gives no error, but I strongly suppose
less() would order the elements according to the address value of the
pointer.
#include <queue>
struct Vertex
{
int a;
};
bool comp (Vertex* v1, Vertex* v2)
{
return v1->a < v2->a;
}
int main()
{
std:riority_queue<Vertex*> pv(comp());
return 0;
}
Regards,
Matthias
read it. I got stuck now for quite a while and just don't know what to try
else.
Thanks,
Matthias
See template class priority_queue in the header <queue>. You'll
have to supply an ordering predicate that takes two pointers
and returns true when one of the designated objects is ordered
before the other, but that shouldn't be hard.
The following sample program does not compile but I have no idea what to do
about it. Might be a beginner's fault. If I substitute pv(comp()) with
pv(std::less<Vertex*>()) the compiler gives no error, but I strongly suppose
less() would order the elements according to the address value of the
pointer.
#include <queue>
struct Vertex
{
int a;
};
bool comp (Vertex* v1, Vertex* v2)
{
return v1->a < v2->a;
}
int main()
{
std:riority_queue<Vertex*> pv(comp());
return 0;
}
Regards,
Matthias