Package org.planit.graph
Class EdgeSegmentsImpl<ES extends EdgeSegment>
- java.lang.Object
-
- org.planit.graph.EdgeSegmentsImpl<ES>
-
- All Implemented Interfaces:
Iterable<ES>
,EdgeSegments<ES>
public class EdgeSegmentsImpl<ES extends EdgeSegment> extends Object implements EdgeSegments<ES>
-
-
Field Summary
Fields Modifier and Type Field Description protected DirectedGraphBuilder<? extends DirectedVertex,? extends DirectedEdge,ES>
directedGraphBuilder
The graph builder to create edgse segments
-
Constructor Summary
Constructors Constructor Description EdgeSegmentsImpl(DirectedGraphBuilder<? extends DirectedVertex,? extends DirectedEdge,ES> graphBuilder)
Constructor
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ES
create(DirectedEdge parentEdge, boolean directionAB)
Create edge segmentES
get(long id)
Get edge segment by idES
getByXmlId(String xmlId)
Return an edge segment by its Xml id Note: not an efficient implementation since it loops over all edge segments in linear time to identify the correct one, preferably use get instead whenever possible.Iterator<ES>
iterator()
void
register(ES edgeSegment)
Register an edge segment.void
register(DirectedEdge parentEdge, ES edgeSegment, boolean directionAB)
Register a edge segment (not registered on nodes and edge)ES
registerNew(DirectedEdge parentEdge, boolean directionAb, boolean registerOnNodeAndLink)
Create directional edge segment and register itES
registerUniqueCopyOf(ES edgeSegmentToCopy, DirectedEdge newParentEdge)
copy the passed in edge segment and register it.void
remove(long edgeSegmentId)
Remove an edge segment by idvoid
remove(ES edgeSegment)
Remove an edges segmentlong
size()
Return number of registered edge segmentsprotected void
updateIdMapping()
updates the edge segments map keys based on edge segment ids in case an external force has changed already registered edges-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.planit.utils.graph.EdgeSegments
isEmpty
-
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
-
-
-
Field Detail
-
directedGraphBuilder
protected DirectedGraphBuilder<? extends DirectedVertex,? extends DirectedEdge,ES extends EdgeSegment> directedGraphBuilder
The graph builder to create edgse segments
-
-
Constructor Detail
-
EdgeSegmentsImpl
public EdgeSegmentsImpl(DirectedGraphBuilder<? extends DirectedVertex,? extends DirectedEdge,ES> graphBuilder)
Constructor- Parameters:
graphBuilder
- the grpahBuilder to use to create edge segments
-
-
Method Detail
-
updateIdMapping
protected void updateIdMapping()
updates the edge segments map keys based on edge segment ids in case an external force has changed already registered edges
-
register
public void register(ES edgeSegment)
Register an edge segment. Use cautiously, Only register via a factory method to ensure correct id generation within the container- Parameters:
edgeSegment
- the link segment to be registered
-
remove
public void remove(ES edgeSegment)
Remove an edges segment- Specified by:
remove
in interfaceEdgeSegments<ES extends EdgeSegment>
- Parameters:
edgeSegment
- to remove
-
remove
public void remove(long edgeSegmentId)
Remove an edge segment by id- Specified by:
remove
in interfaceEdgeSegments<ES extends EdgeSegment>
- Parameters:
edgeSegmentId
- to remove by id
-
iterator
public Iterator<ES> iterator()
- Specified by:
iterator
in interfaceIterable<ES extends EdgeSegment>
-
create
public ES create(DirectedEdge parentEdge, boolean directionAB) throws PlanItException
Create edge segment- Specified by:
create
in interfaceEdgeSegments<ES extends EdgeSegment>
- Parameters:
parentEdge
- the parent edge of this edge segmentdirectionAB
- direction of travel- Returns:
- the created edge segment
- Throws:
PlanItException
- thrown if there is an error
-
register
public void register(DirectedEdge parentEdge, ES edgeSegment, boolean directionAB) throws PlanItException
Register a edge segment (not registered on nodes and edge)- Specified by:
register
in interfaceEdgeSegments<ES extends EdgeSegment>
- Parameters:
parentEdge
- the parent edge which specified edge segment will be registered onedgeSegment
- edge segment to be registereddirectionAB
- direction of travel- Throws:
PlanItException
- thrown if there is an error
-
registerNew
public ES registerNew(DirectedEdge parentEdge, boolean directionAb, boolean registerOnNodeAndLink) throws PlanItException
Create directional edge segment and register it- Specified by:
registerNew
in interfaceEdgeSegments<ES extends EdgeSegment>
- Parameters:
parentEdge
- the parent edge of this edge segmentdirectionAb
- direction of travelregisterOnNodeAndLink
- option to register the new edge segment on the underlying edge and its vertices- Returns:
- the created edge segment
- Throws:
PlanItException
- thrown if there is an error
-
get
public ES get(long id)
Get edge segment by id- Specified by:
get
in interfaceEdgeSegments<ES extends EdgeSegment>
- Parameters:
id
- id of the edge segment- Returns:
- retrieved edge Segment
-
getByXmlId
public ES getByXmlId(String xmlId)
Return an edge segment by its Xml id Note: not an efficient implementation since it loops over all edge segments in linear time to identify the correct one, preferably use get instead whenever possible.- Specified by:
getByXmlId
in interfaceEdgeSegments<ES extends EdgeSegment>
- Parameters:
xmlId
- the XML id of the edge segment- Returns:
- the specified edge segment instance
-
size
public long size()
Return number of registered edge segments- Specified by:
size
in interfaceEdgeSegments<ES extends EdgeSegment>
- Returns:
- number of registered edge segments
-
registerUniqueCopyOf
public ES registerUniqueCopyOf(ES edgeSegmentToCopy, DirectedEdge newParentEdge)
copy the passed in edge segment and register it.- Specified by:
registerUniqueCopyOf
in interfaceEdgeSegments<ES extends EdgeSegment>
- Parameters:
edgeSegmentToCopy
- as is except for its ids which will be updated to make it uniquely identifiablenewParentEdge
- update the parent edge to passed in edge- Returns:
- copy of edge segment now registered
-
-