Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit d27a73d

Browse files
author
werewolf
committed
change abc
1 parent c1f1f98 commit d27a73d

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

‎src/algorithm/DNA_Analyzer.cc‎

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,19 +16,18 @@ void DNA_Analyzer::RabinKarpAlgorithm(const std::filesystem::path& path_1, const
1616
std::vector<std::size_t> hash_samp(samp_size + 1, 0);
1717
CalculateMassHash(samp, hash_samp, samp_size, exp);
1818

19-
for (std::size_t i = 0; i + samp_size - 1 < text_size; ++i) {
20-
std::size_t hash_curr = (hash_text[i + samp_size] + rk_mod - hash_text[i]) % rk_mod;
21-
if ((hash_curr == (hash_samp[samp_size] * exp[i] % rk_mod)) && text.substr(i, samp_size) == samp) {
22-
std::cout << i << " ";
19+
for (std::size_t idx = 0; idx + samp_size - 1 < text_size; ++idx) {
20+
std::size_t hash_curr = (hash_text[idx + samp_size] + rk_mod - hash_text[idx]) % rk_mod;
21+
if ((hash_curr == (hash_samp[samp_size] * exp[idx] % rk_mod)) && text.substr(idx, samp_size) == samp) {
22+
std::cout << idx << " ";
2323
}
2424
}
2525
std::cout << std::endl;
2626
}
2727

2828
void DNA_Analyzer::CalculateMassHash(const std::string &src, std::vector<std::size_t> &hash, const std::size_t size, const std::vector<std::size_t> &exp) {
29-
static std::unordered_map<char, std::size_t> code{{'A', 1}, {'C', 2}, {'G', 3}, {'T', 4}};
3029
for (std::size_t i = 0; i < size; ++i) {
31-
hash[i + 1] = (hash[i] + code[src[i]] * exp[i]) % rk_mod;
30+
hash[i + 1] = (hash[i] + src[i] * exp[i]) % rk_mod;
3231
}
3332
}
3433

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /