Calling all code monkeys!
#1
GWAKS- Tech Geekifier
Thread Starter
Join Date: Oct 2000
Location: Hampton, VA
Posts: 2,109
Likes: 0
Received 0 Likes
on
0 Posts
Calling all code monkeys!
I have a bit of a problem with a bloom filter I"m working on, all help would be appreciated, here's the code and errors I'm getting so far:
Originally Posted by code
#include <iostream>
#include <string>
using namespace std;
unsigned long elfhash(char* key)
{
unsigned long h=0,g;
while(*key){
h=(h<<4)+*key++;
if((g=h&0xF0000000L))
h^=g>>24;
h&=~g;
}
return h;
}
int main(void){
int bloom[16];
int h1, h2, h3;
unsigned long h;
char key[15];
while(cin){
cin.get(key);
h = elfhash(key);
h1 = h%15;
h2 = (h%13)+2;
h3 = (h%11)+3;
cout << key << " " << h1 <<","<<h2<<","<<h3;
}
return 0;
}
#include <string>
using namespace std;
unsigned long elfhash(char* key)
{
unsigned long h=0,g;
while(*key){
h=(h<<4)+*key++;
if((g=h&0xF0000000L))
h^=g>>24;
h&=~g;
}
return h;
}
int main(void){
int bloom[16];
int h1, h2, h3;
unsigned long h;
char key[15];
while(cin){
cin.get(key);
h = elfhash(key);
h1 = h%15;
h2 = (h%13)+2;
h3 = (h%11)+3;
cout << key << " " << h1 <<","<<h2<<","<<h3;
}
return 0;
}
Originally Posted by errors
[XXXXX@XXXXX final]$ bloom.cpp: In function `int main()':
> bloom.cpp:26: no matching function for call to `std::basic_istream& std::basic_istream::get(_CharT&) [with _CharT = char, _Traits =
-bash: char,: No such file or directory
std::char_traits]
> bloom.cpp:26: no matching function for call to `std::basic_istream& std::basic_istream::get(_CharT&) [with _CharT = char, _Traits =
-bash: char,: No such file or directory
std::char_traits]
__________________
-Harry
AIM: NDcissive
CRX and Pre '92 Civic, Engine Tech and Tuning, & Track and Autocross Forum Mod
-Harry
AIM: NDcissive
CRX and Pre '92 Civic, Engine Tech and Tuning, & Track and Autocross Forum Mod
#2
Card carrying badass
Join Date: Mar 2004
Location: Little Rock, AR
Posts: 768
Likes: 0
Received 0 Likes
on
0 Posts
It seems to be pissed off because it is trying to understand what you want it to do when you are trying to cout the array. I didn't look at the code for very long. Are you trying to cout the values that are in the array or just a specific one? While it does seem weird that it throws an error (I thought it would cout the memory address of the array) I think I can see why it's doing it.
#3
GWAKS- Tech Geekifier
Thread Starter
Join Date: Oct 2000
Location: Hampton, VA
Posts: 2,109
Likes: 0
Received 0 Likes
on
0 Posts
Thanks for the reply, but I got it fixed, my brain just needed a rest.
The error was coming from trying to pass a string to the function that wanted the values passed as a referenced character array. I just worked some things around and made my cin value a character array and all's well.
The function's job is to convert a string into unsigned long integers to be hashed and stored in a bloom filter. This program just needed to cout the values gotten from hashing on it, to find out which bits are "turned on".
More info on bloom filters.
The error was coming from trying to pass a string to the function that wanted the values passed as a referenced character array. I just worked some things around and made my cin value a character array and all's well.
The function's job is to convert a string into unsigned long integers to be hashed and stored in a bloom filter. This program just needed to cout the values gotten from hashing on it, to find out which bits are "turned on".
More info on bloom filters.
__________________
-Harry
AIM: NDcissive
CRX and Pre '92 Civic, Engine Tech and Tuning, & Track and Autocross Forum Mod
-Harry
AIM: NDcissive
CRX and Pre '92 Civic, Engine Tech and Tuning, & Track and Autocross Forum Mod
Thread
Thread Starter
Forum
Replies
Last Post
accordh22
Engine Swaps, Tech & Tuning
11
12-31-2003 04:06 PM