Beispiel #1
0
void set_difference (C1& B, const C2& A)
{
  typename C1::iterator newlast = B.end();
  for (typename C2::const_iterator it=A.begin(); it != A.end(); it++)
    newlast = std::remove (B.begin(), newlast, *it);
  B.erase (newlast, B.end());
}
Beispiel #2
0
std::vector<std::pair<typename C1::value_type, typename C2::value_type> > zip(C1 const &container1,
                                                                              C2 const &container2)
{
    std::vector<std::pair<typename C1::value_type, typename C2::value_type> > result;

    auto it1 = container1.begin();
    auto it2 = container2.begin();
    for (; it1 != container1.end() && it2 != container2.end(); ++it1, ++it2) {
        result.push_back(std::make_pair(*it1, *it2));
    }

    return result;
}
static void fillStats(C1<Stat> &stats, const Interval &iv, const C2<Value> &vals)
{
    int i = 0, n = stats.size(), dt = iv.secs();
    typename C1<Stat>::iterator st = stats.begin();
    typename C2<Value>::const_iterator v1 = vals.begin(), v2 = vals.begin(); ++v2;
    while(v2 != vals.end() && st != stats.end())
    {
        Interval vi(v1->tm, v2->tm);//, ci(iv.t1 + i*dt/n, iv.t1 + (i + 1)*dt/n);
        uint t = iv.t1 + int((i + 0.5f)*dt/n);
        if(v2->value != v2->value) vi.t2 = vi.t1 + 1;
        if(vi.contains(t) && v1->value == v1->value)
        {
        	//typename C1<Stat>::iterator pst = st;
        	//if(pst != stats.begin()) (--pst)->add(v1->value);
        	st->add(v1->value);
        }
        if(t < vi.t2) ++st, ++i; else ++v1, ++v2;
    }
}