Packages

c

o1.city

CityMap

class CityMap extends o1.Grid[Demographic]

A CityMap is a square grid that represents a simplified map of a city. It is a Grid whose elements are Demographic objects. That is, each GridPos ("street address") on a CityMap is either Vacant or stores a household that belongs to aparticular demographic.

A CityMap is mutable. As a household moves, the corresponding Demographic object moves to a different GridPos on the CityMap.

Linear Supertypes
grid.Grid[Demographic], AnyRef, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. CityMap
  2. Grid
  3. AnyRef
  4. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. Protected

Instance Constructors

  1. new CityMap(homesPerSide: Int, populations: Vector[(Demographic, Int)])

    homesPerSide

    the number of street addresses in each row and each column of the city grid (which is always square)

    populations

    a vector of pairs in which each Demographic is matched with a count of how many times it appears on this city map

Value Members

  1. final def !=(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  4. def allElements: Vector[Demographic]

    Returns a collection of all the elements currently in the grid.

    Returns a collection of all the elements currently in the grid.

    Definition Classes
    Grid
  5. def allPositions: Vector[grid.GridPos]

    Returns a collection of all the locations on the grid.

    Returns a collection of all the locations on the grid.

    Definition Classes
    Grid
  6. def apply(location: grid.GridPos): Demographic

    Returns the element at the given pair of coordinates.

    Returns the element at the given pair of coordinates. (This does the same as elementAt.)

    location

    a location on the grid (must be within range)

    Definition Classes
    Grid
  7. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  8. def clone(): AnyRef
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.CloneNotSupportedException]) @native() @HotSpotIntrinsicCandidate()
  9. def contains(location: grid.GridPos): Boolean

    Determines whether the grid contains the given pair of coordinates.

    Determines whether the grid contains the given pair of coordinates. For instance,a grid with a width and height of 5 will contain (0, 0) and (4, 4) but not (-1, -1), (4, 5) or (5, 4).

    Definition Classes
    Grid
  10. def elementAt(location: grid.GridPos): Demographic

    Returns the element at the given pair of coordinates.

    Returns the element at the given pair of coordinates. (This does the same as apply.)

    location

    a location on the grid (must be within range)

    Definition Classes
    Grid
  11. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  12. def equals(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef → Any
  13. final def getClass(): Class[_ <: AnyRef]
    Definition Classes
    AnyRef → Any
    Annotations
    @native() @HotSpotIntrinsicCandidate()
  14. def hashCode(): Int
    Definition Classes
    AnyRef → Any
    Annotations
    @native() @HotSpotIntrinsicCandidate()
  15. val height: Int
    Definition Classes
    Grid
  16. def initialElements: Seq[Demographic]

    Generates the elements that initially occupy the grid.

    Generates the elements that initially occupy the grid. In the case of a CityMap grid, this means generating new Demographic objects at random locations so that their distribution matches the populations parameter of the CityMap.

    returns

    a collection of size width times height that contains the initial grid elements. The first element in the collection will appear at GridPos (0,0), the second at (1,0), and so on, filling in the first row before continuing on the second row at (1,0).

    Definition Classes
    CityMapGrid
  17. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  18. def matches(address: o1.GridPos, householdType: Demographic): Boolean

    Determines whether the household at the given "street address" (GridPos) belongs to the given demographic.

    Determines whether the household at the given "street address" (GridPos) belongs to the given demographic.

    address

    a location on the city grid to examine

    householdType

    a demographic that the household at the given address is compared to (may be Vacant, too, in which case this method checks if the address is vacant)

  19. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  20. def neighbors(middleLoc: grid.GridPos, includeDiagonals: Boolean): Vector[Demographic]

    Returns a vector of all the neighboring elements of the indicated element.

    Returns a vector of all the neighboring elements of the indicated element. Depending on the value of the second parameter, either only the four neighbors in cardinal compass directions (north, east, south, west) are considered, or the four diagonals as well.

    Note that an element that is at the edge of the grid has fewer neighbors than one in the middle. For instance, the element at (0, 0) of a 5-by-5 grid has only three neighbors, diagonals included.

    middleLoc

    the location between the neighbors

    includeDiagonals

    true if diagonal neighbors also count (resulting in up to eight neighbors), false if only cardinal directions count (resulting in up to four)

    Definition Classes
    Grid
  21. final def notify(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native() @HotSpotIntrinsicCandidate()
  22. final def notifyAll(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native() @HotSpotIntrinsicCandidate()
  23. val size: Int

    the number of elements in this grid, in total.

    the number of elements in this grid, in total. (Equals width times height.)

    Definition Classes
    Grid
  24. def swap(location1: grid.GridPos, location2: grid.GridPos): Unit

    Swaps the elements at two given locations on the grid, which must be within range.

    Swaps the elements at two given locations on the grid, which must be within range.

    Definition Classes
    Grid
  25. final def synchronized[T0](arg0: => T0): T0
    Definition Classes
    AnyRef
  26. def toString: String
    Definition Classes
    AnyRef → Any
  27. def update(location: grid.GridPos, newElement: Demographic): Unit

    Modifies the grid by replacing the existing element at the given location with the new element.

    Modifies the grid by replacing the existing element at the given location with the new element.

    location

    a location on the grid (must be within range)

    newElement

    the new element that replaces the old one at location

    Definition Classes
    Grid
  28. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])
  29. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException]) @native()
  30. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])
  31. val width: Int
    Definition Classes
    Grid

Deprecated Value Members

  1. 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.

Inherited from grid.Grid[Demographic]

Inherited from AnyRef

Inherited from Any

Ungrouped