comparison jmedcouple.c++ @ 35:6c264f2053bc

jmedcouple: use std::tie and std::move for tuple unpacking
author Jordi Gutiérrez Hermoso <jordigh@octave.org>
date Mon, 19 Jan 2015 10:20:22 -0500
parents 2e277129e81b
children 4fb3b87b8610
comparison
equal deleted inserted replaced
34:f9d59c356eb0 35:6c264f2053bc
44 [](const aw_t& l, const aw_t& r){return l.first > r.first;}); 44 [](const aw_t& l, const aw_t& r){return l.first > r.first;});
45 double trial = AW[mid].first; 45 double trial = AW[mid].first;
46 long wleft = 0, wright = 0; 46 long wleft = 0, wright = 0;
47 47
48 for (aw_t& aw: AW ) { 48 for (aw_t& aw: AW ) {
49 if (aw.first > trial) 49 double a;
50 wleft += aw.second; 50 long w;
51 tie(a, w) = move(aw);
52 if (a > trial)
53 wleft += w;
51 else 54 else
52 // This also includes a == trial, i.e. the "middle" weight. 55 // This also includes a == trial, i.e. the "middle" weight.
53 wright += aw.second; 56 wright += w;
54 } 57 }
55 58
56 if (2*wleft > wtot) 59 if (2*wleft > wtot)
57 end = mid; 60 end = mid;
58 else if (2*wright < wtot) 61 else if (2*wright < wtot)