 #include <omp.h>
 #endif
 
-#include "inverseIndex.h"
-#include "kSizeSortedMap.h"
+#include "inverseIndexCuda.h"
+// #include "kSizeSortedMap.h"
 
 
-class sort_map {
-  public:
-    size_t key;
-    size_t val;
-};
+// class sort_map {
+//   public:
+//     size_t key;
+//     size_t val;
+// };
 
-bool mapSortDescByValue(const sort_map& a, const sort_map& b) {
-        return a.val > b.val;
-};
+// bool mapSortDescByValue(const sort_map& a, const sort_map& b) {
+//         return a.val > b.val;
+// };
 
 InverseIndexCuda::InverseIndexCuda(size_t pNumberOfHashFunctions, size_t pShingleSize,
                     size_t pNumberOfCores, size_t pChunkSize,

    mPruneInverseIndexAfterInstance = pPruneInverseIndexAfterInstance;
    mRemoveHashFunctionWithLessEntriesAs = pRemoveHashFunctionWithLessEntriesAs;
    mHashAlgorithm = pHashAlgorithm;
    mSignatureStorage = new umap_uniqueElement();
    mHash = new Hash();
    mBlockSize = pBlockSize;
    mShingle = pShingle;
    size_t maximalFeatures = 5000;

    int maxBlocks = 65535;
    cudaDeviceProp prop;
    int whichDevice;
    cudaGetDevice(&whichDevice);
    cudaGetDeviceProperties(&prop, whichDevice);
    // if (pRawData->size() > maxBlocks) {
    //     for (size_t i = 0; i < pRawData->size(); ++i) {
    //         if (mNumberOfHashFunctions > prop.maxThreadsPerBlock) {
    //             for (size_t j = 0; j < mNumberOfHashFunctions; ++j) {
                    
    //             }
    //         }
            
    //     }
    // } else {
    //     if (mNumberOfHashFunctions > prop.maxThreadsPerBlock) {
       
    //     } else {
   
    size_t* result;
    result = (size_t*) malloc(pRawData->size() * mNumberOfHashFunctions * sizeof(size_t));
       
    size_t* dev_featureList;
    size_t* dev_sizeOfInstanceList;
    size_t* dev_computedSignaturesPerInstance;
    
    cudaHostAlloc((void **) &dev_featureList,
               pRawData->getMaxNnz() * pRawData->getNumberOfInstances() * sizeof(size_t),
               cudaHostAllocWriteCombined |
               cudaHostAllocMapped);
    cudaHostAlloc((void **) &dev_sizeOfInstanceList,
               pRawData->getNumberOfInstances() * sizeof(size_t),
               cudaHostAllocWriteCombined |
               cudaHostAllocMapped);
    cudaHostAlloc((void **) &dev_computedSignaturesPerInstance,
               pRawData->size() * mNumberOfHashFunctions * sizeof(size_t),
               cudaHostAllocMapped);
    // cudaMemcpy(dev_featureList, pRawData->getSparseMatrixIndex(),
    //             pRawData->getMaxNnz() * pRawData->getNumberOfInstances() * sizeof(size_t),
    //            cudaHostAllocWriteCombined |
    //            cudaHostAllocMapped);
    // cudaMemcpy(dev_sizeOfInstanceList, pRawData->getSparseMatrixSizeOfInstances(),
    //         pRawData->getNumberOfInstances() * sizeof(size_t),
    //         cudaHostAllocMapped);
    cudaHostGetDevicePointer(&dev_featureList, pRawData->getSparseMatrixIndex(), 0);
    cudaHostGetDevicePointer(&dev_sizeOfInstanceList, pRawData->getSparseMatrixSizeOfInstances(), 0);
    cudaHostGetDevicePointer(&dev_computedSignaturesPerInstance, result, 0);
    
    fitGpu<<<pRawData->getNumberOfInstances(), mNumberOfHashFunctions, mNumberOfHashFunctions>>>
    (dev_featureList, 
    dev_sizeOfInstanceList, 
    mNumberOfHashFunctions, 
    pRawData->getMaxNnz(),
            dev_computedSignaturesPerInstance, 
            pRawData->getNumberOfInstances());
    cudaThreadSynchronize();
    
    std::vector<std::vector<size_t> > hashFunctionHashValues;
    std::vector<std::vector<size_t> > associatedIndexValues;
    for (size_t i = 0; i < pRawData->getNumberOfInstances()*mNumberOfHashFunctions; ++i) {
        std::cout << result[i] ", ";
        
        // std::vector<size_t> instance(mNumberOfHashFunctions);
        // for (size_t j = 0; j < mNumberOfHashFunctions; ++j) {
            
        // }
    }
    cudaFree(dev_featureList);
    cudaFree(dev_sizeOfInstanceList);
    cudaFree(dev_computedSignaturesPerInstance);
    // cudaMemcpy(result, dev_computedSignaturesPerInstance,
    //            pRawData->size() * mNumberOfHashFunctions * sizeof(size_t),
    //            cudaMemcpyDeviceToHost );
    
        // }
        
    // }
}

neighborhood* InverseIndexCuda::kneighbors(const umap_uniqueElement* pSignaturesMap, 
