1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-06 09:07:25 +08:00

Split out lower and upper interval inclusivity

A single IsInclusive field causes unexpected issues when trying to
formulate a half-open interval query. Split out IsInclusive into two
fields, Is{Lower,Upper}Inclusive and update usages accordingly.
This commit is contained in:
Bartłomiej Dach 2019-09-20 21:34:38 +02:00
parent 33c51d5178
commit dddd94684b
2 changed files with 11 additions and 9 deletions

View File

@ -53,7 +53,7 @@ namespace osu.Game.Screens.Select
if (comparison < 0)
return false;
if (comparison == 0 && !IsInclusive)
if (comparison == 0 && !IsLowerInclusive)
return false;
}
@ -64,7 +64,7 @@ namespace osu.Game.Screens.Select
if (comparison > 0)
return false;
if (comparison == 0 && !IsInclusive)
if (comparison == 0 && !IsUpperInclusive)
return false;
}
@ -73,12 +73,14 @@ namespace osu.Game.Screens.Select
public T? Min;
public T? Max;
public bool IsInclusive;
public bool IsLowerInclusive;
public bool IsUpperInclusive;
public bool Equals(OptionalRange<T> other)
=> Min.Equals(other.Min)
&& Max.Equals(other.Max)
&& IsInclusive.Equals(other.IsInclusive);
&& IsLowerInclusive.Equals(other.IsLowerInclusive)
&& IsUpperInclusive.Equals(other.IsUpperInclusive);
}
}
}

View File

@ -106,30 +106,30 @@ namespace osu.Game.Screens.Select
case "=":
case ":":
range.IsInclusive = true;
range.IsLowerInclusive = range.IsUpperInclusive = true;
range.Min = value;
range.Max = value;
break;
case ">":
range.IsInclusive = false;
range.IsLowerInclusive = false;
range.Min = value;
break;
case ">=":
case ">:":
range.IsInclusive = true;
range.IsLowerInclusive = true;
range.Min = value;
break;
case "<":
range.IsInclusive = false;
range.IsUpperInclusive = false;
range.Max = value;
break;
case "<=":
case "<:":
range.IsInclusive = true;
range.IsUpperInclusive = true;
range.Max = value;
break;
}