12.06.2015 Views

The Annoyance Filter.pdf - Fourmilab

The Annoyance Filter.pdf - Fourmilab

The Annoyance Filter.pdf - Fourmilab

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

§33 ANNOYANCE-FILTER FAST DICTIONARY 37<br />

}<br />

double d;<br />

is .read (reinterpret cast〈char ∗〉(&s), sizeof s);<br />

u int16 t filler ;<br />

is .read (reinterpret cast〈char ∗〉(&filler ), sizeof filler );<br />

/∗ Two byte filler for alignment ∗/<br />

if (s ≡ doubleSize ) {<br />

is .read (reinterpret cast〈char ∗〉(&d), sizeof d);<br />

}<br />

if ((s ≠ doubleSize ) ∨ (d ≠ fastDictionaryFloatingTest )) {<br />

cerr ≪ "Fast␣dictionary␣file␣" ≪ fname ≪<br />

"␣was␣created␣on␣a␣machine␣with␣incompatible␣floating␣point␣format." ≪ endl ;<br />

regen ( );<br />

goto fdlbail ;<br />

}<br />

is .read (reinterpret cast〈char ∗〉(&totalSize ), sizeof totalSize );<br />

is .read (reinterpret cast〈char ∗〉(&hashTableOffset ), sizeof hashTableOffset );<br />

is .read (reinterpret cast〈char ∗〉(&hashTableBuckets ), sizeof hashTableBuckets );<br />

is .read (reinterpret cast〈char ∗〉(&wordTableSize ), sizeof wordTableSize );<br />

#ifdef HAVE_MMAP<br />

dblock = reinterpret cast〈unsigned char ∗〉(dp) + is .tellg ( );<br />

#else<br />

u int32 t fdsize = (hashTableBuckets ∗ sizeof (u int32 t )) + wordTableSize ;<br />

try {<br />

dblock = new unsigned char[fdsize ];<br />

}<br />

catch(bad alloc)<br />

{<br />

cerr ≪ "Unable␣to␣allocate␣memory␣for␣fast␣dictionary.";<br />

return false ;<br />

}<br />

is .read (reinterpret cast〈char ∗〉(dblock ), fdsize );<br />

is .close ( );<br />

#endif<br />

hashTable = reinterpret cast 〈 u int32 t ∗> (dblock );<br />

wordTable = dblock + (hashTableBuckets ∗ sizeof (u int32 t ));<br />

if (verbose ) {<br />

cerr ≪ "Loaded␣fast␣dictionary␣from␣" ≪ fname ≪ "." ≪ endl ;<br />

}<br />

return true ; }

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

Saved successfully!

Ooh no, something went wrong!