Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Update for Swift 4.2.
* Remove the top code snippet, as per instructions.
* Remove use of deprecated `characters` property.
  • Loading branch information
SpacyRicochet committed Oct 4, 2018
commit 4201fb4fc8bfefe4ab9651f5c393c55ddfd5f294
9 changes: 3 additions & 6 deletions Bloom Filter/BloomFilter.playground/Contents.swift
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
//: Playground - noun: a place where people can play
// last checked with Xcode 9.0b4
#if swift(>=4.0)
print("Hello, Swift 4!")
#endif

public class BloomFilter<T> {
fileprivate var array: [Bool]
private var hashFunctions: [(T) -> Int]
Expand Down Expand Up @@ -54,15 +51,15 @@ public class BloomFilter<T> {

func djb2(x: String) -> Int {
var hash = 5381
for char in x.characters {
for char in x {
hash = ((hash << 5) &+ hash) &+ char.hashValue
}
return Int(hash)
}

func sdbm(x: String) -> Int {
var hash = 0
for char in x.characters {
for char in x {
hash = char.hashValue &+ (hash << 6) &+ (hash << 16) &- hash
}
return Int(hash)
Expand Down