Skip to content

Commit

Permalink
improve docs
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinNowak committed Nov 30, 2014
1 parent 0b38d0f commit af79883
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
bloom [![Build Status](https://travis-ci.org/MartinNowak/bloom.svg?branch=master)](https://travis-ci.org/MartinNowak/bloom) [![Coverage Status](https://img.shields.io/coveralls/MartinNowak/bloom.svg)](https://coveralls.io/r/MartinNowak/bloom?branch=master)
=====

A basic bloom filter.
A basic bloom filter. [Documentation](https://MartinNowak.github.io/bloom)
19 changes: 10 additions & 9 deletions src/dawg/bloom.d
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,12 @@ module dawg.bloom;
import core.bitop;

/**
* Basic bloom filter. This is a very fast data structure to test set
* membership of a key. It might give false positive results but
* never false negative.
* Basic bloom filter. This is a very fast data structure to test set membership
* of a key. It might give false positive results but never false negative
* ones. So if a key was inserted testing for the same key is guaranteed to be
* true, but testing might also be true even though a key was never inserted.
*
* Params:
* BitsPerEntry = Set the number of bits allocated per entry.
* CheapHash = Use a faster but less good hash function.
*
* Asymptotic false-positive rates for different BitsPerEntry:
* Asymptotic false-positive rates for different BitsPerEntry settings.
*
* 1 - 63.2%
* 2 - 39.3%
Expand All @@ -34,6 +31,10 @@ import core.bitop;
* 7 - 3.47%
* 8 - 2.15%
* 9 - 1.33%
*
* Params:
* BitsPerEntry = Set the number of bits allocated per entry.
* CheapHash = Use a faster but less good hash function.
*/
struct BloomFilter(size_t BitsPerEntry=4, bool CheapHash=true) if (BitsPerEntry > 0)
{
Expand Down Expand Up @@ -113,7 +114,7 @@ private:
// The asymptotic false positive rate is (1 - e^(-k*n/m))^k.
enum M_N = BitsPerEntry;
enum K = cast(size_t)(M_N * LN2 + 0.5);
enum real LN2 = 0x1.62e42fefa39ef35793c7673007e5fp-1L; /** ln 2 = 0.693147... */
enum real LN2 = 0x1.62e42fefa39ef35793c7673007e5fp-1L; /* ln 2 = 0.693147... */

void hash(size_t key, ref uint[K] result) const
{
Expand Down

0 comments on commit af79883

Please sign in to comment.