1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-13 08:32:57 +08:00

Use HashSet instead of SortedSet

No need for it to be sorted.
This commit is contained in:
Bartłomiej Dach 2024-03-19 18:19:06 +01:00
parent 77119b2cdb
commit feaf59e15f
No known key found for this signature in database
2 changed files with 11 additions and 17 deletions

View File

@ -257,7 +257,7 @@ namespace osu.Game.Tests.NonVisual.Filtering
var filterCriteria = new FilterCriteria();
FilterQueryParser.ApplyQueries(filterCriteria, query);
Assert.IsNotEmpty(filterCriteria.OnlineStatus.Values);
Assert.Contains(BeatmapOnlineStatus.Ranked, filterCriteria.OnlineStatus.Values);
Assert.That(filterCriteria.OnlineStatus.Values, Contains.Item(BeatmapOnlineStatus.Ranked));
}
[Test]
@ -269,7 +269,7 @@ namespace osu.Game.Tests.NonVisual.Filtering
Assert.AreEqual("I want the pp", filterCriteria.SearchText.Trim());
Assert.AreEqual(4, filterCriteria.SearchTerms.Length);
Assert.IsNotEmpty(filterCriteria.OnlineStatus.Values);
Assert.Contains(BeatmapOnlineStatus.Ranked, filterCriteria.OnlineStatus.Values);
Assert.That(filterCriteria.OnlineStatus.Values, Contains.Item(BeatmapOnlineStatus.Ranked));
}
[Test]
@ -279,8 +279,8 @@ namespace osu.Game.Tests.NonVisual.Filtering
var filterCriteria = new FilterCriteria();
FilterQueryParser.ApplyQueries(filterCriteria, query);
Assert.IsNotEmpty(filterCriteria.OnlineStatus.Values);
Assert.Contains(BeatmapOnlineStatus.Ranked, filterCriteria.OnlineStatus.Values);
Assert.Contains(BeatmapOnlineStatus.Loved, filterCriteria.OnlineStatus.Values);
Assert.That(filterCriteria.OnlineStatus.Values, Contains.Item(BeatmapOnlineStatus.Ranked));
Assert.That(filterCriteria.OnlineStatus.Values, Contains.Item(BeatmapOnlineStatus.Loved));
}
[Test]
@ -290,10 +290,10 @@ namespace osu.Game.Tests.NonVisual.Filtering
var filterCriteria = new FilterCriteria();
FilterQueryParser.ApplyQueries(filterCriteria, query);
Assert.IsNotEmpty(filterCriteria.OnlineStatus.Values);
Assert.Contains(BeatmapOnlineStatus.Ranked, filterCriteria.OnlineStatus.Values);
Assert.Contains(BeatmapOnlineStatus.Approved, filterCriteria.OnlineStatus.Values);
Assert.Contains(BeatmapOnlineStatus.Qualified, filterCriteria.OnlineStatus.Values);
Assert.Contains(BeatmapOnlineStatus.Loved, filterCriteria.OnlineStatus.Values);
Assert.That(filterCriteria.OnlineStatus.Values, Contains.Item(BeatmapOnlineStatus.Ranked));
Assert.That(filterCriteria.OnlineStatus.Values, Contains.Item(BeatmapOnlineStatus.Approved));
Assert.That(filterCriteria.OnlineStatus.Values, Contains.Item(BeatmapOnlineStatus.Qualified));
Assert.That(filterCriteria.OnlineStatus.Values, Contains.Item(BeatmapOnlineStatus.Loved));
}
[TestCase("creator")]

View File

@ -119,21 +119,15 @@ namespace osu.Game.Screens.Select
{
public bool HasFilter => Values.Count > 0;
public bool IsInRange(T value)
{
return Values.Contains(value);
}
public bool IsInRange(T value) => Values.Contains(value);
public SortedSet<T> Values = new SortedSet<T>();
public HashSet<T> Values = new HashSet<T>();
public OptionalSet()
{
}
public bool Equals(OptionalSet<T> other)
{
return Values.SetEquals(other.Values);
}
public bool Equals(OptionalSet<T> other) => Values.SetEquals(other.Values);
}
public struct OptionalRange<T> : IEquatable<OptionalRange<T>>