Class: Arachni::BloomFilter
Overview
Lightweight Bloom-filter implementation.
It uses the return value of the #hash method of the given objects instead of the objects themselves.
This leads to decreased memory consumption and faster comparisons during look-ups.
Instance Method Summary collapse
-
#<<(obj) ⇒ Arachni::BloomFilter
(also: #add)
Self.
- #clear ⇒ Object
-
#delete(obj) ⇒ Arachni::BloomFilter
Self.
- #empty? ⇒ Boolean
- #include?(obj) ⇒ Bool
-
#initialize ⇒ BloomFilter
constructor
A new instance of BloomFilter.
- #size ⇒ Object
Constructor Details
#initialize ⇒ BloomFilter
Returns a new instance of BloomFilter.
29 30 31 |
# File 'lib/arachni/bloom_filter.rb', line 29 def initialize @hash = Hash.new( false ) end |
Instance Method Details
#<<(obj) ⇒ Arachni::BloomFilter Also known as: add
Returns self.
38 39 40 41 |
# File 'lib/arachni/bloom_filter.rb', line 38 def <<( obj ) @hash[obj.hash] = true self end |
#clear ⇒ Object
71 72 73 |
# File 'lib/arachni/bloom_filter.rb', line 71 def clear @hash.clear end |
#delete(obj) ⇒ Arachni::BloomFilter
Returns self.
49 50 51 52 |
# File 'lib/arachni/bloom_filter.rb', line 49 def delete( obj ) @hash.delete( obj.hash ) self end |
#empty? ⇒ Boolean
63 64 65 |
# File 'lib/arachni/bloom_filter.rb', line 63 def empty? @hash.empty? end |
#include?(obj) ⇒ Bool
59 60 61 |
# File 'lib/arachni/bloom_filter.rb', line 59 def include?( obj ) @hash[obj.hash] end |
#size ⇒ Object
67 68 69 |
# File 'lib/arachni/bloom_filter.rb', line 67 def size @hash.size end |