fix: invert logic
This commit is contained in:
@@ -22,6 +22,8 @@ class UpdateValidator
|
||||
}
|
||||
}
|
||||
|
||||
// NOTE: This is basically a bubble sort
|
||||
//
|
||||
public Update Sort(Update update)
|
||||
{
|
||||
var sortedUpdate = new Update(update.Pages.ToList());
|
||||
@@ -33,7 +35,7 @@ class UpdateValidator
|
||||
var currentPage = sortedUpdate.Pages[i];
|
||||
var nextPage = sortedUpdate.Pages[i + 1];
|
||||
|
||||
if (IsOutOfOrder(currentPage, nextPage) is false)
|
||||
if (IsInOrder(currentPage, nextPage))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
@@ -52,7 +54,7 @@ class UpdateValidator
|
||||
|
||||
foreach (var page in update.Pages)
|
||||
{
|
||||
if (previousPages.Any(previousPage => IsOutOfOrder(previousPage, page)))
|
||||
if (previousPages.Any(previousPage => IsInOrder(previousPage, page) is false))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -63,9 +65,9 @@ class UpdateValidator
|
||||
return true;
|
||||
}
|
||||
|
||||
private bool IsOutOfOrder(int previousPage, int futurePage)
|
||||
private bool IsInOrder(int previousPage, int futurePage)
|
||||
{
|
||||
return Graph.TryGetValue(previousPage, out var dependents) &&
|
||||
dependents.Contains(futurePage) is false;
|
||||
dependents.Contains(futurePage);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user