 }
 
 class S2CellId {
-    var id: Double
-    
-    init(id: Double) {
+    var id: UInt64
+    
+    init(id: UInt64) {
         self.id = id
     }
     

    }
    
    convenience init(face: Int, i: Int, j: Int) {
        var  n = face << (S2Constants.posBits - 1)
        var bits = face & S2Constants.swapMask
        
        for k in 7.stride(to: -1, by: -1) {
            let mask = (1 << S2Constants.lookupBits) - 1
            bits += (((i >> (k * S2Constants.lookupBits)) & mask) << (S2Constants.lookupBits + 2))
            bits += (((j >> (k * S2Constants.lookupBits)) & mask) << 2)
            bits = S2Helper.sharedInstance.lookupPos[bits]
            n |= (bits >> 2) << (k * 2 * S2Constants.lookupBits)
            bits &= (S2Constants.swapMask | S2Constants.invertMask)
        }
        
        self.init(id: (Double(n) * 2) + 1)
    }
    
    static func xyzToFaceUv(p: S2Point) -> S2FaceUv {

class S2Helper {
    static let sharedInstance = S2Helper()
    
    var lookupPos: [Int?] = []
    
    init() {
        for _ in 0..<(1 << (2 * S2Constants.lookupBits + 2)) {
            lookupPos.append(nil)
        }
        initLookupCell(0, i: 0, j: 0, origOrientation: 0, pos: 0, orientation: 0)
        initLookupCell(0, i: 0, j: 0, origOrientation: S2Constants.swapMask, pos: 0, orientation: S2Constants.swapMask)
        initLookupCell(0, i: 0, j: 0, origOrientation: S2Constants.invertMask, pos: 0, orientation: S2Constants.invertMask)
