void EdgeBag::put(char c, shared_ptr<Edge>& e) {
    int idx = search(c);

    if (idx < 0) {//change chars
        chars.push_back(c);
        values.push_back(e);

        if ((int)chars.size() > BSEARCH_THRESHOLD)
            sortArrays();
    }

    else
        if(!values.empty())
            values[idx] = e;
}
gpuNUFFT::GpuNUFFTOperator* gpuNUFFT::GpuNUFFTOperatorFactory::createGpuNUFFTOperator(gpuNUFFT::Array<DType>& kSpaceTraj, gpuNUFFT::Array<DType>& densCompData,gpuNUFFT::Array<DType2>& sensData, const IndType& kernelWidth, const IndType& sectorWidth, const DType& osf, gpuNUFFT::Dimensions& imgDims)
{
  //validate arguments
  if (kSpaceTraj.dim.channels > 1)
    throw std::invalid_argument("Trajectory dimension must not contain a channel size greater than 1!");

  if (imgDims.channels > 1)
    throw std::invalid_argument("Image dimensions must not contain a channel size greater than 1!");

  debug("create gpuNUFFT operator...");

  gpuNUFFT::GpuNUFFTOperator *gpuNUFFTOp = createNewGpuNUFFTOperator(kernelWidth,sectorWidth,osf,imgDims);

  //assign according sector to k-Space position
  gpuNUFFT::Array<IndType> assignedSectors = assignSectors(gpuNUFFTOp, kSpaceTraj);

  //order the assigned sectors and memorize index
  std::vector<IndPair> assignedSectorsAndIndicesSorted = sortVector<IndType>(assignedSectors);

  IndType coordCnt = kSpaceTraj.dim.count();

  Array<DType>   trajSorted = initCoordsData(gpuNUFFTOp,coordCnt);
  Array<IndType> dataIndices = initDataIndices(gpuNUFFTOp,coordCnt);

  Array<DType>   densData;
  if (densCompData.data != NULL)
    densData = initDensData(gpuNUFFTOp,coordCnt);

  if (sensData.data != NULL)
    gpuNUFFTOp->setSens(sensData);

  if (useGpu)
  {
    sortArrays(gpuNUFFTOp,assignedSectorsAndIndicesSorted,assignedSectors.data, 
      dataIndices.data,kSpaceTraj,trajSorted.data,densCompData.data,densData.data);
  }
  else
  {
    //sort kspace data coords
    for (int i=0; i<coordCnt;i++)
    {
      trajSorted.data[i] = kSpaceTraj.data[assignedSectorsAndIndicesSorted[i].first];
      trajSorted.data[i + 1*coordCnt] = kSpaceTraj.data[assignedSectorsAndIndicesSorted[i].first + 1*coordCnt];
      if (gpuNUFFTOp->is3DProcessing())
        trajSorted.data[i + 2*coordCnt] = kSpaceTraj.data[assignedSectorsAndIndicesSorted[i].first + 2*coordCnt];

      //sort density compensation
      if (densCompData.data != NULL)
        densData.data[i] = densCompData.data[assignedSectorsAndIndicesSorted[i].first];

      dataIndices.data[i] = assignedSectorsAndIndicesSorted[i].first;
      assignedSectors.data[i] = assignedSectorsAndIndicesSorted[i].second;		
    }
  }
  
  gpuNUFFTOp->setSectorDataCount(computeSectorDataCount(gpuNUFFTOp,assignedSectors));
  
  if (gpuNUFFTOp->getType() == gpuNUFFT::BALANCED ||gpuNUFFTOp->getType() == gpuNUFFT::BALANCED_TEXTURE)
    computeProcessingOrder(gpuNUFFTOp);

  gpuNUFFTOp->setDataIndices(dataIndices);

  gpuNUFFTOp->setKSpaceTraj(trajSorted);

  gpuNUFFTOp->setDens(densData);

  if (gpuNUFFTOp->is3DProcessing())
    gpuNUFFTOp->setSectorCenters(computeSectorCenters(gpuNUFFTOp));
  else
    gpuNUFFTOp->setSectorCenters(computeSectorCenters2D(gpuNUFFTOp));

  //free temporary array
  free(assignedSectors.data);

  debug("finished creation of gpuNUFFT operator\n");
  return gpuNUFFTOp;
}