Esempio n. 1
0
task4_5::solution::solution( const data_type& data )
{
	if(!data.empty())
	{
		m_max = data[0][0];
		m_min = data[0][0];
		m_current_vector = data.size();
		calculate_result(data);
	}
	else
	{
		m_max = 0;
		m_min = 0;
	}
}
Esempio n. 2
0
task4_5::solution::solution( const data_type& data ) : min_(0), max_(0)
{		
	if (!data.empty())
	{
		data_ = data;

		min_ = std::numeric_limits< int >().max();
		max_ = std::numeric_limits< int >().min();

		cur_it_ = data_.begin();

		boost::thread_group thread_group;
		for(int i = 0; i < 4; ++i)
		{
			thread_group.create_thread(boost::bind(&solution::thread_fun, this));
		}

		thread_group.join_all();
	}
}
Esempio n. 3
0
task4_5::solution::solution(const data_type& data) : min(std::numeric_limits< int >().max()), max(std::numeric_limits< int >().min())
{
	boost::thread_group threads;

	if (!data.empty())
	{
		for (size_t i = 0; i < data.size(); i++)
		{
			threads.create_thread(boost::bind(&task4_5::solution::search_min, this, boost::ref(data[i])));
			threads.create_thread(boost::bind(&task4_5::solution::search_max, this, boost::ref(data[i])));
		}

		threads.join_all();

	}
	else
	{
		min = 0;
		max = 0;
	}
}
Esempio n. 4
0
task4_5::solution::solution(const data_type& data) : min_(0), max_(0)
{
	std::vector<std::future<std::pair<int, int>>> futures;
	if (data.empty())
	{
		min_ = 0;
		max_ = 0;
	}
	else
	{
		min_ = std::numeric_limits<int>().max();
		max_ = std::numeric_limits<int>().min();
	}
	for (size_t i = 0; i < data.size(); ++i)
		futures.push_back(std::async(&VectMinMaxFindingFunc, std::cref(data[i])));
	for (auto & ftr : futures)
	{
		const auto ftrAns = ftr.get();
		min_ = std::min(min_, ftrAns.first);
		max_ = std::max(max_, ftrAns.second);
	}
}
 /// Checks if the container has no elements, i.e. whether
 /// begin() == end().
 bool empty() const
 {
     return partition_vector_.empty();
 }
 /// Checks if the container has no elements, i.e. whether
 /// begin() == end().
 bool empty() const
 {
     return partition_unordered_map_.empty();
 }
 bool empty() const { return data_.empty(); }
 bool empty() const noexcept { return data_.empty(); }