Class LinksImpl<L extends Link>

  • Type Parameters:
    L - link type
    All Implemented Interfaces:
    Iterable<L>, Edges<L>, Links<L>

    public class LinksImpl<L extends Link>
    extends Object
    implements Links<L>
    Links implementation wrapper that simply utilises passed in edges of the desired generic type to delegate registration and creation of its links on
    Author:
    markr
    • Constructor Detail

      • LinksImpl

        public LinksImpl​(Edges<L> edges)
        Constructor
        Parameters:
        edges - the edges to use to create and register links on
    • Method Detail

      • remove

        public void remove​(L link)
        remove an edge.
        Specified by:
        remove in interface Edges<L extends Link>
        Parameters:
        link - to remove
      • remove

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

        public L registerNew​(Vertex vertexA,
                             Vertex vertexB,
                             double length,
                             boolean registerOnNodes)
                      throws PlanItException
        Create new link to network identified via its id, injecting link length directly
        Specified by:
        registerNew in interface Edges<L extends Link>
        Parameters:
        vertexA - the first node in this link
        vertexB - the second node in this link
        length - the length of this link
        registerOnNodes - choice to register new link on the nodes or not
        Returns:
        the created link
        Throws:
        PlanItException - thrown if there is an error
      • registerUniqueCopyOf

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

        public L get​(long id)
        Get edge by id
        Specified by:
        get in interface Edges<L extends Link>
        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<L extends Link>
        Returns:
        the number of edges in the graph
      • isEmpty

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