Class 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
    • Constructor Detail

      • OdHashedImpl

        public OdHashedImpl​(Class<? extends IdAble> idClass,
                            IdGroupingToken groupId,
                            OdZones zones)
        Constructor
        Parameters:
        idClass - concrete class to use for id generation
        groupId - contiguous id generation within this group for instances of this class
        zones - 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
        Specified by:
        getValue in interface OdData<T>
        Parameters:
        origin - specified origin
        destination - 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
        Specified by:
        getValue in interface OdData<T>
        Parameters:
        originId - specified origin
        destinationId - specified destination
        Returns:
        value at the specified cell
      • setValue

        public void setValue​(Zone origin,
                             Zone destination,
                             T path)
        Sets the value for a specified origin and destination
        Specified by:
        setValue in interface OdData<T>
        Parameters:
        origin - specified origin
        destination - specified destination
        path - value at the specified cell
      • iterator

        public abstract OdHashedIterator<T> iterator()
        Returns an iterator which can iterate through all the origin-destination entries
        Specified by:
        iterator in interface Iterable<T>
        Specified by:
        iterator in interface OdData<T>
        Specified by:
        iterator in interface OdHashed<T>
        Returns:
        iterator through all available non-empty origin-destination entries
      • clone

        public abstract OdHashedImpl<T> clone()
        Create a shallow copy of this entity
        Specified by:
        clone in interface IdAble
        Specified by:
        clone in class OdDataImpl<T>
        Returns:
        shallow copy of entity