int main() { int n,m,i,j,q,num,flag=0,falsecases=0; float probfalse; unsigned int x,y,z; scanf("%d",&m); n=14.43*m+1; for(i=0;i<m;i++) { scanf("%d",&numarr[i]); x=murmurhash3_32(numarr[i],n); y=fnv1(numarr[i],n); z=jenkins_hash(numarr[i],n); bitarr[x]=1; bitarr[y]=1; bitarr[z]=1; bitarr[hash4(x,y,z)]=1; bitarr[hash5(x,y,z)]=1; bitarr[hash6(x,y,z)]=1; bitarr[hash7(x,y,z)]=1; bitarr[hash8(x,y,z)]=1; bitarr[hash9(x,y,z)]=1; bitarr[hash10(x,y,z)]=1; } //printf("Enter no. of queries: "); scanf("%d",&q); for(i=0;i<q;i++) { //printf("Enter value to check: "); scanf("%d",&num); x=murmurhash3_32(num,n); y=fnv1(num,n); z=jenkins_hash(num,n); if(bitarr[x]==1 && bitarr[y]==1 && bitarr[z]==1 && bitarr[hash4(x,y,z)]==1 && bitarr[hash5(x,y,z)]==1 && bitarr[hash6(x,y,z)]==1 && bitarr[hash7(x,y,z)]==1 && bitarr[hash8(x,y,z)]==1 && bitarr[hash9(x,y,z)]==1 && bitarr[hash10(x,y,z)]==1) found++; else notfound++; //printf("Element not in set\n"); } printf("NUMBER OF FLASE OUTPUTS: %d\n",falsecases); probfalse=(falsecases*100)/q; printf("PROBABILITY OF FLASE OUTPUTS: %.2f %\n",probfalse); printf("No. actually there: %d\nNo. actually not there: %d\n",found,notfound); return 0; }
bool ProtobufConnection::RegisterService(google::protobuf::Service *service) { if (handler_table_.get() == NULL) { handler_table_.reset(new HandlerTable); } const google::protobuf::ServiceDescriptor *service_descriptor = service->GetDescriptor(); for (int i = 0; i < service_descriptor->method_count(); ++i) { const google::protobuf::MethodDescriptor *method = service_descriptor->method(i); const google::protobuf::Message *request = &service->GetRequestPrototype(method); const google::protobuf::Message *response = &service->GetResponsePrototype(method); const string &method_name = method->full_name(); const uint64 method_fingerprint = hash8(method_name); HandlerTable::const_iterator it = handler_table_->find(method_fingerprint); CHECK(it == handler_table_->end()) << " unfortunately, the method name: " << method_name << " is conflict with another name after hash(" << method_fingerprint << ") please change."; handler_table_->insert(make_pair( method_fingerprint, boost::bind( HandleService, service, method, request, response, _1, _2))); } }