Package org.arakhne.afc.math.graph
Class GraphIterationElement<ST extends GraphSegment<ST,PT>,PT extends GraphPoint<PT,ST>>
- java.lang.Object
-
- org.arakhne.afc.math.graph.GraphIterationElement<ST,PT>
-
- Type Parameters:
PT
- is the type of node in the graphST
- is the type of edge in the graph
- All Implemented Interfaces:
Comparable<Object>
,JsonableObject
public class GraphIterationElement<ST extends GraphSegment<ST,PT>,PT extends GraphPoint<PT,ST>> extends Object implements Comparable<Object>, JsonableObject
Describe an element of the graph during an iteration.- Since:
- 13.0
- Version:
- 17.0 2020-01-04 14:41:42
- Author:
- Stéphane GALLAND
- Maven Group Id:
- org.arakhne.afc.core
- Maven Artifact Id:
- mathgraph
-
-
Field Summary
Fields Modifier and Type Field Description (package private) PT
connectionPoint
Connection point between the previous segment and the current segment.(package private) boolean
culDeSac
Indicates if the current segment is a cul-de-sac.(package private) ST
currentSegment
Current segment in the iteration.(package private) double
distanceToReach
Distance that was consumed for reaching the connection point.(package private) boolean
fromStartPoint
Previous element in the iteration.(package private) boolean
lastReachableSegment
Indicates if the segment is the last segment to be reachable in the current exploration branch.(package private) ST
previousSegment
Previous element in the iteration.(package private) boolean
replied
Indicates if this element was replied by the iterator.
-
Constructor Summary
Constructors Constructor Description GraphIterationElement(ST previousSegment1, ST segment, PT point, boolean fromStartPoint, double distanceToReach1, double distanceToConsume1)
Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected int
compareSegments(GraphSegment<?,?> firstSegment, GraphSegment<?,?> secondSegment)
Compare the two given segments.int
compareTo(Object obj)
boolean
equals(Object obj)
double
getDistanceToConsume()
Replies the distance that is not yet consumed.double
getDistanceToReachSegment()
Replies the distance needed to reach the segment.PT
getPoint()
Replies the entry point on the segment.ST
getPreviousSegment()
Replies the segment from which the iterator arrived on the current segment.ST
getSegment()
Replies the segment.int
hashCode()
boolean
isCulDeSac()
Replies if this segment is a cul-de-sac ie if the next connection point is only connected to this segment.boolean
isTerminalSegment()
Replies if this segment is the last which will be reached by the iterator.(package private) void
setTerminalSegment(boolean isTerminal)
Set the flag that indicating if this segment is the last which will be reached by the iterator.void
toJson(JsonBuffer buffer)
Replies the Json representation of this node.String
toString()
-
-
-
Field Detail
-
previousSegment
ST extends GraphSegment<ST,PT> previousSegment
Previous element in the iteration.
-
currentSegment
final ST extends GraphSegment<ST,PT> currentSegment
Current segment in the iteration.
-
connectionPoint
final PT extends GraphPoint<PT,ST> connectionPoint
Connection point between the previous segment and the current segment.
-
fromStartPoint
final boolean fromStartPoint
Previous element in the iteration.
-
distanceToReach
double distanceToReach
Distance that was consumed for reaching the connection point.
-
culDeSac
boolean culDeSac
Indicates if the current segment is a cul-de-sac.
-
lastReachableSegment
boolean lastReachableSegment
Indicates if the segment is the last segment to be reachable in the current exploration branch. This may indicates that the iteration algorithm is not allowed to go deeper in exploration from the current segment.
-
replied
boolean replied
Indicates if this element was replied by the iterator.
-
-
Constructor Detail
-
GraphIterationElement
GraphIterationElement(ST previousSegment1, ST segment, PT point, boolean fromStartPoint, double distanceToReach1, double distanceToConsume1)
Constructor.- Parameters:
previousSegment1
- is the previous element that permits to reach this object during an iterationsegment
- is the current segmentpoint
- is the point on which the iteration arrived on the current segment.fromStartPoint
- indicates if the current search is reached from its start point. This parameter is useful when the current segment is connected to the same road connected with its start point and its end point.distanceToReach1
- is the distance that is already consumed to reach the segment.distanceToConsume1
- is the distance to consume including this segment length.
-
-
Method Detail
-
getPreviousSegment
@Pure public ST getPreviousSegment()
Replies the segment from which the iterator arrived on the current segment.- Returns:
- the segment from which the iterator arrived on the current segment.
-
getSegment
@Pure public ST getSegment()
Replies the segment.- Returns:
- the segment.
-
getPoint
@Pure public PT getPoint()
Replies the entry point on the segment.- Returns:
- the entry point on the segment.
-
getDistanceToReachSegment
@Pure public final double getDistanceToReachSegment()
Replies the distance needed to reach the segment.- Returns:
- the distance to reach the starting point of the segment. The value could be negative in case the iterations start from inside the segment.
-
getDistanceToConsume
@Pure public final double getDistanceToConsume()
Replies the distance that is not yet consumed.- Returns:
- the distance that could be consumed.
- Since:
- 16.0
-
toJson
@Pure public void toJson(JsonBuffer buffer)
Description copied from interface:JsonableObject
Replies the Json representation of this node.- Specified by:
toJson
in interfaceJsonableObject
- Parameters:
buffer
- the Json buffer.
-
compareTo
@Pure public final int compareTo(Object obj)
- Specified by:
compareTo
in interfaceComparable<ST extends GraphSegment<ST,PT>>
-
compareSegments
@Pure protected int compareSegments(GraphSegment<?,?> firstSegment, GraphSegment<?,?> secondSegment)
Compare the two given segments.- Parameters:
firstSegment
- the first segment to compare to the second segment.secondSegment
- the second segment to compare to the first segment.- Returns:
-1
iffirstSegment
is lower thansecondSegment
,1
iffirstSegment
is greater thansecondSegment
, or0
iffirstSegment
is equal tosecondSegment
.
-
isCulDeSac
@Pure public final boolean isCulDeSac()
Replies if this segment is a cul-de-sac ie if the next connection point is only connected to this segment.- Returns:
true
if this segment is a cul-de-sac, otherwisefalse
-
isTerminalSegment
@Pure public final boolean isTerminalSegment()
Replies if this segment is the last which will be reached by the iterator. It means that the iterator will not pass this segment and continue the iterations on the following graph branches.Of course a segment with a cul-de-sac end is always assumed as a terminal segment.
- Returns:
true
if this segment is terminal, otherwisefalse
-
setTerminalSegment
final void setTerminalSegment(boolean isTerminal)
Set the flag that indicating if this segment is the last which will be reached by the iterator. It means that the iterator will not pass this segment and continue the iterations on the following graph branches.- Parameters:
isTerminal
- indicates if the current segment is terminal.
-
-