Struct Bounds<T>
- Namespace
- LfrlAnvil
- Assembly
- LfrlAnvil.Core.dll
public readonly struct Bounds<T> : IEquatable<Bounds<T>> where T : IComparable<T>
Type Parameters
T
Value type.
- Implements
-
IEquatable<Bounds<T>>
- Inherited Members
- Extension Methods
Constructors
Bounds(T, T)
Creates a new Bounds<T> instance.
public Bounds(T min, T max)
Parameters
min
TMinimum value.
max
TMaximum value.
Exceptions
- ArgumentException
When
min
is greater thanmax
.
Properties
Max
Maximum value in this range.
public T Max { get; }
Property Value
- T
Min
Minimum value is this range.
public T Min { get; }
Property Value
- T
Methods
Clamp(T)
[Pure]
public T Clamp(T value)
Parameters
value
TValue to clamp.
Returns
- T
Clamped
value
.
Contains(Bounds<T>)
[Pure]
public bool Contains(Bounds<T> other)
Parameters
other
Bounds<T>Range to check.
Returns
- bool
true when this range contains the provided
other
range, otherwise false.
Contains(T)
[Pure]
public bool Contains(T value)
Parameters
value
TValue to check.
Returns
- bool
true when this range contains the provided
value
, otherwise false.
ContainsExclusively(Bounds<T>)
[Pure]
public bool ContainsExclusively(Bounds<T> other)
Parameters
other
Bounds<T>Range to check.
Returns
- bool
true when this exclusive range contains the provided
other
range, otherwise false.
ContainsExclusively(T)
[Pure]
public bool ContainsExclusively(T value)
Parameters
value
TValue to check.
Returns
- bool
true when this exclusive range contains the provided
value
, otherwise false.
Equals(Bounds<T>)
Indicates whether the current object is equal to another object of the same type.
[Pure]
public bool Equals(Bounds<T> other)
Parameters
other
Bounds<T>An object to compare with this object.
Returns
Equals(object?)
Indicates whether this instance and a specified object are equal.
[Pure]
public override bool Equals(object? obj)
Parameters
obj
objectThe object to compare with the current instance.
Returns
- bool
true if
obj
and this instance are the same type and represent the same value; otherwise, false.
GetHashCode()
Returns the hash code for this instance.
[Pure]
public override int GetHashCode()
Returns
- int
A 32-bit signed integer that is the hash code for this instance.
GetIntersection(Bounds<T>)
[Pure]
public Bounds<T>? GetIntersection(Bounds<T> other)
Parameters
other
Bounds<T>Range to check.
Returns
Intersects(Bounds<T>)
[Pure]
public bool Intersects(Bounds<T> other)
Parameters
other
Bounds<T>Range to check.
Returns
- bool
true when this range intersects with the provided
other
range, otherwise false.
MergeWith(Bounds<T>)
[Pure]
public Bounds<T>? MergeWith(Bounds<T> other)
Parameters
other
Bounds<T>Range to merge.
Returns
Remove(Bounds<T>)
[Pure]
public Pair<Bounds<T>?, Bounds<T>?> Remove(Bounds<T> other)
Parameters
other
Bounds<T>Range to remove.
Returns
- Pair<Bounds<T>?, Bounds<T>?>
Pair of Bounds<T> instances when
other
range is exclusively contained by this range, otherwise pair with both values equal to null whenother
range contains this range, otherwise pair with Second value equal to null.
SetMax(T)
Creates a new Bounds<T> instance with different max
value.
[Pure]
public Bounds<T> SetMax(T max)
Parameters
max
TMaximum value.
Returns
Exceptions
- ArgumentException
When Min is greater than
max
.
SetMin(T)
Creates a new Bounds<T> instance with different min
value.
[Pure]
public Bounds<T> SetMin(T min)
Parameters
min
TMinimum value.
Returns
Exceptions
- ArgumentException
When
min
is greater than Max.
SplitAt(T)
[Pure]
public Pair<Bounds<T>, Bounds<T>?> SplitAt(T value)
Parameters
value
TValue to split at.
Returns
- Pair<Bounds<T>, Bounds<T>?>
Pair of Bounds<T> instances when
value
is exclusively contained by this range, otherwise pair with the Second value equal to null.
ToString()
Returns a string representation of this Bounds<T> instance.
[Pure]
public override string ToString()
Returns
- string
String representation.
Operators
operator ==(Bounds<T>, Bounds<T>)
Checks if a
is equal to b
.
[Pure]
public static bool operator ==(Bounds<T> a, Bounds<T> b)
Parameters
Returns
- bool
true when operands are equal, otherwise false.
operator !=(Bounds<T>, Bounds<T>)
Checks if a
is not equal to b
.
[Pure]
public static bool operator !=(Bounds<T> a, Bounds<T> b)
Parameters
Returns
- bool
true when operands are not equal, otherwise false.