All pastes #2317 Raw Edit

Anonymous

public xml v1 · immutable
#2317 ·published 2004-11-24 23:33 UTC
rendered paste body
class CmpX implements Comparator {	public int compare(Object arg0, Object arg1) {		int erg = ((Compareable2D)arg0).compareToX((Compareable2D)arg1);		if(erg==0){			erg += ((Compareable2D)arg0).compareToY((Compareable2D)arg1);		}		return erg;	}};	public class TreeSet2D extends TreeSet{		public TreeSet2D(){				super(new CmpX());	}	public LinkedList getRegion(Location topleft, Location bottomright){		SortedSet xFits = subSet(topleft, bottomright);			LinkedList list = new LinkedList();				Iterator xFitsIterator = xFits.iterator();		while( xFitsIterator.hasNext()){			Location loc = (Location) xFitsIterator.next();			if (loc.y >= topleft.y && loc.y <= bottomright.y){				list.add(loc);			}		}				return list;	}}