mirror of
https://github.com/ppy/osu.git
synced 2025-01-06 02:42:54 +08:00
Revert nearest index accessibility back to private
Implementation details should not be tested.
This commit is contained in:
parent
9a29797a5b
commit
1001fcfb94
@ -17,11 +17,8 @@ namespace osu.Game.Lists
|
|||||||
private static readonly IComparer<T> type_comparer = Comparer<T>.Default;
|
private static readonly IComparer<T> type_comparer = Comparer<T>.Default;
|
||||||
|
|
||||||
private readonly SortedList<Interval<T>> intervals = new SortedList<Interval<T>>((x, y) => type_comparer.Compare(x.Start, y.Start));
|
private readonly SortedList<Interval<T>> intervals = new SortedList<Interval<T>>((x, y) => type_comparer.Compare(x.Start, y.Start));
|
||||||
|
private int nearestIndex;
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// The index of the nearest interval from last <see cref="IsInAnyInterval"/> call.
|
|
||||||
/// </summary>
|
|
||||||
protected int NearestIntervalIndex;
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Whether the provided value is in any interval added to this list.
|
/// Whether the provided value is in any interval added to this list.
|
||||||
@ -34,20 +31,20 @@ namespace osu.Game.Lists
|
|||||||
|
|
||||||
// Clamp the nearest index in case there were intervals
|
// Clamp the nearest index in case there were intervals
|
||||||
// removed from the list causing the index to go out of range.
|
// removed from the list causing the index to go out of range.
|
||||||
NearestIntervalIndex = Math.Clamp(NearestIntervalIndex, 0, Count - 1);
|
nearestIndex = Math.Clamp(nearestIndex, 0, intervals.Count - 1);
|
||||||
|
|
||||||
if (type_comparer.Compare(value, this[NearestIntervalIndex].End) > 0)
|
if (type_comparer.Compare(value, this[nearestIndex].End) > 0)
|
||||||
{
|
{
|
||||||
while (type_comparer.Compare(value, this[NearestIntervalIndex].End) > 0 && NearestIntervalIndex < Count - 1)
|
while (type_comparer.Compare(value, this[nearestIndex].End) > 0 && nearestIndex < intervals.Count - 1)
|
||||||
NearestIntervalIndex++;
|
nearestIndex++;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
while (type_comparer.Compare(value, this[NearestIntervalIndex].Start) < 0 && NearestIntervalIndex > 0)
|
while (type_comparer.Compare(value, this[nearestIndex].Start) < 0 && nearestIndex > 0)
|
||||||
NearestIntervalIndex--;
|
nearestIndex--;
|
||||||
}
|
}
|
||||||
|
|
||||||
var nearestInterval = this[NearestIntervalIndex];
|
var nearestInterval = this[nearestIndex];
|
||||||
|
|
||||||
return type_comparer.Compare(value, nearestInterval.Start) >= 0 &&
|
return type_comparer.Compare(value, nearestInterval.Start) >= 0 &&
|
||||||
type_comparer.Compare(value, nearestInterval.End) <= 0;
|
type_comparer.Compare(value, nearestInterval.End) <= 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user