Commit 7a3b20a7 authored by Mathieu Giraud's avatar Mathieu Giraud

core/tools.cpp: spaced_int(), directly computes an int index from an int* sequence

parent 2c52a4e6
......@@ -49,6 +49,34 @@ string spaced(const string &input, const string &seed) {
int spaced_int(int *input, const string &seed) {
#ifdef NO_SPACED_SEEDS
return input ;
#endif
int j = 0 ;
// cout << input << endl << seed << endl ;
// assert(input.length() == seed.length()); // length is not equal, pointer
int index_word = 0;
for (size_t i = 0; i < seed.length(); i++)
if (seed[i] == SEED_YES)
index_word = (index_word << 2) | input[i] ;
#ifdef DEBUG_SPACED
cout << input << " => |" << index_word << "|" << endl ;
#endif
return index_word;
}
string string_of_int(int number)
{
stringstream ss;
......
......@@ -32,6 +32,7 @@ int seed_weight(const string &seed);
*/
string spaced(const string &input, const string &seed);
int spaced_int(int *input, const string &seed);
/**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment