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
CompassDirrepresents the cardinal compass directions in a grid-like coordinate system.The class
CompassDirrepresents the cardinal compass directions in a grid-like coordinate system. There are exactly four instances of this class:North,East,SouthandWest, which are also defined in this package.All the
CompassDirobjects 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
Gridrepresents rectangular grids that contain elements of a particular kind.The class
Gridrepresents 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 aSquareobject, andGrid[House]is a grid containingHouseobjects.A
Gridis mutable: it is possible to replace an element at a particularGridPoswith 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
Gridinitializes 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
GridPosrepresents a pair of integer coordinates on two axes named x and y.An object of type
GridPosrepresents 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,
xincreases "eastwards" andyincreases "southwards".GridPosobjecta 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
CompassDirprovides a selection of related constants and utility methods.This companion object of class
CompassDirprovides 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._.