11// Licensed under the MIT License <http://opensource.org/licenses/MIT>.
22// SPDX-License-Identifier: MIT
33// RapidFuzz v1.0.2
4- // Generated: 2022-09-03 19:36:32.122526
4+ // Generated: 2022-09-03 21:47:43.168879
55// ----------------------------------------------------------
66// This file is an amalgamation of multiple different files.
77// You probably shouldn't edit it directly.
88// ----------------------------------------------------------
99#ifndef RAPIDFUZZ_AMALGAMATED_HPP_INCLUDED
1010#define RAPIDFUZZ_AMALGAMATED_HPP_INCLUDED
1111
12+ #include < algorithm>
1213#include < cmath>
1314
1415#include < cassert>
@@ -34,11 +35,10 @@ struct GrowingHashmap {
3435 using size_type = unsigned int ;
3536
3637private:
37- static constexpr value_type _empty_val = value_type();
3838 static constexpr size_type min_size = 8 ;
3939 struct MapElem {
4040 key_type key;
41- value_type value = _empty_val ;
41+ value_type value = value_type() ;
4242 };
4343
4444 int used;
@@ -95,7 +95,7 @@ struct GrowingHashmap {
9595
9696 value_type get (key_type key) const noexcept
9797 {
98- if (m_map == NULL ) return _empty_val ;
98+ if (m_map == NULL ) return value_type () ;
9999
100100 return m_map[lookup (key)].value ;
101101 }
@@ -106,7 +106,7 @@ struct GrowingHashmap {
106106
107107 size_t i = lookup (key);
108108
109- if (m_map[i].value == _empty_val ) {
109+ if (m_map[i].value == value_type () ) {
110110 /* resize when 2/3 full */
111111 if (++fill * 3 >= (mask + 1 ) * 2 ) {
112112 grow ((used + 1 ) * 2 );
@@ -136,12 +136,12 @@ struct GrowingHashmap {
136136 size_t hash = static_cast <size_t >(key);
137137 size_t i = hash & static_cast <size_t >(mask);
138138
139- if (m_map[i].value == _empty_val || m_map[i].key == key) return i;
139+ if (m_map[i].value == value_type () || m_map[i].key == key) return i;
140140
141141 size_t perturb = hash;
142142 while (true ) {
143143 i = (i * 5 + perturb + 1 ) & static_cast <size_t >(mask);
144- if (m_map[i].value == _empty_val || m_map[i].key == key) return i;
144+ if (m_map[i].value == value_type () || m_map[i].key == key) return i;
145145
146146 perturb >>= 5 ;
147147 }
@@ -160,7 +160,7 @@ struct GrowingHashmap {
160160 mask = newSize - 1 ;
161161
162162 for (int i = 0 ; used > 0 ; i++)
163- if (oldMap[i].value != _empty_val ) {
163+ if (oldMap[i].value != value_type () ) {
164164 size_t j = lookup (oldMap[i].key );
165165
166166 m_map[j].key = oldMap[i].key ;
@@ -382,9 +382,9 @@ struct BitMatrix {
382382} // namespace detail
383383} // namespace rapidfuzz
384384
385- #include < iostream>
386385#include < iterator>
387386#include < limits>
387+ #include < ostream>
388388#include < stdexcept>
389389#include < vector>
390390
@@ -2249,6 +2249,20 @@ struct CachedSimilarityBase : public CachedNormalizedMetricBase<T> {
22492249namespace rapidfuzz {
22502250namespace detail {
22512251
2252+ template <typename IntType>
2253+ struct RowId {
2254+ IntType val = -1 ;
2255+ friend bool operator ==(const RowId& lhs, const RowId& rhs)
2256+ {
2257+ return lhs.val == rhs.val ;
2258+ }
2259+
2260+ friend bool operator !=(const RowId& lhs, const RowId& rhs)
2261+ {
2262+ return !(lhs == rhs);
2263+ }
2264+ };
2265+
22522266/*
22532267 * based on the paper
22542268 * "Linear space string correction algorithm using the Damerau-Levenshtein distance"
@@ -2262,20 +2276,7 @@ int64_t damerau_levenshtein_distance_zhao(Range<InputIt1> s1, Range<InputIt2> s2
22622276 IntType maxVal = static_cast <IntType>(std::max (len1, len2) + 1 );
22632277 assert (std::numeric_limits<IntType>::max () > maxVal);
22642278
2265- struct RowId {
2266- IntType val = -1 ;
2267- bool operator ==(const RowId& other)
2268- {
2269- return val == other.val ;
2270- }
2271-
2272- bool operator !=(const RowId& other)
2273- {
2274- return !(*this == other);
2275- }
2276- };
2277-
2278- HybridGrowingHashmap<typename Range<InputIt1>::value_type, RowId> last_row_id;
2279+ HybridGrowingHashmap<typename Range<InputIt1>::value_type, RowId<IntType>> last_row_id;
22792280 size_t size = static_cast <size_t >(s2.size () + 2 );
22802281 assume (size != 0 );
22812282 std::vector<IntType> FR_arr (size, maxVal);
@@ -2489,7 +2490,7 @@ struct CachedDamerauLevenshtein : public detail::CachedDistanceBase<CachedDamera
24892490 template <typename InputIt2>
24902491 int64_t maximum (detail::Range<InputIt2> s2) const
24912492 {
2492- return std::max (static_cast <int64_t >(s1.size ()), s2.size ());
2493+ return std::max (static_cast <ptrdiff_t >(s1.size ()), s2.size ());
24932494 }
24942495
24952496 template <typename InputIt2>
@@ -3292,6 +3293,7 @@ class LCSseq : public SimilarityBase<LCSseq> {
32923293} // namespace detail
32933294} // namespace rapidfuzz
32943295
3296+ #include < algorithm>
32953297#include < cmath>
32963298#include < limits>
32973299
@@ -3379,7 +3381,7 @@ struct CachedLCSseq : detail::CachedSimilarityBase<CachedLCSseq<CharT1>> {
33793381 template <typename InputIt2>
33803382 int64_t maximum (detail::Range<InputIt2> s2) const
33813383 {
3382- return std::max (static_cast <int64_t >(s1.size ()), s2.size ());
3384+ return std::max (static_cast <ptrdiff_t >(s1.size ()), s2.size ());
33833385 }
33843386
33853387 template <typename InputIt2>
@@ -3481,7 +3483,7 @@ template <typename InputIt1, typename InputIt2>
34813483int64_t indel_similarity (InputIt1 first1, InputIt1 last1, InputIt2 first2, InputIt2 last2,
34823484 int64_t score_cutoff = 0.0 )
34833485{
3484- return detail::Indel::normalized_distance (first1, last1, first2, last2, score_cutoff);
3486+ return detail::Indel::similarity (first1, last1, first2, last2, score_cutoff);
34853487}
34863488
34873489template <typename Sentence1, typename Sentence2>
0 commit comments