make_heap или ?
От: 13akaEagle Россия  
Дата: 26.12.06 14:04
Оценка:
struct Team 
{
    std::string _name;

    Team::Team(std::string name);
};

struct Game
{
    Team& _first;
    Team& _second;
    Score score;
//    TDateTime _datetime;
    std::string _datetime;

    Game(Team& first, Team& second, std::string datetime);
    Game& operator=(const Game& game);
    friend bool operator>(const Game& left, const Game& rigth);
};

int _tmain(int argc, _TCHAR* argv[])
{
    std::vector<Game> g;

    Team a("Russia");
    Team b("Litva");
    Team c("Estonia");

    g.push_back(Game(a, b, "25.12.2006"));
    g.push_back(Game(c, b, "26.12.2006"));
    g.push_back(Game(a, c, "27.12.2006"));


    make_heap(g.begin(), g.end(), std::greater<Game>());
    for (std::vector<Game>::iterator it = g.begin(); it != g.end(); ++it)
    {
        Game& game = static_cast<Game>(*it);
        std::cout << game._first._name << " " << game._second._name << std::endl;
    }
}


Выводит:

Estonia Litva
Estonia Litva
Estonia Estonia

Совсем не то, что ожидалось.
Как будет правильно?
... << RSDN@Home 1.1.4 stable SR1 rev. 568>>
 
Подождите ...
Wait...
Пока на собственное сообщение не было ответов, его можно удалить.