code: protected void keepTopFeatures(Map<Object, Double> featureScores, int maxFeatures) {
          logger.debug("keepTopFeatures()");
  
          logger.debug("Estimating the minPermittedScore");
          Double minPermittedScore = SelectKth.largest(featureScores.values().iterator(), maxFeatures);
  
          //remove any entry with score less than the minimum permitted one
          logger.debug("Removing features with scores less than threshold");
          Iterator<Map.Entry<Object, Double>> it = featureScores.entrySet().iterator();
          while(it.hasNext()) {
              Map.Entry<Object, Double> entry = it.next();
              if(entry.getValue()<minPermittedScore) {
                  it.remove();
              }
          }
  
          //if some extra features still exist (due to ties on the scores) remove some of those extra features
          int numOfExtraFeatures = featureScores.size()-maxFeatures;
          if(numOfExtraFeatures>0) {
              logger.debug("Removing extra features caused by ties");
              it = featureScores.entrySet().iterator();
              while(it.hasNext() && numOfExtraFeatures>0) {
                  Map.Entry<Object, Double> entry = it.next();
                  if(entry.getValue()-minPermittedScore<=0.0) { //DO NOT COMPARE THEM DIRECTLY USE SUBTRACTION!
                      it.remove();
                      --numOfExtraFeatures;
                  }
              }
          }
      }
docs: This method keeps the highest scoring features of the provided feature map
  and removes all the others.
  
  @param featureScores
  @param maxFeatures