Rename Instance -> Data.

This commit is contained in:
Mikael Capelle 2018-02-20 12:03:18 +01:00
parent 960d1b1845
commit 3a17f55571
13 changed files with 58 additions and 58 deletions

View file

@ -6,15 +6,15 @@ import java.util.ArrayList;
public abstract class AbstractAlgorithm<Observer> {
protected AbstractInstance instance;
protected AbstractData instance;
protected ArrayList<Observer> observers;
protected AbstractAlgorithm(AbstractInstance instance) {
protected AbstractAlgorithm(AbstractData instance) {
this.instance = instance;
this.observers = new ArrayList<Observer>();
}
protected AbstractAlgorithm(AbstractInstance instance, ArrayList<Observer> observers) {
protected AbstractAlgorithm(AbstractData instance, ArrayList<Observer> observers) {
this.instance = instance;
this.observers = observers;;
}
@ -38,7 +38,7 @@ public abstract class AbstractAlgorithm<Observer> {
/**
* @return Instance corresponding to this algorithm.
*/
public AbstractInstance getInstance() { return instance; }
public AbstractData getInstance() { return instance; }
/**
* Run the algorithm and update the current solution.

View file

@ -2,7 +2,7 @@ package org.insa.algo;
import org.insa.graph.Graph;
public abstract class AbstractInstance {
public abstract class AbstractData {
protected Graph graph;
@ -11,7 +11,7 @@ public abstract class AbstractInstance {
*
* @param graph
*/
protected AbstractInstance(Graph graph) {
protected AbstractData(Graph graph) {
this.graph = graph;
}

View file

@ -22,20 +22,20 @@ public abstract class AbstractSolution {
Duration solvingTime;
// Original instance of the solution
AbstractInstance instance;
AbstractData instance;
/**
* Create a new abstract solution with unknown status.
*
* @param instance
*/
protected AbstractSolution(AbstractInstance instance) {
protected AbstractSolution(AbstractData instance) {
this.instance = instance;
this.solvingTime = Duration.ZERO;
this.status = Status.UNKNOWN;
}
protected AbstractSolution(AbstractInstance instance, Status status) {
protected AbstractSolution(AbstractData instance, Status status) {
this.instance = instance;
this.status = status;
}
@ -43,7 +43,7 @@ public abstract class AbstractSolution {
/**
* @return Original instance for this solution.
*/
public AbstractInstance getInstance() { return instance; }
public AbstractData getInstance() { return instance; }
/**
* @return Status of this solution.

View file

@ -9,7 +9,7 @@ public abstract class StronglyConnectedComponentsAlgorithm extends AbstractAlgor
* @param instance
* @param logOutput
*/
public StronglyConnectedComponentsAlgorithm(StronglyConnectedComponentsInstance instance) {
public StronglyConnectedComponentsAlgorithm(StronglyConnectedComponentsData instance) {
super(instance);
}
@ -19,8 +19,8 @@ public abstract class StronglyConnectedComponentsAlgorithm extends AbstractAlgor
}
@Override
public StronglyConnectedComponentsInstance getInstance() {
return (StronglyConnectedComponentsInstance)super.getInstance();
public StronglyConnectedComponentsData getInstance() {
return (StronglyConnectedComponentsData)super.getInstance();
}
}

View file

@ -0,0 +1,16 @@
package org.insa.algo.strongconnectivity;
import org.insa.algo.AbstractData;
import org.insa.graph.Graph;
public class StronglyConnectedComponentsData extends AbstractData {
/**
*
* @param graph
*/
public StronglyConnectedComponentsData(Graph graph) {
super(graph);
}
}

View file

@ -1,16 +0,0 @@
package org.insa.algo.strongconnectivity;
import org.insa.algo.AbstractInstance;
import org.insa.graph.Graph;
public class StronglyConnectedComponentsInstance extends AbstractInstance {
/**
*
* @param graph
*/
public StronglyConnectedComponentsInstance(Graph graph) {
super(graph);
}
}

View file

@ -10,11 +10,11 @@ public class StronglyConnectedComponentsSolution extends AbstractSolution {
// Components
private ArrayList<ArrayList<Node>> components;
protected StronglyConnectedComponentsSolution(StronglyConnectedComponentsInstance instance) {
protected StronglyConnectedComponentsSolution(StronglyConnectedComponentsData instance) {
super(instance);
}
protected StronglyConnectedComponentsSolution(StronglyConnectedComponentsInstance instance,
protected StronglyConnectedComponentsSolution(StronglyConnectedComponentsData instance,
Status status, ArrayList<ArrayList<Node>> components) {
super(instance, status);
this.components = components;

View file

@ -27,7 +27,7 @@ public class TarjanAlgorithm extends StronglyConnectedComponentsAlgorithm {
// Array of strongly connected components
ArrayList<ArrayList<Node>> components;
public TarjanAlgorithm(StronglyConnectedComponentsInstance instance) {
public TarjanAlgorithm(StronglyConnectedComponentsData instance) {
super(instance);
}

View file

@ -19,7 +19,7 @@ public class WeaklyConnectedComponentsAlgorithm extends AbstractAlgorithm<Weakly
* @param instance
* @param logOutput
*/
public WeaklyConnectedComponentsAlgorithm(WeaklyConnectedComponentsInstance instance) {
public WeaklyConnectedComponentsAlgorithm(WeaklyConnectedComponentsData instance) {
super(instance);
}
@ -29,8 +29,8 @@ public class WeaklyConnectedComponentsAlgorithm extends AbstractAlgorithm<Weakly
}
@Override
public WeaklyConnectedComponentsInstance getInstance() {
return (WeaklyConnectedComponentsInstance)super.getInstance();
public WeaklyConnectedComponentsData getInstance() {
return (WeaklyConnectedComponentsData)super.getInstance();
}
/**

View file

@ -0,0 +1,16 @@
package org.insa.algo.weakconnectivity;
import org.insa.algo.AbstractData;
import org.insa.graph.Graph;
public class WeaklyConnectedComponentsData extends AbstractData {
/**
*
* @param graph
*/
public WeaklyConnectedComponentsData(Graph graph) {
super(graph);
}
}

View file

@ -1,16 +0,0 @@
package org.insa.algo.weakconnectivity;
import org.insa.algo.AbstractInstance;
import org.insa.graph.Graph;
public class WeaklyConnectedComponentsInstance extends AbstractInstance {
/**
*
* @param graph
*/
public WeaklyConnectedComponentsInstance(Graph graph) {
super(graph);
}
}

View file

@ -10,11 +10,11 @@ public class WeaklyConnectedComponentsSolution extends AbstractSolution {
// Components
private ArrayList<ArrayList<Node>> components;
protected WeaklyConnectedComponentsSolution(WeaklyConnectedComponentsInstance instance) {
protected WeaklyConnectedComponentsSolution(WeaklyConnectedComponentsData instance) {
super(instance);
}
protected WeaklyConnectedComponentsSolution(WeaklyConnectedComponentsInstance instance,
protected WeaklyConnectedComponentsSolution(WeaklyConnectedComponentsData instance,
Status status, ArrayList<ArrayList<Node>> components) {
super(instance, status);
this.components = components;

View file

@ -41,12 +41,12 @@ import javax.swing.filechooser.FileNameExtensionFilter;
import org.insa.algo.shortestpath.BellmanFordAlgorithm;
import org.insa.algo.shortestpath.ShortestPathAlgorithm;
import org.insa.algo.shortestpath.ShortestPathGraphicObserver;
import org.insa.algo.shortestpath.ShortestPathInstance;
import org.insa.algo.shortestpath.ShortestPathInstance.Mode;
import org.insa.algo.shortestpath.ShortestPathData;
import org.insa.algo.shortestpath.ShortestPathData.Mode;
import org.insa.algo.shortestpath.ShortestPathSolution;
import org.insa.algo.weakconnectivity.WeaklyConnectedComponentGraphicObserver;
import org.insa.algo.weakconnectivity.WeaklyConnectedComponentsAlgorithm;
import org.insa.algo.weakconnectivity.WeaklyConnectedComponentsInstance;
import org.insa.algo.weakconnectivity.WeaklyConnectedComponentsData;
import org.insa.drawing.Drawing;
import org.insa.drawing.graph.BlackAndWhiteGraphPalette;
import org.insa.drawing.graph.GraphDrawing;
@ -456,7 +456,7 @@ public class MainWindow extends JFrame {
wccItem.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
WeaklyConnectedComponentsInstance instance = new WeaklyConnectedComponentsInstance(graph);
WeaklyConnectedComponentsData instance = new WeaklyConnectedComponentsData(graph);
WeaklyConnectedComponentsAlgorithm algo = new WeaklyConnectedComponentsAlgorithm(instance);
algo.addObserver(new WeaklyConnectedComponentGraphicObserver(drawing));
// algo.addObserver(new WeaklyConnectedComponentTextObserver(printStream));
@ -485,7 +485,7 @@ public class MainWindow extends JFrame {
@Override
public void call(ArrayList<Node> nodes) {
launchShortestPathThread(new BellmanFordAlgorithm(
new ShortestPathInstance(graph, nodes.get(0), nodes.get(1), mode)));
new ShortestPathData(graph, nodes.get(0), nodes.get(1), mode)));
}
});
}