 import Foundation
 
 
-protocol HashTableElementType {
+protocol HashTableElementType : Hashable {
+    associatedtype Key : Hashable
     associatedtype Element
     init(elem: Element)
-    var key : Int { get }
-    var elem : Element { get }
+    var key : Key       { get }
+    var value : Element { get }
     var hashValue : Int { get }
 }
 extension HashTableElementType {
-    var hashValue : Int { return key }
+    var hashValue : Int { return key.hashValue }
+    var tuple : (Int, Element) { return (hashValue, value) }
 }
 
 struct HashTable <K: Hashable, V> : ArrayLiteralConvertible, CustomStringConvertible {

    private(set) var maxBucketSize  : Int = 4 // 2 ^ 4 = 16
    
    init(arrayLiteral elements: Element...) {
        do {
            try self.init(_: elements)
        } catch let e {
            print("Error: \(e)")
            self.init()
        }
    }
    

    }
    
    var description: String {
        var desc = "HashTable\(Element.self)\n"
        for i in table.range {
            desc += "bucket \(i+1): \(table[i])\n"
        }
        return desc
    }
}