Class Range<TValue>
- Namespace
- Bonsai
- Assembly
- Bonsai.Core.dll
Represents a range of values defined by an inclusive lower and upper bounds.
public sealed class Range<TValue> : IEquatable<Range<TValue>>
Type Parameters
TValueThe type of values in the range.
- Inheritance
-
Range<TValue>
- Implements
-
IEquatable<Range<TValue>>
- Inherited Members
Constructors
Range(TValue, TValue)
Initializes a new instance of the Range<TValue> class with the specified lower and upper bounds.
public Range(TValue lowerBound, TValue upperBound)
Parameters
lowerBoundTValueThe inclusive lower bound of the range.
upperBoundTValueThe inclusive upper bound of the range.
Range(TValue, TValue, IComparer<TValue>)
Initializes a new instance of the Range<TValue> class with the specified lower and upper bounds and using the specified comparer.
public Range(TValue lowerBound, TValue upperBound, IComparer<TValue> comparer)
Parameters
lowerBoundTValueThe inclusive lower bound of the range.
upperBoundTValueThe inclusive upper bound of the range.
comparerIComparer<TValue>An IComparer<T> to use to compare values.
Properties
LowerBound
Gets the inclusive lower bound of the range.
public TValue LowerBound { get; }
Property Value
- TValue
UpperBound
Gets the inclusive upper bound of the range.
public TValue UpperBound { get; }
Property Value
- TValue
Methods
Contains(TValue)
Tests whether a specified value falls within the range.
public bool Contains(TValue value)
Parameters
valueTValueThe value to test.
Returns
- bool
true if
valueis between or equal to the lower and upper bound values of this instance; otherwise, false.
Equals(Range<TValue>)
Returns a value indicating whether this instance has the same lower and upper bounds as a specified Range<TValue> object.
public bool Equals(Range<TValue> other)
Parameters
otherRange<TValue>The Range<TValue> object to compare to this instance.
Returns
Equals(object)
Tests to see whether the specified object is a Range<TValue> object with the same lower and upper bounds as this Range<TValue> instance.
public override bool Equals(object obj)
Parameters
objobjectThe object to compare with this instance.
Returns
- bool
true if
objis a Range<TValue> and has the same lower and upper bounds as this Range<TValue>; otherwise, false.
GetHashCode()
Returns a hash code for the current instance.
public override int GetHashCode()
Returns
- int
The hash code for the current instance.
ToString()
Creates a string representation of this Range<TValue>.
public override string ToString()
Returns
- string
A string containing the lower and upper bound values of this Range<TValue>.
Operators
operator ==(Range<TValue>, Range<TValue>)
Tests whether two Range<TValue> objects are equal.
public static bool operator ==(Range<TValue> left, Range<TValue> right)
Parameters
leftRange<TValue>The Range<TValue> object on the left-hand side of the equality operator.
rightRange<TValue>The Range<TValue> object on the right-hand side of the equality operator.
Returns
operator !=(Range<TValue>, Range<TValue>)
Tests whether two Range<TValue> objects are different.
public static bool operator !=(Range<TValue> left, Range<TValue> right)
Parameters
leftRange<TValue>The Range<TValue> object on the left-hand side of the inequality operator.
rightRange<TValue>The Range<TValue> object on the right-hand side of the inequality operator.