Class EdgesImpl<V extends Vertex,​E extends Edge>

  • All Implemented Interfaces:
    Iterable<E>, Edges<E>

    public class EdgesImpl<V extends Vertex,​E extends Edge>
    extends Object
    implements Edges<E>
    Implementation of Edges interface
    Author:
    markr
    • Constructor Detail

      • EdgesImpl

        public EdgesImpl​(GraphBuilder<V,​E> graphBuilder)
        Constructor
        Parameters:
        graphBuilder - the builder for edge implementations
    • Method Detail

      • updateIdMapping

        protected void updateIdMapping()
        updates the edge map keys based on edge ids in case an external force has changed already registered edges
      • register

        public E register​(E edge)
        Add edge to the internal container. Do not use this unless you know what you are doing because it can mess up the contiguous internal id structure of the edges. PReferred method is to only use registerNew.
        Parameters:
        edge - edge to be registered in this network based on its internal id
        Returns:
        edge, in case it overrides an existing edge, the removed edge is returned
      • remove

        public void remove​(E edge)
        remove an edge.
        Specified by:
        remove in interface Edges<V extends Vertex>
        Parameters:
        edge - to remove
      • remove

        public void remove​(long edgeId)
        remove an edge.
        Specified by:
        remove in interface Edges<V extends Vertex>
        Parameters:
        edgeId - of the edge to remove
      • registerNew

        public E registerNew​(Vertex vertexA,
                             Vertex vertexB,
                             double length,
                             boolean registerOnVertices)
                      throws PlanItException
        Create new edge to network identified via its id, allow to be registered on vertices if indicated)
        Specified by:
        registerNew in interface Edges<V extends Vertex>
        Parameters:
        vertexA - the first vertex in this edge
        vertexB - the second certex in this edge
        length - the length of this edge
        registerOnVertices - choice to register new edge on the vertices or not
        Returns:
        the created edge
        Throws:
        PlanItException - thrown if there is an error
      • get

        public E get​(long id)
        Get edge by id
        Specified by:
        get in interface Edges<V extends Vertex>
        Parameters:
        id - the id of the edge
        Returns:
        the retrieved edge, null if not present
      • size

        public int size()
        Get the number of edges in the graph
        Specified by:
        size in interface Edges<V extends Vertex>
        Returns:
        the number of edges in the graph
      • isEmpty

        public boolean isEmpty()
        Check if is empty
        Specified by:
        isEmpty in interface Edges<V extends Vertex>
        Returns:
        true when no edges, false otherwise
      • registerUniqueCopyOf

        public E registerUniqueCopyOf​(E edgeToCopy)
        copy the passed in edge and register it
        Specified by:
        registerUniqueCopyOf in interface Edges<V extends Vertex>
        Parameters:
        edgeToCopy - as is except for its ids which will be updated to makeit uniquely identifiable
        Returns:
        copy of edge now registered