         // => buckets * 16 >= count
         // count > buckets / 16
         let minBuckets = 4
-        let LOGmaxBucketSize = 6
+        let LOGmaxBucketSize = Int(log2(Double(maxBucketSize)))
         // => maxBucketSize = 2 ^ (LOGmaxBucketSize)
         // => bucketSize between 2^(x-1) and 2^(x)
         // x = 4 => bucketSize between 4 and 8

    }
    
    var description: String {
        return String(table)
    }
}
    var decreaseBuckets: Bool = true { didSet { if decreaseBuckets && (!oldValue || !resetBuckets) { resetBuckets = true } } }
    var increaseBuckets: Bool = true { didSet { if increaseBuckets && (!oldValue || !resetBuckets) { resetBuckets = true } } }
    
    init(_ array: [(key: K, value: V)], buckets: Int = 0x10) throws {
        self.init(buckets: buckets, resetBuckets: false)
        try insert(array)
    }
    
    init(buckets: Int = 0x10, resetBuckets: Bool = true, hashFunction: K -> Int = { $0.hashValue }) {
        table = [[(key: K, value: V)]](count: buckets.nextPowerOf2, repeatedValue: [])
        self.hashFunction = hashFunction
        self.resetBuckets = resetBuckets
    }
    
    //P.ERFORMANCE maybe in parallel or hashing all first in parallel, then appending all?
    mutating func insert(elements elements: (key: K, value: V)...) throws {
        try insert(elements)
    }
    
    //P.ERFORMANCE maybe in parallel or hashing all first in parallel, then appending all?
    mutating func insert(elements: [(key: K, value: V)]) throws {
        try correctBucketCount(count + elements.count)
        let oldResetBuckets = resetBuckets
        self.resetBuckets = false
        for v in elements {
            try insert(element: v)
        }
        print("tries to correct in \(#function)")
        self.resetBuckets = oldResetBuckets
        try correctBucketCount()
    }
    
