← Back to team overview

widelands-dev team mailing list archive

Re: troubles with priority_queue

 

I just gave up on this. I used std::map - it works so I will test it for
some time....

Thanks anyway

2015-12-01 16:05 GMT+01:00 Fòram na Gàidhlig <fios@xxxxxxxxxxxxxxxxxxx>:

> Do you have a constructor to create a request_dist from another
> request_dist? That solved by problem once for something like this.
>
> I'm not sure if you need the = comparator, but you can test that easily
> once you have gotten rid of the compiler error.
>
>
>
> Sgrìobh Tibor Bamhor na leanas 01/12/2015 aig 12:50:
> > Hi,
> >
> > I spent few hours today to code priority queue for economy. The queue
> > should contains structs of distance,&supply. Distance is distance from
> > request to supply and this has to be a sorting key. I tried multiple
> > things but failed to make it work. By now I have:
> >
> > ---------------------------------------------
> > struct request_dist {
> > request_dist(uint32_t d, Supply& s) : dist(d), supply(s) { }
> > struct compare {
> > bool operator() (const request_dist & a, const request_dist & b) const {
> > return a.dist < b.dist;
> > }
> >
> > };
> >
> >        // is following needed?
> > void operator=(const request_dist& other){
> > dist = other.dist;
> > supply = other.supply;
> > }
> > uint32_t dist;
> > Supply& supply;
> > };
> >
> >
> >
> > using AvailableSupplies = std::priority_queue<request_dist,
> > std::vector<request_dist>, request_dist::compare>;
> > AvailableSupplies available_supplies;
> >
> > ---------------------------------------------
> >
> > Currently I am getting this:
> >
> > /var/widelands/request_supply_opt/src/economy/economy.h:253:10: error:
> > invalid use of incomplete type 'struct Widelands::Supply'
> >    supply = other.supply;
> >           ^
> > In file included from
> > /var/widelands/request_supply_opt/src/economy/economy.h:34:0,
> >                  from
> > /var/widelands/request_supply_opt/src/wui/actionconfirm.cc:25:
> > /var/widelands/request_supply_opt/src/economy/supply_list.h:30:8: error:
> > forward declaration of 'struct Widelands::Supply'
> >  struct Supply;
> >
> >
> > Can you advice me? This is far beyond my coding skills...
> >
> > But on the other hand this is not critical for my life nor widelands, I
> > just have some improvement in my head...
> >
> > Thanks
> >
> > Tibor
> >
> >
> > _______________________________________________
> > Mailing list: https://launchpad.net/~widelands-dev
> > Post to     : widelands-dev@xxxxxxxxxxxxxxxxxxx
> > Unsubscribe : https://launchpad.net/~widelands-dev
> > More help   : https://help.launchpad.net/ListHelp
> >
> >
> >
> > No virus found in this message.
> > Checked by AVG - www.avg.com <http://www.avg.com>
> > Version: 2016.0.7227 / Virus Database: 4477/11097 - Release Date:
> 12/01/15
> >
>
> --
> -----BEGIN PGP PUBLIC KEY BLOCK-----
> Version: GnuPG v2.0.22 (MingW32)
>
> mQINBFNbSyEBEADh+uhohycnZgPPnyMs5pZQG6pKyLzFZoIKbVjY31ZoPZ2SdltB
> elrwn6kFZkQiDx4K6nkZFHsPh8RMvWoFWg1rGiWkdsZessLFawraC8YEZDwtlaU5
> SFXbE4+QnMfbPhe9tmC8Nbhec3dfV9zcXAhxc+zkIUsKFhSkpJ2Syvo9FCA/5adW
> UZgWWKFwlSg4+/lrhJ6QJnldPlXfWcuEasKF7fjdafDIdS5hdKu8Lv+CiPQWvgsi
> J2BDlZLzEZf3PD+NMujUbJa0nilD2ltu3/qRvR2f86YV6wRwt4E2OD8JJQOau4X2
> Pg7vqkIbnB9rMiQ6T17rQ4rc80eesGCxQ6XOba9oa1eRRZDwY7HJtYwvPdw9HZaN
> Lq2RRbGDGO0q7fxrzbp1WuNN+UXOA/pmVzWWczPfPHVcNIehGf3wQI+Vgh/qa+IZ
> jLJ25I1Tv85cDzvv5gdtI8PR4JTfK6Db+gUJmsuIg2fmsljxA7OmeTgSPR7nEVq5
> VlHYfx1T0uKlthWw/eDwlS44vTgm6HZzIdYqdPMPa/PU1U+WVuDejyDJTn/1TY78
> oJMT/IixFR+N+smohhKASprewcsO2ClWGptSG0sRTiCrVHFD3Mt6SCVaxsQLHvek
> KuNAUXhR2KSvYuqGT0Nv3bplN6svCp4CuAGZ3lyOIt/Sb7OFUwzcx2sOdwARAQAB
> tC5Gw7JyYW0gbmEgR8OgaWRobGlnIDxmaW9zQGZvcmFtbmFnYWlkaGxpZy5uZXQ+
> iQI5BBMBAgAjBQJTW0shAhsPBwsJCAcDAgEGFQgCCQoLBBYCAwECHgECF4AACgkQ
> UHP09XBr75NHNBAAxv2C/G13Z1kCFOSOnbPpzqcIDcMuP7RK1Mv5XfOZLfqSw4le
> gdDmZggX2/EBH6xFTXFPLSE6rVUKTkHLA7IY8D43GBtDWjcIyyuLnIjtR+LhRKCP
> 3/Sm8MyZMQvUH1CBpUXFNnP/HCR6xjm1Mog5kXxFeCR9PMjeEiobKXIVuMfuNlBD
> WzoR2Nh+oroXLjZw3VMFewiCyhu4Pe7F3sLpVldiI3PBOyPQOBZ3HEIM490D/Lrh
> rl3Wwmoug8j8rqkh/Fr+kKaToRJik4PkcxsfepzhMdNfCpr7I3jE5XQHzib5Ubv8
> wsSaVNBG92NTnGKoAntWXBUaiDN84St9l+Zm/BgedRk+7wdESHBuOuFXoRc0yEjF
> 4tLOhyO9u5bYGQWHyJiwhbw51R8G+Kh3OPq/tr4KmsuueEI2v5cLkoDzwCpYyMnu
> BfU8d0mt5eULbQCWcy7LYeQs6E+CEB+tPL3Qz2zaAAvwt7N2PLMjHf5Fcqj5LqrV
> mzQfcB9zQFq9Rtld/IIIDkE1y/q/SNFYsFNW/u/bxWsu+lMOYtBco++O5DJhAq6t
> 7rJXUBirju50hhogHfBL2v6RG1b8/uiWm0m8713ZhiSvpr4Dd+V+DU9nPli5nTmU
> En6gP7TTYJKETMf7O9i873Z8yG6zd0/fBzFyruS2KRTPV2GiVT6CI37gUtw=
> =fcOW
> -----END PGP PUBLIC KEY BLOCK-----
>
> _______________________________________________
> Mailing list: https://launchpad.net/~widelands-dev
> Post to     : widelands-dev@xxxxxxxxxxxxxxxxxxx
> Unsubscribe : https://launchpad.net/~widelands-dev
> More help   : https://help.launchpad.net/ListHelp
>

References