An address is an integer. Are you doing something like return &x instead of return x?
An address is an integer. Are you doing something like return &x instead of return x?
No I'm doing return x
and then it goes to the called function from before and returnsCode:for (int i = 0; i < String.size(); i++){ mystring = String.at(i); std::cout<<mystring<<std::endl; mystringmap(mystring, tablesize); std::cout << "string value in bloom "<<stringvalue;
"stringvalue"
I guess the question is why do you think you're getting an address. Based on the code you posted above, mystringmap is supposed to return a number. Why do you think it's an address instead of the number you want?
Well, I don't think it is passing anything now, at the beginning of my function I initialize it to 0 and after the second function call it prints 0 still. I am having trouble figuring out why..
There's a difference between
andCode:mystringmap(mystring, tablesize);
in that one of them does something and one of them does nothing.Code:stringvalue = mystringmap(mystring, tablesize);
Wow, it's the easiest things that waste the most time.
One more stupid question, I'm trying to set the value of the index to true in a vector <bool> but I am having trouble getting the syntax to work, can anyone help set me straight with that?
Well my current attempt is this:
But I think I'm getting farther away.Code:std::vector <bool> truthtable = valuei.at(index);
Are you trying to do the entire vector at once, or just a particular element of the vector?
Just a value at a time, I have it in a for loop that increments through all strings and hash functions.
Then just assign to that value.
Code:truthtable[n] = true or false;
This is supposed to take the return vector from search of of Boolean value and store into Boolean vector in main.Code:vector <bool> bloomprediction = bloom.searchhash();
When it gets to this line it says "Error, vector <bool> iterator is dereferencable"
Header definition
Private memberCode:std::vector <bool> searchhash();
Return valueCode:std::vector <bool> truthtable, stringtruth;
Code:return stringtruth;
do you need something else?
Code:#include <cmath> #include <complex> bool euler_flip(bool value) { return std::pow ( std::complex<float>(std::exp(1.0)), std::complex<float>(0, 1) * std::complex<float>(std::atan(1.0) *(1 << (value + 2))) ).real() < 0; }
I changed the vector to int instead of bool because I was seeing if that was the problem. I know the function call works within searhhash(), and truthtable works, but it freezes up and says out of subscript on the function call of search hash from above. Here is the function.
Let me know if there is another part of the code needed to helpCode:std::vector <int> bloomfilter::searchhash(){ int index = 0; std::vector <int> stringtruth; int size = String2.size(); for (int i = 0; i < size; i++){ stringtruth.resize(i); mystring2 = String2.at(i); stringvalue = mystringmap(mystring2, tablesize); for (index = 0; index < hashfunctions; index++){ //for loop to incremement through hash functions int insertvalue2 = ((static_cast<long long>(A.at(index)) * stringvalue * B.at(index)) %primenumber) %tablesize; if (truthtable[insertvalue2] == 1){ index++; stringtruth[i] = 1; std::cout << "truth of " << stringtruth[i] << "is: " << std::endl; std::cout << String2[i] << " is true! " << std::endl; } else { stringtruth[i] = 0; std::cout << "truth of " << stringtruth[i] << "is: " << std::endl; std::cout << String2[i] << " is false. " << std::endl; } } } return stringtruth; }