Struct Bounds<T>
- Namespace
- LfrlAnvil
- Assembly
- LfrlAnvil.Core.dll
public readonly struct Bounds<T> : IEquatable<Bounds<T>> where T : IComparable<T>
Type Parameters
TValue 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
minTMinimum value.
maxTMaximum value.
Exceptions
- ArgumentException
When
minis 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
valueTValue to clamp.
Returns
- T
Clamped
value.
Contains(Bounds<T>)
[Pure]
public bool Contains(Bounds<T> other)
Parameters
otherBounds<T>Range to check.
Returns
- bool
true when this range contains the provided
otherrange, otherwise false.
Contains(T)
[Pure]
public bool Contains(T value)
Parameters
valueTValue 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
otherBounds<T>Range to check.
Returns
- bool
true when this exclusive range contains the provided
otherrange, otherwise false.
ContainsExclusively(T)
[Pure]
public bool ContainsExclusively(T value)
Parameters
valueTValue 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
otherBounds<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
objobjectThe object to compare with the current instance.
Returns
- bool
true if
objand 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
otherBounds<T>Range to check.
Returns
Intersects(Bounds<T>)
[Pure]
public bool Intersects(Bounds<T> other)
Parameters
otherBounds<T>Range to check.
Returns
- bool
true when this range intersects with the provided
otherrange, otherwise false.
MergeWith(Bounds<T>)
[Pure]
public Bounds<T>? MergeWith(Bounds<T> other)
Parameters
otherBounds<T>Range to merge.
Returns
Remove(Bounds<T>)
[Pure]
public Pair<Bounds<T>?, Bounds<T>?> Remove(Bounds<T> other)
Parameters
otherBounds<T>Range to remove.
Returns
- Pair<Bounds<T>?, Bounds<T>?>
Pair of Bounds<T> instances when
otherrange is exclusively contained by this range, otherwise pair with both values equal to null whenotherrange 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
maxTMaximum 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
minTMinimum value.
Returns
Exceptions
- ArgumentException
When
minis greater than Max.
SplitAt(T)
[Pure]
public Pair<Bounds<T>, Bounds<T>?> SplitAt(T value)
Parameters
valueTValue to split at.
Returns
- Pair<Bounds<T>, Bounds<T>?>
Pair of Bounds<T> instances when
valueis 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.