#include <SequenceReaderFilter.h>
Collaboration diagram for StringHash:

Public Member Functions | |
| void | makeBins (int numBins) |
| size_t | makeNumBins (void) const |
| void | makeBins (void) |
| bool | isPresent (const string &s) |
| size_t | max (void) const |
| double | loadFactor (void) const |
| double | effic (void) const |
| size_t | numBins (void) const |
Public Attributes | |
| HashFunctor | H_ |
Private Attributes | |
| size_t | numBins_ |
| vector< vector< string * > > | bins_ |
Definition at line 59 of file SequenceReaderFilter.h.
| void StringHash::makeBins | ( | int | numBins | ) |
Definition at line 372 of file SequenceReaderFilter.cpp.
References bins_, H_, and numBins_.
Referenced by SequenceReaderFilter::readFilterNames().
00373 { 00374 // cout << "Hashing " << size() << " sequence names into " 00375 // << numBins << " bins" << endl; 00376 00377 numBins_ = numBins; 00378 bins_.clear(); 00379 bins_.resize(numBins); 00380 for (vector<string>::const_iterator i(begin());i!=end();i++) 00381 { 00382 (bins_[ H_(i->c_str()) % numBins ]).push_back((string*)&(*i)); 00383 // (bins_[ H_(i->c_str()) % numBins ]).push_back(); 00384 // (bins_[ H_(i->c_str()) % numBins ]).back() = i; 00385 } 00386 } // StringHash
Here is the caller graph for this function:

| size_t StringHash::makeNumBins | ( | void | ) | const |
Definition at line 388 of file SequenceReaderFilter.cpp.
Referenced by makeBins().
00389 { 00390 static const size_t primes[] = { 103,1009,7013,10007,88883,100043 }; 00391 static const int numPrimes = 6; 00392 size_t minSize = size() + (size()>>3); // current size +12.5% 00393 for (int i(0);i<numPrimes;i++) 00394 if (minSize<primes[i]) return primes[i]; 00395 minSize |=1; // make sure it's odd 00396 if (minSize%5==0) minSize+=2; // make sure it's not a mult of 5 00397 // (cos then hash fn gives lousy performance) 00398 return minSize; 00399 }
Here is the caller graph for this function:

| void StringHash::makeBins | ( | void | ) | [inline] |
Definition at line 68 of file SequenceReaderFilter.h.
References makeNumBins().
00069 { 00070 makeBins(makeNumBins()); 00071 }
Here is the call graph for this function:

| bool StringHash::isPresent | ( | const string & | s | ) | [inline] |
Definition at line 73 of file SequenceReaderFilter.h.
References bins_, H_, and numBins_.
Referenced by SequenceReaderFilter::findSequence().
00074 { 00075 vector<string*>* myBin = &bins_[ H_(s.c_str()) % numBins_ ]; 00076 for (vector<string*>::iterator i(myBin->begin()); i!= myBin->end();++i) 00077 if (**i == s ) return true; 00078 return false; 00079 }
Here is the caller graph for this function:

| size_t StringHash::max | ( | void | ) | const [inline] |
Definition at line 81 of file SequenceReaderFilter.h.
References bins_.
Referenced by effic().
00082 { 00083 int max(0); 00084 for (vector<vector<string*> >::const_iterator i(bins_.begin()); i!= bins_.end(); i++ ) 00085 if (i->size()>max) max=i->size(); 00086 return max; 00087 }
Here is the caller graph for this function:

| double StringHash::loadFactor | ( | void | ) | const [inline] |
Definition at line 89 of file SequenceReaderFilter.h.
References numBins_.
Referenced by effic().
00089 { return size()/numBins_; }
Here is the caller graph for this function:

| double StringHash::effic | ( | void | ) | const [inline] |
Definition at line 91 of file SequenceReaderFilter.h.
References loadFactor(), and max().
00091 { return max()/loadFactor(); }
Here is the call graph for this function:

| size_t StringHash::numBins | ( | void | ) | const [inline] |
Definition at line 93 of file SequenceReaderFilter.h.
References numBins_.
00093 { return numBins_; }
size_t StringHash::numBins_ [private] |
Definition at line 97 of file SequenceReaderFilter.h.
Referenced by isPresent(), loadFactor(), makeBins(), and numBins().
vector<vector<string*> > StringHash::bins_ [private] |
Definition at line 98 of file SequenceReaderFilter.h.
Referenced by isPresent(), makeBins(), and max().
1.5.2