case class GridPos(x: Int, y: Int) extends Product with Serializable
An object of type GridPos
represents a pair of integer coordinates on two axes named x and y.
Such a pair can be used to reference a point on a Grid.
In this coordinate system, x
increases "eastwards" and y
increases "southwards".
GridPos
objecta are immutable.
This class has an alias in the top-level package o1, so it’s accessible to students
simply via import o1._
.
- x
an x coordinate
- y
a y coordinate
- Alphabetic
- By Inheritance
- GridPos
- Serializable
- Product
- Equals
- AnyRef
- Any
- Hide All
- Show All
- Public
- Protected
Instance Constructors
- new GridPos(x: Int, y: Int)
- x
an x coordinate
- y
a y coordinate
Value Members
- final def !=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def ##(): Int
- Definition Classes
- AnyRef → Any
- def ==(another: GridPos): Boolean
Determines whether this grid position equals the given one.
Determines whether this grid position equals the given one. This is the case if the two have identical x and y coordinates.
- final def ==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def asInstanceOf[T0]: T0
- Definition Classes
- Any
- def clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.CloneNotSupportedException]) @native() @HotSpotIntrinsicCandidate()
- def diff(another: GridPos): (Int, Int)
Returns the xDiff and yDiff between this
GridPos
and the given one as a pair. - def distance(another: GridPos): Int
Returns the "grid distance" between this
GridPos
and the given one.Returns the "grid distance" between this
GridPos
and the given one. The grid distance betweena
andb
equalsa.xDiff(b).abs + a.yDiff(b).abs
. - final def eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- final def getClass(): Class[_ <: AnyRef]
- Definition Classes
- AnyRef → Any
- Annotations
- @native() @HotSpotIntrinsicCandidate()
- final def isInstanceOf[T0]: Boolean
- Definition Classes
- Any
- final def ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- def neighbor(direction: CompassDir): GridPos
Returns a grid position that "neighbors" this one in the given direction.
Returns a grid position that "neighbors" this one in the given direction. For instance, if this position has an
x
of 10 and ay
of 20, and thedirection
parameter is given the valueCompassDir.South
, then the result has anx
of 10 and ay
of 21. Calling this method is essentially the same as callingrelative
with adistance
of one. - final def notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native() @HotSpotIntrinsicCandidate()
- final def notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native() @HotSpotIntrinsicCandidate()
- def pathTowards(direction: CompassDir): LazyList[GridPos]
Returns an infinite lazy-list of locations at increasing distances from this
GridPos
in the given direction.Returns an infinite lazy-list of locations at increasing distances from this
GridPos
in the given direction. For example, if thisGridPos
is (10,1), and the direction isSouth
, returns a list of (10,2), (10,3), (10,4), etc. - def productElementNames: Iterator[String]
- Definition Classes
- Product
- def relative(direction: CompassDir, distance: Int): GridPos
Returns another grid position that is in the given direction from this one and at a given distance.
Returns another grid position that is in the given direction from this one and at a given distance.
For instance, say this position has an
x
of 10 and ay
of 20. Ifdirection
isCompassDir.North
anddistance
is 3, then the result has anx
of 10 and ay
of 17.- See also
- final def synchronized[T0](arg0: => T0): T0
- Definition Classes
- AnyRef
- def toString: String
Returns a textual description of this position.
Returns a textual description of this position. The description is of the form
"(x,y)"
.- Definition Classes
- GridPos → AnyRef → Any
- final def wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException]) @native()
- final def wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- val x: Int
- def xDiff(another: GridPos): Int
Returns the difference between the x coordinate of this
GridPos
and that of the givenGridPos
.Returns the difference between the x coordinate of this
GridPos
and that of the givenGridPos
. The result is negative if the x coordinate of thisGridPos
is greater. - def xDirectionOf(another: GridPos): Option[CompassDir]
Determines if the given
GridPos
is west or east of this one.Determines if the given
GridPos
is west or east of this one. ReturnsEast
if thisGridPos
’s x coordinate is less thananother
’s andWest
if the opposite is true. Wraps that return value in anOption
;None
means that the x coordinates are equal. - val y: Int
- def yDiff(another: GridPos): Int
Returns the difference between the y coordinate of this
GridPos
and that of the givenGridPos
.Returns the difference between the y coordinate of this
GridPos
and that of the givenGridPos
. The result is negative if the y coordinate of thisGridPos
is greater. - def yDirectionOf(another: GridPos): Option[CompassDir]
Determines if the given
GridPos
is north or south of this one.Determines if the given
GridPos
is north or south of this one. ReturnsSouth
if thisGridPos
’s y coordinate is less thananother
’s andNorth
if the opposite is true. Wraps that direction in anOption
;None
means that the y coordinates are equal.
Deprecated Value Members
- def finalize(): Unit
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.Throwable]) @Deprecated @deprecated
- Deprecated
(Since version ) see corresponding Javadoc for more information.