DirectPosition2D class
class DirectPosition2D {
final double x;
final double y;
const DirectPosition2D(num x, num y):
this.x= x.toDouble(), this.y=y.toDouble();
int compareTo(other) {
_require(other is DirectPosition2D);
int ret = x.compareTo(other.x);
return ret != 0 ? ret : y.compareTo(other.y);
}
String toString() => "($x, $y)";
int get hashCode {
const prime = 31;
int result = 1;
result = prime * result + x.hashCode;
result = prime * result + y.hashCode;
return result;
}
bool operator ==(other) => compareTo(other) == 0;
bool operator <(other) => compareTo(other) == -1;
bool operator <=(other) => compareTo(other) <= 0;
bool operator >(other) => compareTo(other) == 1;
bool operator >=(other) => compareTo(other) >= 0;
}
Constructors
Properties
final int hashCode #
Get a hash code for this object.
All objects have hash codes. Hash codes are guaranteed to be the
same for objects that are equal when compared using the equality
operator ==. Other than that there are no guarantees about
the hash codes. They will not be consistent between runs and
there are no distribution guarantees.
If a subclass overrides hashCode it should override the equality operator as well to maintain consistency.
docs inherited from Object
int get hashCode {
const prime = 31;
int result = 1;
result = prime * result + x.hashCode;
result = prime * result + y.hashCode;
return result;
}
Operators
bool operator ==(other) #
The equality operator.
The default behavior for all Objects is to return true if and
only if this and
other are the same object.
If a subclass overrides the equality operator it should override the hashCode method as well to maintain consistency.
docs inherited from Object
bool operator ==(other) => compareTo(other) == 0;