Exemplo n.º 1
0
inline void GAppSetOpts_ranged(const char *value, Cont& cont) {
	cont.clear();
	bool had_range = false;

	const char *comma = value;
	do {
		uint32_t low = abs(atoi(comma)), high = low;
		const char *delim = strchr(comma, '-');
		const char *nextc = strchr(comma, ',');
		if (delim && (nextc == 0 || nextc > delim)) {
			had_range = true;
			high = abs(atoi(delim + 1));
		}
		for (; low <= high; ++low) {
			cont.push_back(low);
		}
	} while ((comma = strchr(comma, ',')) != 0 && ++comma && *comma != 0);

	if (cont.size() == 1 && !had_range) {
		uint32_t val = cont.front();
		cont.clear();
		for (uint32_t i = 1; i <= val; ++i) {
			cont.push_back(i);
		}
	}
}
Exemplo n.º 2
0
void insert_back(Cont& c, long& avg, const int& num_op)
{
	cout << "\nCounting..." 
		<< "time of " << num_op << " back_insert";
	clock_t t = 0;

	for(int j = 0; j < REPEAT_TEST; ++j)
	{

		c.push_back(0);
		c.push_back(0);

		auto it = c.end();
		t = clock();
		for (int i = 1; i <= num_op ; ++i)
		{
			it = c.end();
			c.insert(it, i);		
		}

		t = clock() - t;
		avg += t;
		c.clear();
	}


	avg /= REPEAT_TEST;
}
 Cont keep_if(Pred pred, const Cont& xs)
 {
     Cont ys;
     for (const auto x : xs)
     {
         if (pred(x))
         {
             ys.push_back(x);
         }
     }
     return ys;
 }
Exemplo n.º 4
0
void strategy1()
{
    int numElems;
    cin >> numElems;
    Cont container;

    for (int ii = 0; ii < numElems; ii++)
    {
        container.push_back(0);
        cin >> container.back();
    }
    for (int day = 0; ; day++)
    {
        list<ContIter> toDelete;
        ContIter iThis(container.begin());
        ContIter iPrev(iThis);
        iThis++;
        while (iThis != container.end())
        {
            if (*iThis > *iPrev)
            {
                toDelete.push_back(iThis);
            }
            iThis++;
            iPrev++;
        }
        if (toDelete.empty())
        {
            cout << day << endl;
            break;
        }
//        cout << "toDelete ";
 //       dump(toDelete);
        for (list<ContIter>::reverse_iterator iDel = toDelete.rbegin(); iDel != toDelete.rend(); iDel++)
        {
            container.erase(*iDel);
        }
 //       dump(container);
    } 
}
Exemplo n.º 5
0
void push_back(Cont& c, long& avg, const int& num_op)
{
	cout << "\nCounting..." 
		 << "time of " << num_op << " push_back";
	clock_t t = 0;
	for(int j = 0; j < REPEAT_TEST; ++j)
	{
		t = clock();
		for (int i = 1; i <= num_op ; ++i)
		{

			c.push_back(i);

		}
		t = clock() - t;
		avg += t;
		c.clear();
	}

	c.clear();
	avg /= REPEAT_TEST;
}
Exemplo n.º 6
0
 void operator()() const
 {
     cont->push_back(argument_type());
 }
Exemplo n.º 7
0
 void operator()(const V&v) const
 {
     cont->push_back(v);
 }
 void operator()(Cont& c, long count) {
     for (long i = 0; i < count; i++)
         c.push_back(fs);
 }
Exemplo n.º 9
0
 Back_inserter& operator=(typename Cont::const_reference val) { c->push_back(val); return *this; }