DistancesModel

Constructors

Link copied to clipboard
constructor()

Types

Link copied to clipboard
inner class Location(aName: String? = null) : SpatialModel.AbstractLocation

Represents a location within this spatial model.

Properties

Link copied to clipboard
Link copied to clipboard
open override var defaultLocation: LocationIfc
Link copied to clipboard

The default distance from a location to itself, must be greater than or equal to 0.0

Link copied to clipboard

The default velocity for elements that move within the spatial model

Link copied to clipboard
Link copied to clipboard
val id: Int
Link copied to clipboard

The names of the locations.

Link copied to clipboard

The locations that have been added to the model.

Link copied to clipboard
Link copied to clipboard

Functions

Link copied to clipboard
fun addDistance(fromLoc: String, toLoc: String, distance: Double, symmetric: Boolean = false): Pair<LocationIfc, LocationIfc>

Adds the distance from location fromLoc to location toLoc where fromLoc and toLoc are string names of locations. If a location with the name does not already exist in the model, then a new location with the name is created. The flag symmetric will cause an additional distance to be added going from toLoc to location fromLoc that has the same distance. The default value of the flag is false. The pair must not have already been added to the model.

fun addDistance(fromLocation: LocationIfc, toLocation: LocationIfc, distance: Double, symmetric: Boolean = false)

Adds a distance value between the pair of locations, going from fromLocation to toLocation. The distance must be greater than or equal to 0.0. The flag symmetric will cause an additional distance to be added going from toLocation to location fromLocation that has the same distance. The default value of the flag is false. The pair must not have already been added to the model. Use changeDistance() in that case.

Link copied to clipboard

Assumes that matrix is square and contains the from-to distances. Any values on the diagonal are ignored. No values can be 0.0

Adds a list of distanceData to the model.

Link copied to clipboard
open override fun attachObserver(observer: ObserverIfc<SpatialElementIfc>)

Allows the adding (attaching) of an observer to the observable

Link copied to clipboard
fun changeDistance(fromLocation: LocationIfc, toLocation: LocationIfc, distance: Double)

Changes a distance value between the pair of locations, going from fromLocation to toLocation. The distance must be greater than or equal to 0.0. The pair must already be part of the model.

Link copied to clipboard
open override fun compareLocations(firstLocation: LocationIfc, secondLocation: LocationIfc): Boolean

For this model, this returns true if and only if the locations are the same object instances.

fun compareLocations(firstElement: SpatialElementIfc, secondElement: SpatialElementIfc): Boolean

Returns true if firstElement is the same as secondElement within the underlying spatial model. This is not object reference equality, but rather whether the elements within the underlying spatial model can be considered spatially (equivalent) according to the model. This may or may not imply that the distance between the elements is zero. No assumptions about distance are implied by true.

Link copied to clipboard
Link copied to clipboard
open override fun countObservers(): Int

Returns how many observers are currently attached to the observable

Link copied to clipboard
open override fun detachAllObservers()

Detaches all the observers from the observable

Link copied to clipboard
open override fun detachObserver(observer: ObserverIfc<SpatialElementIfc>)

Allows the deletion (removing) of an observer from the observable

Link copied to clipboard
open override fun distance(fromLocation: LocationIfc, toLocation: LocationIfc): Double

Computes the distance between fromLocation and toLocation based on the spatial model's distance metric

fun distance(fromElement: SpatialElementIfc, toElement: SpatialElementIfc): Double

Computes the distance between fromElement and toElement based on the spatial model's distance metric

Link copied to clipboard
open override fun isAttached(observer: ObserverIfc<SpatialElementIfc>): Boolean

Returns true if the observer is already attached

Link copied to clipboard

Checks if the spatial model contains the supplied element. True indicates that the element is within the spatial model. If the element has already been added to this spatial model then this method should return true

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
fun <T> Observable<T>.observe(block: (T?) -> Unit)
Link copied to clipboard
Link copied to clipboard
open fun stopTracking(element: SpatialElement)
Link copied to clipboard
open override fun toString(): String
Link copied to clipboard
open fun track(element: SpatialElement)

Causes the element to be tracked, held, by the spatial model. The user is responsible for maintaining this list