ladder_interranking method

Map<int, List<Student>> ladder_interranking(
  1. List<Student> allStudents
)

Retourne une carte des étudiants mieux classés pour les mêmes écoles sur les vœux dont l’interclassement diffère.

Implementation

Map<int, List<Student>> ladder_interranking(
    List<Student> allStudents) {
  Map<int, List<Student>> ladder = {};
  Map<int, Choice> diffDict = diff_interrankings();
  if (diffDict.isEmpty) return {};
  for (var entry in diffDict.entries) {
    Choice c = entry.value; // Le choix problématique
    int key = entry.key; // Son index dans la liste des vœux
    ladder[key] = [];
    for (Student other in allStudents) {
      if (other.id == id) continue;
      for (Choice otherChoice in other.choices.values) {
        if (otherChoice.school.id == c.school.id &&
            otherChoice.interranking > c.interranking) {
          ladder.putIfAbsent(key, () => []);
          ladder[key]!.add(other);
        }
      }
    }
  }
  return ladder;
}