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>
-
- 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
-
-
Constructor Summary
Constructors Constructor Description OdHashedImpl(Class<? extends IdAble> idClass, IdGroupingToken groupId, OdZones zones)
ConstructorOdHashedImpl(OdHashedImpl<T> other)
Copy constructor, only shallow copy implemented, deep copy is to be implemented by parent because we do not want to enforce more type information on values
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract OdHashedImpl<T>
deepClone()
An id entity should always support a deep copy, i.e., all "owned" members will be deep copied when a clone of this instance is created via this call.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 OdHashedIterator<T>
iterator()
Returns an iterator which can iterate through all the origin-destination entriesvoid
setValue(Zone origin, Zone destination, T path)
Sets the value for a specified origin and destinationabstract OdHashedImpl<T>
shallowClone()
Create a shallow copy of this entity-
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
clone, 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, only shallow copy implemented, deep copy is to be implemented by parent because we do not want to enforce more type information on values- 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
-
shallowClone
public abstract OdHashedImpl<T> shallowClone()
Create a shallow copy of this entity- Specified by:
shallowClone
in interfaceIdAble
- Specified by:
shallowClone
in interfaceOdData<T>
- Specified by:
shallowClone
in classOdDataImpl<T>
- Returns:
- shallow copy of entity
-
deepClone
public abstract OdHashedImpl<T> deepClone()
An id entity should always support a deep copy, i.e., all "owned" members will be deep copied when a clone of this instance is created via this call. To be used with caution if not called by managed id container related code- Specified by:
deepClone
in interfaceIdAble
- Specified by:
deepClone
in classOdDataImpl<T>
- Returns:
- deep copy of entity
-
-