Improve arc memory management.

This commit is contained in:
Mikael Capelle
2018-03-05 17:58:59 +01:00
parent be1176c1e3
commit 98aba8dd06
9 changed files with 210 additions and 81 deletions

View File

@@ -4,7 +4,12 @@ import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
public class Arc {
/**
* Implementation of Arc that represents a "forward" arc in a graph, this is the
* arc implementation that stores data relative to the arc.
*
*/
public class ArcForward implements Arc {
// Destination node.
private final Node origin, destination;
@@ -27,7 +32,8 @@ public class Arc {
* @param roadInformation Road information for this arc.
* @param points Points representing this arc.
*/
public Arc(Node origin, Node dest, int length, RoadInformation roadInformation, ArrayList<Point> points) {
public ArcForward(Node origin, Node dest, int length, RoadInformation roadInformation,
ArrayList<Point> points) {
this.origin = origin;
this.destination = dest;
this.length = length;
@@ -37,42 +43,42 @@ public class Arc {
}
/**
* @return Origin node of this arc.
* {@inheritDoc}
*/
public Node getOrigin() {
return origin;
}
/**
* @return Destination node of this arc.
* {@inheritDoc}
*/
public Node getDestination() {
return destination;
}
/**
* @return Length of this arc, in meters.
* {@inheritDoc}
*/
public int getLength() {
return length;
}
/**
* @return Minimum time required to travel this arc, in seconds.
* {@inheritDoc}
*/
public double getMinimumTravelTime() {
return getLength() * 3600.0 / (info.getMaximumSpeed() * 1000.0);
}
/**
* @return Road information for this arc.
* {@inheritDoc}
*/
public RoadInformation getRoadInformation() {
return info;
}
/**
* @return Points representing segments of this arc.
* {@inheritDoc}
*/
public List<Point> getPoints() {
return Collections.unmodifiableList(points);