Package org.goplanit.utils.od
Class OdNonPrimitiveMatrix<T>
- java.lang.Object
-
- org.goplanit.utils.id.IdAbleImpl
-
- org.goplanit.utils.od.OdDataImpl<T>
-
- org.goplanit.utils.od.OdMatrixImpl<T,T[][]>
-
- org.goplanit.utils.od.OdNonPrimitiveMatrix<T>
-
- All Implemented Interfaces:
Cloneable
,Comparable<IdAble>
,Iterable<T>
,IdAble
,OdData<T>
,OdMatrix<T,T[][]>
- Direct Known Subclasses:
OdPathMatrix
public abstract class OdNonPrimitiveMatrix<T> extends OdMatrixImpl<T,T[][]>
This class contains common methods for handling origin-demand matrices where values are non primitive types, i.e. Objects of some type. Data container used is a raw array of a fixed size based on the Od number of zones. Cells that have no value entry will still take up space in this implementation. If the matrix is dense and contains very little empty cells, this is likely the most computationally efficient implementation, if not, consider other implementations that deal better with sparse matrices in terms of memory usage.- Author:
- gman6028m, markr
-
-
Field Summary
-
Fields inherited from class org.goplanit.utils.od.OdMatrixImpl
matrixContents
-
Fields inherited from class org.goplanit.utils.od.OdDataImpl
zones
-
-
Constructor Summary
Constructors Constructor Description OdNonPrimitiveMatrix(Class<? extends IdAble> idTokenClass, IdGroupingToken idToken, OdZones zones, T[][] matrixContents)
Constructor for full Od matrix containing non-primitives, i.e.OdNonPrimitiveMatrix(OdNonPrimitiveMatrix<T> other)
Copy constructor
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description T
getValue(long originId, long destinationId)
Returns the value for a specified origin and destination by their internal idT
getValue(Zone origin, Zone destination)
Returns the value for a specified origin and destinationabstract OdMatrixIterator<T,T[][]>
iterator()
Returns an iterator which can iterate through all the origin-destination cells in the matrixvoid
setValue(Zone origin, Zone destination, T value)
Sets the value for a specified origin and destination-
Methods inherited from class org.goplanit.utils.od.OdMatrixImpl
clone
-
Methods inherited from class org.goplanit.utils.od.OdDataImpl
getNumberOfOdZones, getOdZones
-
Methods inherited from class org.goplanit.utils.id.IdAbleImpl
equals, generateAndSetId, generateId, getId, hashCode, setId
-
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.goplanit.utils.id.IdAble
compareTo, getId, idEquals, idHashCode
-
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Methods inherited from interface org.goplanit.utils.od.OdData
getNumberOfOdZones
-
-
-
-
Constructor Detail
-
OdNonPrimitiveMatrix
public OdNonPrimitiveMatrix(Class<? extends IdAble> idTokenClass, IdGroupingToken idToken, OdZones zones, T[][] matrixContents)
Constructor for full Od matrix containing non-primitives, i.e. object based- Parameters:
idTokenClass
- to use for id generationidToken
- to use for the matrix idzones
- holder for zones considered in the matrixmatrixContents
- container for the matrix contents
-
OdNonPrimitiveMatrix
public OdNonPrimitiveMatrix(OdNonPrimitiveMatrix<T> other)
Copy constructor- Parameters:
other
- to copy from
-
-
Method Detail
-
setValue
public void setValue(Zone origin, Zone destination, T value)
Sets the value for a specified origin and destination- Parameters:
origin
- specified origindestination
- specified destinationvalue
- value at the specified cell
-
getValue
public T getValue(Zone origin, Zone destination)
Returns the value for a specified origin and destination- Parameters:
origin
- specified origindestination
- specified destination- Returns:
- value at the specified cell
-
getValue
public T getValue(long originId, long destinationId)
Returns the value for a specified origin and destination by their internal id- Parameters:
originId
- specified origindestinationId
- specified destination- Returns:
- value at the specified cell
-
iterator
public abstract OdMatrixIterator<T,T[][]> iterator()
Returns an iterator which can iterate through all the origin-destination cells in the matrix
-
-