The Prum filter is actually made up of a very long binary vector and a series of random mapping functions, and the Prum filter is used to retrieve whether an element is in a set
Advantages
Prum filters have space and time advantages. The Prum filter storage space and insert/query time are constant. In addition, the Hash function is not related to each other and is conveniently implemented by hardware. The Prum filter does not require the storage element itself, and has an advantage in certain situations where confidentiality requirements are very stringent
Disadvantages
There is a certain error rate, that is, the Bloom filter reports that an element exists in a set, but that the element is not in the collection, but if an element is not actually in the collection, then Bloom Filter does not report that the element exists in the collection; In addition, it is difficult to remove elements from the Prum filter.
Concrete implementation
Create a 1,600,000,002-feed constant and then set all 1.6 billion bits to 0. For each string, 8 information fingerprints (F1,F2,...., F8) are generated with 8 different random generator (F1,f2,....., F8). Then use a random number generator G to map these eight information fingerprints to 1.6 billion natural numbers in 1 to 8 g1,g2,..., G8. Now turn the bits of these 8 positions into 1. This is the kind of a cloth-lung filter that's built.
Sample code
[Java] View plain copy import java.util.bitset; /** * * @author xkey */ public class bloomfilter { private static final int default_size = 2 << 24;// Bit length private static final int[] seeds of Prum filter = {3,5,7, 11, 13, 31, 37, 61};//here to select prime numbers, can be very good to reduce the error rate private static bitset bits = new bitset (DEFAULT_SIZE); private static SimpleHash[] func = new simplehash[seeds.length]; public static Void addvalue (string value) { for (SIMPLEHASH&NBSP;F&NBSP;:&NBSP;FUNC)// Hashes the string value to 8 or more integers, and then changes to 1 on the bit of those integers bits.set (F.hash (value), true); } public static void add (string value) { if (value != null) addvalue (value); } public static boolean contains (String value) { if (value == null) return false; boolean ret = true; for (simplehash F&NBSP;:&NBSP;FUNC)//There's really no need to run it all, just once ret==false then don't include this string ret = ret && bits.get (F.hash (value )); return ret; } public static void main (String[] args) { String value = "Xkeyideal@gmail.com"; &NBsp; for (int i = 0; i < seeds.length; i++) {