Esempio n. 1
0
fcppt::container::grid::dim<
	SizeType,
	Size
>
range_dim(
	fcppt::container::grid::min<
		SizeType,
		Size
	> const _min,
	fcppt::container::grid::sup<
		SizeType,
		Size
	> const _sup
)
{
	return
		fcppt::container::grid::min_less_sup(
			_min,
			_sup
		)
		?
			fcppt::math::vector::to_dim(
				_sup.get()
				-
				_min.get()
			)
		:
			fcppt::math::dim::null<
				fcppt::container::grid::dim<
					SizeType,
					Size
				>
			>()
		;
}
Esempio n. 2
0
fcppt::container::grid::pos<
	SizeType,
	Size
>
next_position(
	fcppt::container::grid::pos<
		SizeType,
		Size
	> const _current,
	fcppt::container::grid::min<
		SizeType,
		Size
	> const _min,
	fcppt::container::grid::sup<
		SizeType,
		Size
	> const _sup
)
{
	typedef
	fcppt::container::grid::pos<
		SizeType,
		Size
	>
	result_type;

	result_type result{
		_current
	};

	++result.x();

	return
		fcppt::algorithm::fold(
			fcppt::math::int_range_count<
				Size
				-
				1u
			>{},
			result,
			[
				&_min,
				&_sup
			](
				auto const _index,
				result_type _result
			)
			{
				FCPPT_USE(
					_index
				);

				typedef
				fcppt::tag_type<
					decltype(
						_index
					)
				>
				index;

				if(
					fcppt::math::vector::at<
						index::value
					>(
						_result
					)
					==
					fcppt::math::vector::at<
						index::value
					>(
						_sup.get()
					)
				)
				{
					fcppt::math::vector::at<
						index::value
					>(
						_result
					) =
						fcppt::math::vector::at<
							index::value
						>(
							_min.get()
						);

					++
					fcppt::math::vector::at<
						index::value
						+
						1u
					>(
						_result
					);
				}

				return
					_result;
			}
		);
}