public RectangleManager(List<Rectangle> recs)
	{
		rectangles = new LinkedList<Rectangle>();
		rectangles.addAll(recs);
		
		xEndPoints = new LinkedList<Endpoint>();
		yEndPoints = new LinkedList<Endpoint>();
		
		
		for (int i = 0; i < 2*rectangles.size(); i++)
		{
			xEndPoints.add(null);
			yEndPoints.add(null);
			
		}
		
		for (int i = 0; i < rectangles.size(); i++)
		{
			Endpoint endpoint = new Endpoint();
			endpoint.type = Endpoint.Type.BEGIN;
			endpoint.value = rectangles.get(i).xEnd[0].value;
			endpoint.index = i;
			xEndPoints.set(2*i, endpoint);
			
			endpoint = new Endpoint();
			endpoint.type = Endpoint.Type.BEGIN;
			endpoint.value = rectangles.get(i).yEnd[0].value;
			endpoint.index = i;
			yEndPoints.set(2*i, endpoint);
			
			endpoint = new Endpoint();
			endpoint.type = Endpoint.Type.END;
			endpoint.value = rectangles.get(i).xEnd[1].value;
			endpoint.index = i;
			xEndPoints.set(2*i+1, endpoint);
			
			endpoint = new Endpoint();
			endpoint.type = Endpoint.Type.END;
			endpoint.value = rectangles.get(i).yEnd[1].value;
			endpoint.index = i;
			yEndPoints.set(2*i+1, endpoint);
			
		
		
		}
		
		Collections.sort(xEndPoints);
		Collections.sort(yEndPoints);
		
		xLookUp = new LinkedList<Integer>();
		yLookUp = new LinkedList<Integer>();
		
		for (int i = 0; i < xEndPoints.size(); i++)
		{
			xLookUp.add(null);
			yLookUp.add(null);
		}
		
		for (int i = 0; i < xEndPoints.size(); ++i)
		{
			xLookUp.set(2*xEndPoints.get(i).index + xEndPoints.get(i).type.ordinal(), new Integer(i));
			yLookUp.set(2*yEndPoints.get(i).index + yEndPoints.get(i).type.ordinal(), new Integer(i));
		}
		
		Set<Integer> active = new LinkedHashSet<Integer>();
		overLaps = new LinkedHashSet<Pair>();
		
		for (int i = 0; i < xEndPoints.size(); ++i)
		{
			Endpoint end = xEndPoints.get(i);
			int index = end.index;
			
			if (end.type.ordinal() == Endpoint.Type.BEGIN.ordinal())
			{
				Iterator<Integer> iterator = active.iterator();
				
				while (iterator.hasNext())
				{
					Integer activeIndex = iterator.next(); 
					
					Rectangle r0 = rectangles.get(activeIndex);
					Rectangle r1 = rectangles.get(index);
					
					if (r0.hasYOverlap(r1))
					{
						if (activeIndex < index)
						{
							overLaps.add(new Pair(activeIndex, index));
						}
						else
						{
							overLaps.add(new Pair(index, activeIndex));
						}
					}
				}
				
				active.add(new Integer(index));
			}
			else
			{
				active.remove(new Integer(index));
			}
		}
		
	}