-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.html
43 lines (38 loc) · 1.43 KB
/
test.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>Test Bloom Filter</title>
<script type="text/javascript" src="bloom_filter.js"></script>
<script type="text/javascript" src="sha1.js"></script>
<script type="text/javascript">
var drinks = ["coke","pepsi","redbull","v","appletiser","orange juice","apple juice"];
var bf = new BloomFilter(100).add(drinks);
for(var i=0; i<drinks.length; i++) {
var d = drinks[i];
console.log("Has " + d + "?", bf.has(d));
}
for(var i=0; i<drinks.length; i++) {
var d = "diet " + drinks[i];
console.log("Has " + d + "?", bf.has(d));
}
</script>
</head>
<body>
<h1>Bloom Filter</h1>
<p>See the source and Firebug console output for details.</p>
<h2>Usage</h2>
<pre>
var drinks = ["coke","pepsi","redbull","v","appletiser","orange juice","apple juice"];
var bf = new BloomFilter(100).add(drinks);
bf.has("coke") // == true
bf.has("dr pepper") // == false
bf.add("dr pepper") // == true
bf.has("dr pepper") // == true
</pre>
<h2>Future</h2>
<p>Here's an idea: Why not load the Bloom Filter array from a Canvas element (png image)?</p>
<p>It's a simple binary array, so this would be a memory efficient way of doing a large scale bloom filter in JavaScript.</p>
</body>
</html>