Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 26 lines (20 sloc) 0.587 kb
dffe7c3 @igrigorik Import, fix, cleanup, extend.
authored
1 #!/usr/bin/env ruby
cdf8b16 @igrigorik update examples
authored
2 require 'bloomfilter-rb'
dffe7c3 @igrigorik Import, fix, cleanup, extend.
authored
3
4 WORDS = %w(duck penguin bear panda)
5 TEST = %w(penguin moose racooon)
6
cdf8b16 @igrigorik update examples
authored
7 bf = BloomFilter::Native.new(:size => 100, :hashes => 2, :seed => 1, :bucket => 3, :raise => false)
dffe7c3 @igrigorik Import, fix, cleanup, extend.
authored
8
9 WORDS.each { |w| bf.insert(w) }
10 TEST.each do |w|
11 puts "#{w}: #{bf.include?(w)}"
12 end
13
14 bf.stats
15
16 # penguin: true
17 # moose: false
18 # racooon: false
19 #
a02f0a6 @igrigorik added gemspec + updated examples
authored
20 # Number of filter buckets (m): 100
21 # Number of bits per buckets (b): 1
dffe7c3 @igrigorik Import, fix, cleanup, extend.
authored
22 # Number of filter elements (n): 4
23 # Number of filter hashes (k) : 4
a02f0a6 @igrigorik added gemspec + updated examples
authored
24 # Raise on overflow? (r) : false
dffe7c3 @igrigorik Import, fix, cleanup, extend.
authored
25 # Predicted false positive rate = 0.05%
Something went wrong with that request. Please try again.