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 = difference_type_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
auto begin() noexcept
253 assert(me_ptr !=
nullptr);
254 return iterator_type{*
this};
258 constexpr
auto begin() const noexcept = delete;
261 constexpr auto cbegin() const noexcept = delete;
264 constexpr sentinel end() noexcept
270 constexpr sentinel
end() const noexcept = delete;
273 constexpr sentinel cend() const noexcept = delete;
277 constexpr
size_t size() const noexcept
286 derived_t * me_ptr{};
307 using value_type = alignment_column_type;
310 using reference = value_type;
312 using pointer = void;
314 using difference_type = difference_type_t<alignment_column_type>;
322 constexpr iterator_type() =
default;
323 constexpr iterator_type(iterator_type
const &) =
default;
324 constexpr iterator_type(iterator_type &&) =
default;
325 constexpr iterator_type & operator=(iterator_type
const &) =
default;
326 constexpr iterator_type & operator=(iterator_type &&) =
default;
327 ~iterator_type() =
default;
332 explicit constexpr iterator_type(derived_t & me) :
341 constexpr reference operator*() const noexcept
344 static_assert(
std::convertible_to<decltype(me_ptr->initialise_column(column_index)), reference>,
345 "The returned type of initialise_column must be convertible to the reference type.");
346 return me_ptr->initialise_column(column_index);
353 constexpr iterator_type & operator++() noexcept
361 constexpr
void operator++(
int) noexcept
370 constexpr
bool operator==(std::ranges::default_sentinel_t
const &)
const noexcept
373 return column_index == me_ptr->num_cols;
377 friend constexpr
bool operator==(std::ranges::default_sentinel_t
const & lhs, iterator_type
const & rhs)
384 constexpr
bool operator!=(std::ranges::default_sentinel_t
const & rhs)
const noexcept
386 return !(*
this == rhs);
390 friend constexpr
bool operator!=(std::ranges::default_sentinel_t
const & lhs, iterator_type
const & rhs)
401 size_t column_index{};
407 constexpr alignment_matrix_column_major_range_base() =
default;
410 constexpr alignment_matrix_column_major_range_base(alignment_matrix_column_major_range_base
const &) =
default;
412 constexpr alignment_matrix_column_major_range_base(alignment_matrix_column_major_range_base &&) =
default;
414 constexpr alignment_matrix_column_major_range_base &
415 operator=(alignment_matrix_column_major_range_base
const &) =
default;
417 constexpr alignment_matrix_column_major_range_base &
418 operator=(alignment_matrix_column_major_range_base &&) =
default;
420 ~alignment_matrix_column_major_range_base() =
default;
430 SEQAN3_DOXYGEN_ONLY(
typedef value_type;)
435 SEQAN3_DOXYGEN_ONLY(
typedef column_data_view_type;)
447 SEQAN3_DOXYGEN_ONLY(value_type make_proxy(iter_t host_iter) noexcept {})
461 SEQAN3_DOXYGEN_ONLY(alignment_column_type initialise_column(
size_t column_index) {})
467 template <typename iter_t>
468 constexpr
void on_column_iterator_creation(iter_t SEQAN3_DOXYGEN_ONLY(host_iter)) noexcept
475 template <
typename iter_t>
476 constexpr
void before_column_iterator_increment(iter_t SEQAN3_DOXYGEN_ONLY(host_iter)) noexcept
483 template <
typename iter_t>
484 constexpr
void after_column_iterator_increment(iter_t SEQAN3_DOXYGEN_ONLY(host_iter)) noexcept
489 using iterator = iterator_type;
491 using sentinel = std::ranges::default_sentinel_t;
498 constexpr iterator
begin() noexcept
501 return iterator{static_cast<derived_t &>(*
this)};
505 constexpr iterator
begin() const noexcept = delete;
508 constexpr iterator cbegin() const noexcept = delete;
511 constexpr sentinel end() noexcept
513 return std::ranges::default_sentinel;
517 constexpr sentinel
end() const noexcept = delete;
520 constexpr sentinel cend() const noexcept = delete;