glob2-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[glob2-devel] question about std::list


From: Leo Wandersleb
Subject: [glob2-devel] question about std::list
Date: Thu, 03 May 2007 01:16:15 +0200
User-agent: Icedove 1.5.0.10 (X11/20070328)

hi

fighting to get a meaningful unit allocation i ran into a sort that doesn't 
sort:
ok it sorted. but it sorted pointers. not what i thought it would sort.

ok now that i know and that it works, can someone tell me how to do it clean?

i had
unitsWorking.sort();
with
public:
Sint32 score;
bool operator < (const Unit& u) { return score < u.score; }
in Unit.h
and that was only sorting adresses.

i found out that:
class Predicate
{
        public:
        bool operator() (const Unit* lhs, const Unit* rhs) {
                return lhs->score < rhs->score;
        }
};
and then
unitsWorking.sort(Predicate());
worked as expected. But how can i tell it to use my operator <??

thanx for input

Leo Wandersleb

P.S.: Unit Alocation still is fun to work at although i'm not too impressd by my success :/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]