diff options
author | Jan Holthuis <jan.holthuis@ruhr-uni-bochum.de> | 2020-11-24 17:45:10 +0100 |
---|---|---|
committer | Jan Holthuis <jan.holthuis@ruhr-uni-bochum.de> | 2020-11-24 18:11:12 +0100 |
commit | 42c3e8e103d53172486aec5bb050dbee68dd8a54 (patch) | |
tree | 2fa6ca6fc7a8ebcd0fc568106e5c9a3e6377c381 | |
parent | 03c54adb9a59c199b5998ca6cac6a431f01a69ee (diff) |
util/lcs: Use int instead of size_t
Fixes these warnings:
src\util\lcs.h(13): warning C4267: 'argument': conversion from 'size_t' to 'int', possible loss of data
src\util\lcs.h(18): warning C4267: 'argument': conversion from 'size_t' to 'int', possible loss of data
src\util\lcs.h(22): warning C4267: 'argument': conversion from 'size_t' to 'int', possible loss of data
src\util\lcs.h(23): warning C4267: 'argument': conversion from 'size_t' to 'int', possible loss of data
src\util\lcs.h(24): warning C4267: 'argument': conversion from 'size_t' to 'int', possible loss of data
src\util\lcs.h(25): warning C4267: 'argument': conversion from 'size_t' to 'int', possible loss of data
src\util\lcs.h(29): warning C4267: 'argument': conversion from 'size_t' to 'int', possible loss of data
src\util\lcs.h(33): warning C4267: 'argument': conversion from 'size_t' to 'int', possible loss of data
-rw-r--r-- | src/util/lcs.h | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/src/util/lcs.h b/src/util/lcs.h index 68ff172e59..58101e989f 100644 --- a/src/util/lcs.h +++ b/src/util/lcs.h @@ -1,24 +1,24 @@ -#include <cstring> - #include <QString> +#include <QVector> +#include <cstring> // Returns the longest common substring shared between a and b. Does not support // finding multiple longest common substrings. inline QString LCS(const QString& a, const QString& b) { - const size_t m = a.size(); - const size_t n = b.size(); - const size_t rows = m + 1; - const size_t cols = n + 1; + const int m = a.size(); + const int n = b.size(); + const int rows = m + 1; + const int cols = n + 1; - QVector<QVector<size_t> > M(rows); - size_t longest = 0; - size_t longest_loc = 0; + QVector<QVector<int> > M(rows); + int longest = 0; + int longest_loc = 0; - for (size_t i = 0; i < rows; ++i) { - M[i] = QVector<size_t>(cols, 0); + for (int i = 0; i < rows; ++i) { + M[i] = QVector<int>(cols, 0); } - for (size_t i = 1; i <= m; ++i) { - for (size_t j = 1; j <= n; ++j) { + for (int i = 1; i <= m; ++i) { + for (int j = 1; j <= n; ++j) { if (a.at(i-1) == b.at(j-1)) { M[i][j] = M[i-1][j-1] + 1; if (M[i][j] > longest) { |