List<LimitingResourceQueueElement> result) {
if (gaps.isEmpty()) {
return null;
}
GapOnQueueWithQueueElement first = gaps.get(0);
GapOnQueue gapOnQueue = first.getGapOnQueue();
if (gapOnQueue != null) {
AllocationSpec allocation = requirements.guessValidity(gapOnQueue);
if (allocation.isValid()) {
return allocation;
}
}
result.add(unschedule(first.getQueueElement()));
if (gaps.size() > 1) {
gaps.set(1, GapOnQueueWithQueueElement.coalesce(first, gaps.get(1)));
}
gaps.remove(0);
return unscheduleElementsFor(gaps, requirements, result);