コード例 #1
0
void detail::CFileSystemWatcherInterface::processChangesAndNotifySubscribers(const QFileInfoList& newState)
{
	// Note: QFileInfo::operator== does exactly what's needed
	// http://doc.qt.io/qt-5/qfileinfo.html#operator-eq-eq
	// If this changes, a custom comparator will be required

	std::set<QFileInfo, std::less<>> newItemsSet;
	std::copy(begin_to_end(newState), std::inserter(newItemsSet, newItemsSet.end()));

	const auto diff = SetOperations::calculateDiff(_previousState, newItemsSet);

	transparent_set<QFileInfo> changedItems;
	for (const auto& newItem : diff.common_elements)
	{
		const auto sameOldItem = container_aware_find(_previousState, newItem);
		assert_debug_only(sameOldItem != _previousState.end());
		if (sameOldItem->fileDetailsChanged(newItem))
			changedItems.insert(newItem);
	}

	if (!changedItems.empty() || !diff.elements_from_a_not_in_b.empty() || !diff.elements_from_b_not_in_a.empty())
	{
		for (const auto& callback : _callbacks)
			callback(diff.elements_from_b_not_in_a, diff.elements_from_a_not_in_b, changedItems);

		_previousState.clear();
		std::copy(begin_to_end(newState), std::inserter(_previousState, _previousState.end()));
	}
}
コード例 #2
0
int GRASP::pickARandomNumberBetween(int begin, int end){
  typedef boost::mt19937 RNGType;
  RNGType rng;
  rng.seed(std::random_device()());
  boost::uniform_int<> begin_to_end( begin, end );
  boost::variate_generator< RNGType, boost::uniform_int<> >
                dice(rng, begin_to_end);
  return dice();
}