Skip to content
This repository was archived by the owner on Jul 30, 2024. It is now read-only.
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions pybloom/pybloom.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,23 @@ def add(self, key, skip_check=False):
else:
return True

def add_return_bits(self, key):
""" Adds a key to this bloom filter and return a list of bit indices set."""
bits_per_slice = self.bits_per_slice
hashes = self.make_hashes(key)
if self.count > self.capacity:
raise IndexError("BloomFilter is at capacity")

offset = 0
indices = []

for k in hashes:
self.bitarray[offset + k] = True
indices.append(offset + k)
offset += bits_per_slice

return indices

def copy(self):
"""Return a copy of this bloom filter.
"""
Expand Down