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) if (comparison < 0)
return false; return false;
if (comparison == 0 && !IsInclusive) if (comparison == 0 && !IsLowerInclusive)
return false; return false;
} }
@ -64,7 +64,7 @@ namespace osu.Game.Screens.Select
if (comparison > 0) if (comparison > 0)
return false; return false;
if (comparison == 0 && !IsInclusive) if (comparison == 0 && !IsUpperInclusive)
return false; return false;
} }
@ -73,12 +73,14 @@ namespace osu.Game.Screens.Select
public T? Min; public T? Min;
public T? Max; public T? Max;
public bool IsInclusive; public bool IsLowerInclusive;
public bool IsUpperInclusive;
public bool Equals(OptionalRange<T> other) public bool Equals(OptionalRange<T> other)
=> Min.Equals(other.Min) => Min.Equals(other.Min)
&& Max.Equals(other.Max) && 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 "=":
case ":": case ":":
range.IsInclusive = true; range.IsLowerInclusive = range.IsUpperInclusive = true;
range.Min = value; range.Min = value;
range.Max = value; range.Max = value;
break; break;
case ">": case ">":
range.IsInclusive = false; range.IsLowerInclusive = false;
range.Min = value; range.Min = value;
break; break;
case ">=": case ">=":
case ">:": case ">:":
range.IsInclusive = true; range.IsLowerInclusive = true;
range.Min = value; range.Min = value;
break; break;
case "<": case "<":
range.IsInclusive = false; range.IsUpperInclusive = false;
range.Max = value; range.Max = value;
break; break;
case "<=": case "<=":
case "<:": case "<:":
range.IsInclusive = true; range.IsUpperInclusive = true;
range.Max = value; range.Max = value;
break; break;
} }