TreeSet tree = new TreeSet(sortComp); visibleTargets = new Entity[vec.size()];  for ( int i = 0; i < vec.size(); i++ ) { tree.add(vec.elementAt(i)); }
TreeSet<Entity> tree = new TreeSet<Entity>(sortComp); tree.addAll(vec);
      private void cacheVisibleTargets() {        clearVisibleTargets();                Vector vec = client.game.getValidTargets( ce() );        Comparator sortComp = new Comparator() {          public int compare(java.lang.Object x, java.lang.Object y) {            Entity entX = (Entity)x;            Entity entY = (Entity)y;                    int rangeToX = ce().getPosition().distance(entX.getPosition());            int rangeToY = ce().getPosition().distance(entY.getPosition());                    if ( rangeToX == rangeToY ) return ((entX.getId() < entY.getId()) ? -1 : 1);                      return ((rangeToX < rangeToY) ? -1 : 1);          }        };                  TreeSet tree = new TreeSet(sortComp);        visibleTargets = new Entity[vec.size()];                      for ( int i = 0; i < vec.size(); i++ ) {          tree.add(vec.elementAt(i));          }                Iterator it = tree.iterator();        int count = 0;        while ( it.hasNext() ) {          visibleTargets[count++] = (Entity)it.next();        }        setNextTargetEnabled(visibleTargets.length > 0);      }