private Set<DTNHost> selectTrackedHosts(List<DTNHost> allHosts){
  Set<DTNHost> trackedHosts=new HashSet<DTNHost>();
  if (this.nrofHosts > allHosts.size()) {
    throw new SettingsError("Can't use more hosts than there are " + "in the simulation scenario");
  }
  for (int i=0; i < nrofHosts; i++) {
    DTNHost nextHost=allHosts.get(rng.nextInt(allHosts.size()));
    if (trackedHosts.contains(nextHost)) {
      i--;
    }
 else {
      trackedHosts.add(nextHost);
    }
  }
  return trackedHosts;
}

private Set < DTNHost > selectTrackedHosts ( List < DTNHost > allHosts ) { Set < DTNHost > trackedHosts = new HashSet < DTNHost > ( ) ; if ( this . nrofHosts > allHosts . size ( ) ) { throw new SettingsError ( "Can't use more hosts than there are " + "in the simulation scenario" ) ; } for ( int i = 0 ; i < nrofHosts ; i ++ ) { DTNHost nextHost = allHosts . get ( rng . nextInt ( allHosts . size ( ) ) ) ; if ( trackedHosts . contains ( nextHost ) ) { i -- ; } else { trackedHosts . add ( nextHost ) ; } } return trackedHosts ; }
randomly selects the hosts to track
