public void allocatePartPERanges(int partId, PERangeList selected, 
			double startTime, double finishTime) {
		
		if(partId >= partitions.length || partId < 0) {
			throw new IndexOutOfBoundsException("Partition " + partId + 
					" does not exist.");
		}

		Iterator<ProfileEntry> it = avail.itValuesFromPrec(startTime);
		PartProfileEntry last = (PartProfileEntry)it.next();
		PartProfileEntry newAnchor = null;
        
        // The following is to avoid having to iterate the 
        // profile more than one time to update the entries. 
        if(Double.compare(last.getTime(),startTime) == 0) {
        	last.increaseJob();
        }
        else {
        	newAnchor = last.clone(startTime);
        	last = newAnchor;
        }

        PartProfileEntry nextEntry = null;
        while(it.hasNext()) {
       		nextEntry = (PartProfileEntry)it.next();
       		if(nextEntry.getTime() <= finishTime) {
       			last.getAvailRanges(partId).remove(selected);
       			last = nextEntry;
       			continue;
       		}
   			break;
        }

        if(Double.compare(last.getTime(),finishTime) == 0) {
        	last.increaseJob();
        }
        else {
        	add(last.clone(finishTime));
        	last.getAvailRanges(partId).remove(selected);
        }
        
        if(newAnchor != null) {
        	add(newAnchor);
        }
	}