File tree Expand file tree Collapse file tree 1 file changed +3
-6
lines changed
Bloom Filter/BloomFilter.playground Expand file tree Collapse file tree 1 file changed +3
-6
lines changed Original file line number Diff line number Diff line change 1
1
//: Playground - noun: a place where people can play
2
- // last checked with Xcode 9.0b4
3
- #if swift(>=4.0)
4
- print ( " Hello, Swift 4! " )
5
- #endif
2
+
6
3
public class BloomFilter < T> {
7
4
fileprivate var array : [ Bool ]
8
5
private var hashFunctions : [ ( T ) -> Int ]
@@ -54,15 +51,15 @@ public class BloomFilter<T> {
54
51
55
52
func djb2( x: String ) -> Int {
56
53
var hash = 5381
57
- for char in x. characters {
54
+ for char in x {
58
55
hash = ( ( hash << 5 ) &+ hash) &+ char. hashValue
59
56
}
60
57
return Int ( hash)
61
58
}
62
59
63
60
func sdbm( x: String ) -> Int {
64
61
var hash = 0
65
- for char in x. characters {
62
+ for char in x {
66
63
hash = char. hashValue &+ ( hash << 6 ) &+ ( hash << 16 ) &- hash
67
64
}
68
65
return Int ( hash)
You can’t perform that action at this time.
0 commit comments