当前位置: 首页>>代码示例>>C++>>正文


C++ BloomFilter::contains方法代码示例

本文整理汇总了C++中BloomFilter::contains方法的典型用法代码示例。如果您正苦于以下问题:C++ BloomFilter::contains方法的具体用法?C++ BloomFilter::contains怎么用?C++ BloomFilter::contains使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在BloomFilter的用法示例。


在下文中一共展示了BloomFilter::contains方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: main

int main(int argc, char *argv[]) {
  if (argc < 2) {
    cout << "usage: BloomFilterTest <bits>\n where bits is the bit count per variable" << endl;
    return 1;
  }
  unsigned int bits = atoi(argv[1]), wrong = 0, counter = 0;
  cout << "bits=" << bits << endl;
  int limit = 1000000;

  // take bits as parameter
  BloomFilter BF (limit, (size_t) bits, (uint32_t) time(NULL));



  // insert ints 0,...,1M
  for (int j=0; j<limit;j++)
    BF.insert(j);

  // assert 0,...,1M
  for (int j=0; j<limit;j++)
    assert(BF.contains(j));
  
  for (int j=limit; j < 2*limit ;j++) {
    if (BF.contains(j))
      wrong++;
    counter++;
  }

  Kmer::set_k(31);
  Kmer km("ACGTACGTACGTACGTACGTACGTACGTACG");
  printf("sizeof(Kmer) == %d\n", (int) sizeof(Kmer));
  printf("sizeof(km) == %d\n", (int) sizeof(km));
  printf("pointer cast == %p\n", (const void*) &km);

  cout << "Count == " << BF.count() << endl;
  cout << "Contains(km) == " << BF.contains(km) << endl;
  cout << "Insert(km) == " << BF.insert(km) << endl;
  BF.count();
  cout << "Contains(km) == " << BF.contains(km) << endl;
  assert(BF.contains(km));
  
  BF.count();
  Kmer km2("ACGTACGTACGTACGTACGTACGTACGTAGG"); // AGG vs ACG in the end
  cout << "Contains(km2) == " << BF.contains(km2) << endl;
  cout << "Insert(km2) == " << BF.insert(km2) << endl;
  cout << "Contains(km2) == " << BF.contains(km2) << endl;
  assert(BF.contains(km2));

  BF.count();
  
  FILE *fp = fopen("testBloom.bf", "wb");
  BF.WriteBloomFilter(fp);
  fclose(fp);



  // compute false positive rate
  printf("False positive ratio: %.6f\n", wrong / (0.0 + counter));
  cout << &argv[0][2] << " completed successfully" << endl;
}
开发者ID:,项目名称:,代码行数:60,代码来源:

示例2: main

int main(){
  BloomFilter *bf = new BloomFilter(1024);

  string st1 = "this";
  string st2 = "is";
  string st3 = "a";
  string st4 = "test";

  bf->add(st1.c_str(),st1.length());
  bf->add(st2.c_str(),st2.length());
  cout<<"bloom filter contains \""<<st1 <<"\"" <<":"<< bf->contains(st1.c_str(), st1.length()) << endl;
  cout<<"bloom filter contains \""<<st2 <<"\"" <<":"<< bf->contains(st2.c_str(), st2.length()) << endl;
  cout<<"bloom filter contains \""<<st3 <<"\"" <<":"<< bf->contains(st3.c_str(), st3.length()) << endl;
  cout<<"bloom filter contains \""<<st4 <<"\"" <<":"<< bf->contains(st4.c_str(), st4.length()) << endl;


}
开发者ID:newwaylw,项目名称:NLPTools,代码行数:17,代码来源:main.cpp

示例3: querySeqr

void querySeqr(BloomFilter & myFilter, const string & seq, size_t & fHit) {
    if (seq.size() < opt::kmerLen) return;
    uint64_t fhVal, rhVal;
    if(myFilter.contains(seq.c_str(), fhVal, rhVal)) {
        #ifdef _OPENMP
        #pragma omp atomic
        #endif
        ++fHit;
    }
    for (size_t i = 1; i < seq.size() - opt::kmerLen + 1; i++) {
        if(myFilter.contains(fhVal, rhVal, seq[i-1], seq[i+opt::kmerLen-1])) {
            #ifdef _OPENMP
            #pragma omp atomic
            #endif
            ++fHit;
        }
    }
}
开发者ID:bcgsc,项目名称:ntHash,代码行数:18,代码来源:nttest.cpp

示例4: querySeq

void querySeq(BloomFilter & myFilter, const string & seq, size_t & fHit) {
    if (seq.size() < opt::kmerLen) return;
    for (size_t i = 0; i < seq.size() - opt::kmerLen + 1; i++) {
        if(myFilter.contains(seq.c_str()+i)) {
            #ifdef _OPENMP
            #pragma omp atomic
            #endif
            ++fHit;
        }
    }
}
开发者ID:bcgsc,项目名称:ntHash,代码行数:11,代码来源:nttest.cpp


注:本文中的BloomFilter::contains方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。