code: private void boundSize(HashSetModifiableDBIDs set, int items) {
      if(set.size() > items) {
        DBIDs sample = DBIDUtil.randomSample(set, items, rnd);
        set.clear();
        set.addDBIDs(sample);
      }
    }
docs: Bound the size of a set by random sampling.
  
  @param set Set to process
  @param items Maximum size