21 namespace seqan3::detail
59 template <
typename derived_t>
60 class alignment_matrix_column_major_range_base
75 class alignment_column_type :
public std::ranges::view_interface<alignment_column_type>
79 using view_type =
typename deferred_type<typename derived_t::column_data_view_type>::type;
81 static_assert(std::ranges::random_access_range<view_type>,
"Column view must support random access.");
82 static_assert(std::ranges::sized_range<view_type>,
"Column view must be a sized range.");
83 static_assert(std::ranges::view<view_type>,
"Column view must be a view.");
86 using sentinel = std::ranges::sentinel_t<view_type>;
104 using value_type =
typename deferred_type<typename derived_t::value_type>::type;
107 using reference =
typename deferred_type<typename derived_t::reference>::type;
109 using pointer = void;
111 using difference_type = std::ranges::range_difference_t<view_type>;
119 constexpr iterator_type() =
default;
120 constexpr iterator_type(iterator_type
const &) =
default;
121 constexpr iterator_type(iterator_type &&) =
default;
122 constexpr iterator_type & operator=(iterator_type
const &) =
default;
123 constexpr iterator_type & operator=(iterator_type &&) =
default;
124 ~iterator_type() =
default;
129 explicit constexpr iterator_type(alignment_column_type & host) :
131 host_iter{host.ref.begin()}
133 host_ptr->me_ptr->on_column_iterator_creation(host_iter);
140 constexpr reference operator*() const noexcept
143 static_assert(std::convertible_to<decltype(host_ptr->me_ptr->make_proxy(host_iter)), reference>,
144 "The returned type of make_proxy must be convertible to the reference type.");
145 assert(host_ptr !=
nullptr);
146 return host_ptr->me_ptr->make_proxy(host_iter);
153 constexpr iterator_type & operator++() noexcept
156 assert(host_ptr !=
nullptr);
157 assert(host_ptr->me_ptr !=
nullptr);
159 host_ptr->me_ptr->before_column_iterator_increment(host_iter);
161 host_ptr->me_ptr->after_column_iterator_increment(host_iter);
166 constexpr iterator_type operator++(
int) noexcept
168 iterator_type tmp{*
this};
177 constexpr
bool operator==(sentinel
const & rhs)
const noexcept
180 return host_iter == rhs;
184 friend constexpr
bool operator==(sentinel
const & lhs, iterator_type
const & rhs) noexcept
190 constexpr
bool operator==(iterator_type
const & rhs)
const noexcept
192 return (host_ptr == rhs.host_ptr) && (host_iter == rhs.host_iter);
196 constexpr
bool operator!=(sentinel
const & rhs)
const noexcept
198 return !(*
this == rhs);
202 friend constexpr
bool operator!=(sentinel
const & lhs, iterator_type
const & rhs) noexcept
208 constexpr
bool operator!=(iterator_type
const & rhs)
const noexcept
210 return !(*
this == rhs);
216 alignment_column_type * host_ptr{
nullptr};
218 std::ranges::iterator_t<view_type> host_iter{};
225 constexpr alignment_column_type() =
default;
226 constexpr alignment_column_type(alignment_column_type
const &) =
default;
227 constexpr alignment_column_type(alignment_column_type &&) =
default;
228 constexpr alignment_column_type & operator=(alignment_column_type
const &) =
default;
229 constexpr alignment_column_type & operator=(alignment_column_type &&) =
default;
230 ~alignment_column_type() =
default;
240 constexpr alignment_column_type(derived_t & me, view_type ref) :
250 constexpr iterator_type
begin() noexcept
253 assert(me_ptr !=
nullptr);
254 return iterator_type{*
this};
258 constexpr
auto begin() const noexcept = delete;
261 constexpr sentinel end() noexcept
267 constexpr sentinel
end() const noexcept = delete;
271 constexpr
size_t size() const noexcept
280 derived_t * me_ptr{};
301 using value_type = alignment_column_type;
304 using reference = value_type;
306 using pointer = void;
308 using difference_type = std::ranges::range_difference_t<alignment_column_type>;
316 constexpr iterator_type() =
default;
317 constexpr iterator_type(iterator_type
const &) =
default;
318 constexpr iterator_type(iterator_type &&) =
default;
319 constexpr iterator_type & operator=(iterator_type
const &) =
default;
320 constexpr iterator_type & operator=(iterator_type &&) =
default;
321 ~iterator_type() =
default;
326 explicit constexpr iterator_type(derived_t & me) :
335 constexpr reference operator*() const noexcept
338 static_assert(std::convertible_to<decltype(me_ptr->initialise_column(column_index)), reference>,
339 "The returned type of initialise_column must be convertible to the reference type.");
340 return me_ptr->initialise_column(column_index);
347 constexpr iterator_type & operator++() noexcept
355 constexpr
void operator++(
int) noexcept
364 constexpr
bool operator==(std::default_sentinel_t
const &)
const noexcept
367 return column_index == me_ptr->num_cols;
371 friend constexpr
bool operator==(std::default_sentinel_t
const & lhs, iterator_type
const & rhs)
378 constexpr
bool operator!=(std::default_sentinel_t
const & rhs)
const noexcept
380 return !(*
this == rhs);
384 friend constexpr
bool operator!=(std::default_sentinel_t
const & lhs, iterator_type
const & rhs)
395 size_t column_index{};
401 constexpr alignment_matrix_column_major_range_base() =
default;
404 constexpr alignment_matrix_column_major_range_base(alignment_matrix_column_major_range_base
const &) =
default;
406 constexpr alignment_matrix_column_major_range_base(alignment_matrix_column_major_range_base &&) =
default;
408 constexpr alignment_matrix_column_major_range_base &
409 operator=(alignment_matrix_column_major_range_base
const &) =
default;
411 constexpr alignment_matrix_column_major_range_base &
412 operator=(alignment_matrix_column_major_range_base &&) =
default;
414 ~alignment_matrix_column_major_range_base() =
default;
424 SEQAN3_DOXYGEN_ONLY(
typedef value_type;)
429 SEQAN3_DOXYGEN_ONLY(
typedef column_data_view_type;)
441 SEQAN3_DOXYGEN_ONLY(value_type make_proxy(iter_t host_iter) noexcept {})
455 SEQAN3_DOXYGEN_ONLY(alignment_column_type initialise_column(
size_t column_index) {})
461 template <typename iter_t>
462 constexpr
void on_column_iterator_creation(iter_t SEQAN3_DOXYGEN_ONLY(host_iter)) noexcept
469 template <
typename iter_t>
470 constexpr
void before_column_iterator_increment(iter_t SEQAN3_DOXYGEN_ONLY(host_iter)) noexcept
477 template <
typename iter_t>
478 constexpr
void after_column_iterator_increment(iter_t SEQAN3_DOXYGEN_ONLY(host_iter)) noexcept
483 using iterator = iterator_type;
485 using sentinel = std::default_sentinel_t;
492 constexpr iterator
begin() noexcept
495 return iterator{
static_cast<derived_t &
>(*this)};
499 constexpr iterator
begin() const noexcept = delete;
502 constexpr sentinel end() noexcept
504 return std::default_sentinel;
508 constexpr sentinel
end() const noexcept = delete;