Skip to content

Commit

Permalink
Update IndexJsonBase.cs, Ranking.cs, and Hashing.cs
Browse files Browse the repository at this point in the history
  • Loading branch information
actions-user committed Jul 6, 2024
1 parent 2d78674 commit 6a63b03
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using PoliNetwork.Graduatorie.Parser.Objects.RankingNS;
using PoliNetwork.Graduatorie.Parser.Objects.Tables.Course;
using PoliNetwork.Graduatorie.Parser.Objects.Tables.Merit;
using PoliNetwork.Graduatorie.Parser.Utils;

#endregion

Expand Down Expand Up @@ -100,22 +101,21 @@ private static bool SameHashCourse(IReadOnlyCollection<CourseTable>? aTableCours
if (aTableCourse.Count != bTableCourse.Count)
return false;

var aHash = aTableCourse.Select(variable =>
var aList = aTableCourse.Select(variable =>
{
var hashWithoutLastUpdate = variable.GetHashWithoutLastUpdate();
return hashWithoutLastUpdate;
}).ToList();
var aHash = Hashing.GetHashFromListHash(aList);

var bHash = bTableCourse.Select(variable =>
var bList = bTableCourse.Select(variable =>
{
var hashWithoutLastUpdate = variable.GetHashWithoutLastUpdate();
return hashWithoutLastUpdate;
}).ToList();
var bHash = Hashing.GetHashFromListHash(bList);

var ai = aHash;
var bi = bHash;

return ai == bi;
return aHash == bHash;
}

private static bool SameHashMerit(MeritTable? aTableMerit, MeritTable? bTableMerit)
Expand Down
3 changes: 1 addition & 2 deletions PoliNetwork.Graduatorie.Parser/Objects/RankingNS/Ranking.cs
Original file line number Diff line number Diff line change
Expand Up @@ -205,8 +205,7 @@ public int GetHashWithoutLastUpdate()
i = ByCourse.Aggregate(i, (current, variable) =>
{
var hashWithoutLastUpdate = variable.GetHashWithoutLastUpdate();
var iList = hashWithoutLastUpdate;
return current ^ iList;
return current ^ hashWithoutLastUpdate;
});

return i;
Expand Down
9 changes: 9 additions & 0 deletions PoliNetwork.Graduatorie.Parser/Utils/Hashing.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,13 @@ public static int GetHashFromListHash(IReadOnlyCollection<int?>? iMerit)
var hashFromListHash = iMerit.Aggregate(0, (current, variable) => current ^ variable ?? 0);
return hashFromListHash;
}

public static int GetHashFromListHash(List<int> iMerit)
{
if (iMerit.Count == 0)
return 0;

var hashFromListHash = iMerit.Aggregate(0, (current, variable) => current ^ variable);
return hashFromListHash;
}
}

0 comments on commit 6a63b03

Please sign in to comment.