Skip to content

Instantly share code, notes, and snippets.

@nathankrishnan
Created April 9, 2017 18:08
Show Gist options
  • Save nathankrishnan/1914841d9daa53bbea383a7cfa4c583c to your computer and use it in GitHub Desktop.
Save nathankrishnan/1914841d9daa53bbea383a7cfa4c583c to your computer and use it in GitHub Desktop.
public class BloomFilter<T> {
private var array: [Bool]
private var hashFunctions: [(T) -> Int]
public init(size: Int = 1024, hashFunctions: [(T) -> Int]) {
self.array = [Bool](repeating: false, count: size)
self.hashFunctions = hashFunctions
}
private func computeHashes(_ value: T) -> [Int]
public func insert(_ element: T)
public func query(_ value: T) -> Bool
public func isEmpty()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment