package grid
This package contains tools for working with grid-like two-dimensional structures.
The contents of this package have aliases in the top-level package o1, so they
are accessible to students simply via import o1._
.
- Alphabetic
- By Inheritance
- grid
- AnyRef
- Any
- Hide All
- Show All
- Public
- Protected
Type Members
- sealed abstract class CompassDir extends Product with Serializable
The class
CompassDir
represents the cardinal compass directions in a grid-like coordinate system.The class
CompassDir
represents the cardinal compass directions in a grid-like coordinate system. There are exactly four instances of this class:North
,East
,South
andWest
, which are also defined in this package.All the
CompassDir
objects are immutable.This class and its instances have aliases in the top-level package o1, so they are accessible to students simply via
import o1._
.- See also
- abstract class Grid[Element] extends AnyRef
The class
Grid
represents rectangular grids that contain elements of a particular kind.The class
Grid
represents rectangular grids that contain elements of a particular kind. Each element in a grid is located at a unique pair of coordinates, represented as a GridPos.X coordinates run from 0 to
width-1
, y coordinates from 0 toheight-1
. (0,0) corresponds to the upper left corner of the grid.There are different kinds of grids: the type of element that a grid contains is defined by a type parameter. For instance
Grid[Square]
is a grid where each pair of x and y coordinates contains aSquare
object, andGrid[House]
is a grid containingHouse
objects.A
Grid
is mutable: it is possible to replace an element at a particularGridPos
with another. (Depending on the element type, the elements may be individually mutable, too.) The width and height of a grid never change, however.Upon creation, a
Grid
initializes itself by calling initialElements, which produces an initial state for the grid.This class has an alias in the top-level package o1, so it’s accessible to students simply via
import o1._
. - 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.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" andy
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
Value Members
- object CompassDir extends Serializable
This companion object of class
CompassDir
provides a selection of related constants and utility methods.This companion object of class
CompassDir
provides a selection of related constants and utility methods.This object has an alias in the top-level package o1, so it’s accessible to students simply via
import o1._
.