Skip to content

Commit

Permalink
[FIX] chunk_view using 16 bit integers
Browse files Browse the repository at this point in the history
  • Loading branch information
eseiler committed Jun 15, 2022
1 parent d0c5249 commit 3fddbdc
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions include/seqan3/utility/views/chunk.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class chunk_view : public std::ranges::view_interface<chunk_view<urng_t>>
urng_t urange;

//!\brief The chunk size to use.
uint16_t chunk_size;
size_t chunk_size;

// The iterator type if `urng_t` is a pure input range. See class definition for details.
template <bool const_range>
Expand All @@ -72,7 +72,7 @@ class chunk_view : public std::ranges::view_interface<chunk_view<urng_t>>
* \param[in] underlying_range The underlying range to divide into chunks.
* \param[in] size_of_chunk The size of the chunks, e.g., the length of the subrange returned at each position.
*/
constexpr explicit chunk_view(urng_t underlying_range, uint16_t const size_of_chunk) :
constexpr explicit chunk_view(urng_t underlying_range, size_t const size_of_chunk) :
urange{std::move(underlying_range)},
chunk_size{size_of_chunk}
{}
Expand Down Expand Up @@ -161,7 +161,7 @@ class chunk_view : public std::ranges::view_interface<chunk_view<urng_t>>

//!\brief A deduction guide for the view class template.
template <std::ranges::range rng_t>
chunk_view(rng_t &&, uint16_t const &) -> chunk_view<seqan3::detail::all_t<rng_t>>;
chunk_view(rng_t &&, size_t const &) -> chunk_view<seqan3::detail::all_t<rng_t>>;

// ---------------------------------------------------------------------------------------------------------------------
// chunk_view iterators (basic_input_iterator and basic_iterator)
Expand Down Expand Up @@ -319,7 +319,7 @@ class chunk_view<urng_t>::basic_input_iterator :
*
* Constant.
*/
constexpr explicit basic_input_iterator(urng_it_t it_begin, sentinel_t it_end, uint16_t const size_of_chunk) :
constexpr explicit basic_input_iterator(urng_it_t it_begin, sentinel_t it_end, size_t const size_of_chunk) :
chunk_size{size_of_chunk},
remaining{size_of_chunk},
urng_begin{std::move(it_begin)},
Expand Down Expand Up @@ -374,10 +374,10 @@ class chunk_view<urng_t>::basic_input_iterator :

private:
//!\brief The chunk size, e.g., the length of the subrange returned by this iterator.
uint16_t chunk_size;
size_t chunk_size;

//!\brief The remaining elements in the chunk.
uint16_t remaining;
size_t remaining;

//!\brief Points to the start of the underlying range.
urng_it_t urng_begin;
Expand Down Expand Up @@ -469,7 +469,7 @@ class chunk_view<urng_t>::basic_iterator : public maybe_iterator_category<maybe_
*
* Linear in chunk_size for non-random_access ranges. Constant else.
*/
constexpr explicit basic_iterator(it_t it_start, sentinel_t it_end, uint16_t const size_of_chunk) :
constexpr explicit basic_iterator(it_t it_start, sentinel_t it_end, size_t const size_of_chunk) :
chunk_size{size_of_chunk},
urng_begin{std::move(it_start)},
urng_end{std::move(it_end)}
Expand Down Expand Up @@ -675,7 +675,7 @@ class chunk_view<urng_t>::basic_iterator : public maybe_iterator_category<maybe_

private:
//!\brief The chunk size, e.g. the length of the subrange returned by this iterator.
uint16_t chunk_size;
size_t chunk_size;

//!\brief Points to the start of the underlying range.
it_t urng_begin;
Expand Down Expand Up @@ -709,7 +709,7 @@ class chunk_view<urng_t>::basic_iterator : public maybe_iterator_category<maybe_
}
else // We need to increment one by one to not cross urng_end.
{
for (uint16_t increments{}; increments != chunk_size && start_of_chunk != urng_end; ++increments)
for (size_t increments{}; increments != chunk_size && start_of_chunk != urng_end; ++increments)
++start_of_chunk;

return start_of_chunk;
Expand Down Expand Up @@ -739,7 +739,7 @@ class chunk_view<urng_t>::basic_iterator : public maybe_iterator_category<maybe_
}
else // We need to decrement one by one to not cross urng_begin.
{
for (uint16_t decrements{}; decrements != chunk_size && end_of_chunk != urng_begin; ++decrements)
for (size_t decrements{}; decrements != chunk_size && end_of_chunk != urng_begin; ++decrements)
--end_of_chunk;

return end_of_chunk;
Expand All @@ -756,7 +756,7 @@ class chunk_view<urng_t>::basic_iterator : public maybe_iterator_category<maybe_
struct chunk_fn
{
//!\brief Store the `chunk_size` and return a range adaptor closure object.
constexpr auto operator()(uint16_t const chunk_size) const
constexpr auto operator()(size_t const chunk_size) const
{
return adaptor_from_functor{*this, chunk_size};
}
Expand All @@ -767,7 +767,7 @@ struct chunk_fn
* \returns A range of subranges.
*/
template <std::ranges::range underlying_range_t>
constexpr auto operator()(underlying_range_t && urange, uint16_t const chunk_size) const
constexpr auto operator()(underlying_range_t && urange, size_t const chunk_size) const
{
static_assert(std::ranges::input_range<underlying_range_t>,
"The range parameter to views::chunk must model std::ranges::input_range.");
Expand Down

0 comments on commit 3fddbdc

Please sign in to comment.