11// Licensed under the MIT License <http://opensource.org/licenses/MIT>.
22// SPDX-License-Identifier: MIT
33// RapidFuzz v1.0.2
4- // Generated: 2023-12-24 17:28:29.475831
4+ // Generated: 2023-12-24 18:34:14.416744
55// ----------------------------------------------------------
66// This file is an amalgamation of multiple different files.
77// You probably shouldn't edit it directly.
@@ -483,6 +483,9 @@ class Range {
483483 _size = static_cast <size_t >(std::distance (_first, _last));
484484 }
485485
486+ constexpr Range (Iter first, Iter last, size_t size) : _first(first), _last(last), _size(size)
487+ {}
488+
486489 template <typename T>
487490 constexpr Range (T& x) : _first(to_begin(x)), _last(to_end(x))
488491 {
@@ -513,11 +516,6 @@ class Range {
513516 return _size;
514517 }
515518
516- constexpr ssize_t ssize () const
517- {
518- return static_cast <ssize_t >(_size);
519- }
520-
521519 constexpr bool empty () const
522520 {
523521 return size () == 0 ;
@@ -544,6 +542,8 @@ class Range {
544542 else
545543 for (size_t i = 0 ; i < n; ++i)
546544 _first++;
545+
546+ _size -= n;
547547 }
548548 constexpr void remove_suffix (size_t n)
549549 {
@@ -553,17 +553,19 @@ class Range {
553553 else
554554 for (size_t i = 0 ; i < n; ++i)
555555 _last--;
556+
557+ _size -= n;
556558 }
557559
558560 constexpr Range subseq (size_t pos = 0 , size_t count = std::numeric_limits<size_t >::max())
559561 {
560562 if (pos > size ()) throw std::out_of_range (" Index out of range in Range::substr" );
561563
562- // todo we should probably support non random access iterators here too
563- ptrdiff_t scount = static_cast < ptrdiff_t >(count );
564- auto start = _first + static_cast < ptrdiff_t >(pos );
565- if ( std::distance (start, _last) < scount) return {start, _last};
566- return {start, start + scount} ;
564+ Range res = * this ;
565+ res. remove_prefix (pos );
566+ if (count < res. size ()) res. remove_suffix (res. size () - count );
567+
568+ return res ;
567569 }
568570
569571 constexpr decltype (auto ) front() const
@@ -578,7 +580,7 @@ class Range {
578580
579581 constexpr Range<reverse_iterator> reversed () const
580582 {
581- return {rbegin (), rend ()};
583+ return {rbegin (), rend (), _size };
582584 }
583585
584586 friend std::ostream& operator <<(std::ostream& os, const Range& seq)
@@ -7016,7 +7018,7 @@ void levenshtein_hyrroe2003_simd(Range<size_t*> scores, const detail::BlockPatte
70167018 else {
70177019 if constexpr (!std::is_same_v<VecType, uint64_t >) {
70187020 size_t min_dist = abs_diff (s1_lengths[result_index], s2.size ());
7019- size_t wraparound_score = std::numeric_limits<VecType>::max () + 1 ;
7021+ size_t wraparound_score = static_cast < size_t >( std::numeric_limits<VecType>::max () ) + 1 ;
70207022
70217023 score = (min_dist / wraparound_score) * wraparound_score;
70227024 VecType remainder = static_cast <VecType>(min_dist % wraparound_score);
@@ -8487,7 +8489,7 @@ void osa_hyrroe2003_simd(Range<size_t*> scores, const detail::BlockPatternMatchV
84878489 else {
84888490 if constexpr (!std::is_same_v<VecType, uint64_t >) {
84898491 size_t min_dist = abs_diff (s1_lengths[result_index], s2.size ());
8490- size_t wraparound_score = std::numeric_limits<VecType>::max () + 1 ;
8492+ size_t wraparound_score = static_cast < size_t >( std::numeric_limits<VecType>::max () ) + 1 ;
84918493
84928494 score = (min_dist / wraparound_score) * wraparound_score;
84938495 VecType remainder = static_cast <VecType>(min_dist % wraparound_score);
0 commit comments