12.06.2015 Views

The Annoyance Filter.pdf - Fourmilab

The Annoyance Filter.pdf - Fourmilab

The Annoyance Filter.pdf - Fourmilab

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

§32 ANNOYANCE-FILTER FAST DICTIONARY 35<br />

{<br />

#ifdef HAVE_MMAP<br />

if (dp ≠ Λ) {<br />

munmap(dp, fileLength );<br />

close (fileHandle );<br />

}<br />

#else<br />

if (dblock ≠ Λ) {<br />

delete dblock ;<br />

}<br />

#endif<br />

}<br />

bool load (const string fname );<br />

bool isDictionaryLoaded (void)<br />

{<br />

return dblock ≠ Λ;<br />

}<br />

double find (const string &target ) const;<br />

void describe (ostream &os = cout ) const<br />

{<br />

if (dblock ≠ Λ) {<br />

os ≪ "Total␣size␣of␣fast␣dictionary␣is␣" ≪ totalSize ≪ endl ;<br />

os ≪ "Hash␣table␣offset:␣" ≪ hashTableOffset ≪ endl ;<br />

os ≪ "Hash␣table␣buckets:␣" ≪ hashTableBuckets ≪ endl ;<br />

os ≪ "Word␣table␣size:␣" ≪ wordTableSize ≪ endl ;<br />

}<br />

else {<br />

os ≪ "No␣fast␣dictionary␣is␣loaded." ≪ endl ;<br />

}<br />

}<br />

static void exportDictionary (const dictionary &d, ostream &o);<br />

static void exportDictionary (const dictionary &d, const string fname );<br />

};

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!