Esempio n. 1
0
	iterator insert(value_type&& val) {
		if (container.empty()) {
			return container.insert(detail::adl_cend(container), val);
		}
		auto elementgreaterthanorequalto = std::lower_bound(detail::adl_cbegin(container), detail::adl_cend(container), val, std::ref(predicate));
		return container.insert(elementgreaterthanorequalto, std::move(val));
	}
Esempio n. 2
0
	iterator insert(value_type&& val) {
		if (container.empty()) {
			return container.insert(cend(), val);
		}
		auto elementgreaterthanorequalto = std::lower_bound(cbegin(), cend(), val, std::ref(compare_predicate));
		return container.insert(elementgreaterthanorequalto, std::move(val));
	}
Esempio n. 3
0
auto zip_var(LastCont lastContainer) {
  Cont<tuple<typename LastCont::value_type>, allocator<tuple<typename LastCont::value_type>>> result;
  for_each(lastContainer.begin(), lastContainer.end(), [&](auto &content) {
    result.insert(result.end(), make_tuple(content));
  });
  return result;
}
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;
}
	bool erase(T t) {
		ContIter it = std::lower_bound(elements.begin(), elements.end(), t);
		if (it == elements.end()) {
			return false;
		}
		if (it->ub < t || it->lb > t) {
			return false;
		}
		if (it->lb == t && it->ub == t) {
			elements.erase(it);
			--_size;
			return true;
		}
		if (it->ub == t) {
			--it->ub;
			--_size;
			return true;
		}
		if (it->lb == t) {
			++it->lb;
			--_size;
			return true;
		}
		if (it->lb < t && it->ub > t) {
			elements.insert(it + 1, interval(t + 1, it->ub));
			it->ub = t - 1;
			--_size;
			return true;
		}

		assert(false && "interval_vector.erase() should never reach this place...");
		return false;
	}
	bool insert(T t) {
		ContIter it = std::lower_bound(elements.begin(), elements.end(), t);
		if (it != elements.end() && t >= it->lb && t <= it->ub) {
			return false;
		}
		ContIter pr = it - 1;
		if (it != elements.begin() && pr->ub + 1 == t) {
			++pr->ub;
			if (it != elements.end() && pr->ub + 1 == it->lb) {
				pr->ub = it->ub;
				elements.erase(it);
			}
		}
		else if (it != elements.end() && it->lb == t + 1) {
			--it->lb;
			if (it != elements.begin() && pr->ub + 1 == it->lb) {
				pr->ub = it->ub;
				elements.erase(it);
			}
		}
		else {
			elements.insert(it, interval(t));
		}
		++_size;
		return true;
	}
Esempio n. 7
0
	iterator emplace(Tn&&... argn) {
		if (container.empty()) {
			return container.insert(detail::adl_cend(container), std::forward<Tn>(argn)...);
		}
		auto elementgreaterthanorequalto = std::lower_bound(detail::adl_cbegin(container), detail::adl_cend(container), val, std::ref(predicate));
		return container.emplace(elementgreaterthanorequalto, std::forward<Tn>(argn)...);
	}
 void operator()(Cont& c, long count) {
     typename Cont::iterator it;
     long cnt = count / 10;
     for (long i = 0; i < cnt; i++) {
         // Must get the iterator every time to keep
         // from causing an access violation with
         // vector. Increment it to put it in the
         // middle of the container:
         it = c.begin();
         it++;
         c.insert(it, fs);
     }
 }
Esempio n. 9
0
void test_unordered_interface()
{
    Cont c;
    T* t = new T;
    c.insert( t );
    typename Cont::local_iterator i = c.begin( 0 );
    typename Cont::const_local_iterator ci = i;
    ci = c.cbegin( 0 );
    i = c.end( 0 );
    ci = c.cend( 0 );
    typename Cont::size_type s = c.bucket_count();
    s = c.max_bucket_count();
    s = c.bucket_size( 0 );
    s = c.bucket( *t );
    float f = c.load_factor();
    f       = c.max_load_factor();
    c.max_load_factor(f);
    c.rehash(1000);
} 
Esempio n. 10
0
void mock_cursor_data(Cont& data)
{ 
    data.insert(test_data( 0, 0, 5,10, 8));
    data.insert(test_data( 1, 1, 1, 4, 3));
    data.insert(test_data( 3, 2, 0, 0, 1));
    data.insert(test_data( 4, 3, 3, 3, 6));
    data.insert(test_data( 9, 4, 2, 1, 4));
    data.insert(test_data(10, 5, 4, 2, 7));
    data.insert(test_data( 2, 6, 6, 9,10));
    data.insert(test_data( 6, 7,10, 8,14));
    data.insert(test_data(13, 8, 9, 7,13));
    data.insert(test_data(27, 9, 7, 6,11));
    data.insert(test_data(56,10, 8, 5,12));
}
		inline
		bool replace_key (Cont& c,
						  const typename Cont::key_type& old_key,
						  const typename Cont::key_type& new_key)
		{
			typename Cont::iterator pos;
			pos = c.find(old_key);
			if (pos != c.end()) {
				// insert new element with value of old element
				c.insert(typename Cont::value_type(new_key,
												   pos->second));
				// remove old element
				c.erase(pos);
				return true;
			}
			else {
				// key not found
				return false;
			}
		}
Esempio n. 12
0
void test_unordered_interface()
{
    Cont c;
    T* t = new T;
    Key key = get_next_key( key );
    c.insert( key, t );
    typename Cont::local_iterator i = c.begin( 0 );
    typename Cont::const_local_iterator ci = i;
    ci = c.cbegin( 0 );
    i = c.end( 0 );
    ci = c.cend( 0 );
    typename Cont::size_type s = c.bucket_count();
    hide_warning(s);
    s = c.max_bucket_count();
    s = c.bucket_size( 0 );
    s = c.bucket( key );
    float f = c.load_factor();
    f       = c.max_load_factor();
    c.max_load_factor(f);
    c.rehash(1000);
} 
Esempio n. 13
0
	iterator insert(value_type&& val) {
		auto x = container.insert(std::move(val));
		return x.first;
	}
Esempio n. 14
0
	iterator insert(const value_type& val) {
		auto x = container.insert(val);
		return x.first;
	}