// This code assumes the shiftAssignmentList is sorted
// Filter out every immovable ShiftAssignment
List<ShiftAssignment> shiftAssignmentList = new ArrayList<ShiftAssignment>(
nurseRoster.getShiftAssignmentList());
for (Iterator<ShiftAssignment> it = shiftAssignmentList.iterator(); it.hasNext(); ) {
ShiftAssignment shiftAssignment = it.next();
if (!filter.accept(nurseRoster, shiftAssignment)) {
it.remove();
}
}
// Hash the assignments per employee
Map<Employee, List<AssignmentSequence>> employeeToAssignmentSequenceListMap
= new HashMap<Employee, List<AssignmentSequence>>(employeeList.size());
int assignmentSequenceCapacity = nurseRoster.getShiftDateList().size() + 1 / 2;
for (Employee employee : employeeList) {
employeeToAssignmentSequenceListMap.put(employee,
new ArrayList<AssignmentSequence>(assignmentSequenceCapacity));
}
for (ShiftAssignment shiftAssignment : shiftAssignmentList) {
Employee employee = shiftAssignment.getEmployee();
List<AssignmentSequence> assignmentSequenceList = employeeToAssignmentSequenceListMap.get(employee);
if (assignmentSequenceList.isEmpty()) {
AssignmentSequence assignmentSequence = new AssignmentSequence(employee, shiftAssignment);
assignmentSequenceList.add(assignmentSequence);
} else {