jasondavies / bloomfilter.js

JavaScript bloom filter using FNV for fast hashing
http://www.jasondavies.com/bloomfilter/
BSD 3-Clause "New" or "Revised" License
759 stars 79 forks source link

is it possible to calculate index? #32

Closed thearthouse closed 3 years ago

thearthouse commented 3 years ago

like ['ant', 'bison'].indexOf('ant')

0

jasondavies commented 3 years ago

Can you explain in a bit more detail?

thearthouse commented 3 years ago

in normal array beasts = ['ant', 'bison', 'camel', 'duck']; we can get index of elements like this beasts.indexOf('bison') beasts.indexOf('duck')

in bloom lets say we add this elements 'ant', 'bison', 'camel', 'duck' how to calculate 'bison' index or is it possible ?

thearthouse commented 3 years ago

it possible ?

jasondavies commented 3 years ago

In a bloom filter, a given element doesn't necessarily have single index. The closest equivalent would be to get the positions in the bit vector (which you can do using .locations() in this library. If you want to know about how bloom filters work, I made an interactive visualisation here.