views:

152

answers:

2

i am looking for a specific data structure, but i forgot its name. if i knew the name it would be trivial, i would just look it up in wikipedia :)

basically, it is like a set - except you cannot iterate it.

you put some values in it, lets say 80k zip codes.

then you can test if a given string is definately NOT a zip code, but you will eventually get false positives if you insert too many zip codes.

the memory consumption of this structure is quite small.

what is its name, and is there an implementation in java?

+6  A: 

I believe you are looking for a Bloom Filter.

Here is a Java implementation.

groundhog
thanks a lot! fast and precise
Andreas Petersson
+3  A: 

I think you mean a Bloom filter. Here's one based on Java's BitSet.

Meredith L. Patterson
thanks a lot! did not know that specific implementation!
Andreas Petersson