Package org.goplanit.utils.od
Class OdHashedImpl<T>
- java.lang.Object
-
- org.goplanit.utils.id.IdAbleImpl
-
- org.goplanit.utils.od.OdDataImpl<T>
-
- org.goplanit.utils.od.OdHashedImpl<T>
-
- All Implemented Interfaces:
Cloneable,Comparable<IdAble>,Iterable<T>,IdAble,OdData<T>,OdHashed<T>
- Direct Known Subclasses:
OdPathsHashed
public abstract class OdHashedImpl<T> extends OdDataImpl<T> implements OdHashed<T>
This class stores paths by their origin and destination by creating a unique hash for the combined ids of the od zones. This results in a memory efficient implementation requiring only a single hash based container, instead of having as many containers as their are origins. It also means only conducting a single lookup despite the fact we have two keys (o and d).- Author:
- markr
-
-
Field Summary
-
Fields inherited from class org.goplanit.utils.od.OdDataImpl
zones
-
-
Constructor Summary
Constructors Constructor Description OdHashedImpl(Class<? extends IdAble> idClass, IdGroupingToken groupId, OdZones zones)ConstructorOdHashedImpl(OdHashedImpl<T> other)Copy constructor (shallow copy of contents)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract OdHashedImpl<T>clone()Create a shallow copy of this entityTgetValue(long originId, long destinationId)Returns the value for a specified origin and destination by their internal idTgetValue(Zone origin, Zone destination)Returns the value for a specified origin and destinationabstract OdHashedIterator<T>iterator()Returns an iterator which can iterate through all the origin-destination entriesvoidsetValue(Zone origin, Zone destination, T path)Sets the value for a specified origin and destination-
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
-
OdHashedImpl
public OdHashedImpl(Class<? extends IdAble> idClass, IdGroupingToken groupId, OdZones zones)
Constructor- Parameters:
idClass- concrete class to use for id generationgroupId- contiguous id generation within this group for instances of this classzones- the zones being used
-
OdHashedImpl
public OdHashedImpl(OdHashedImpl<T> other)
Copy constructor (shallow copy of contents)- Parameters:
other- to copy from
-
-
Method Detail
-
getValue
public T getValue(Zone origin, Zone destination)
Returns the value for a specified origin and destination
-
getValue
public T getValue(long originId, long destinationId)
Returns the value for a specified origin and destination by their internal id
-
setValue
public void setValue(Zone origin, Zone destination, T path)
Sets the value for a specified origin and destination
-
iterator
public abstract OdHashedIterator<T> iterator()
Returns an iterator which can iterate through all the origin-destination entries
-
clone
public abstract OdHashedImpl<T> clone()
Create a shallow copy of this entity- Specified by:
clonein interfaceIdAble- Specified by:
clonein classOdDataImpl<T>- Returns:
- shallow copy of entity
-
-