summaryrefslogtreecommitdiff
path: root/base/src/main/java/bjc/utils/graph
diff options
context:
space:
mode:
authorBen Culkin <scorpress@gmail.com>2020-12-03 19:22:35 -0500
committerBen Culkin <scorpress@gmail.com>2020-12-03 19:22:35 -0500
commita2c7425458f645802a352abc4783e0afc73dba13 (patch)
tree92fe887eb09674ddc61c251626989c06aff88a22 /base/src/main/java/bjc/utils/graph
parentbcda03dd2ba95a93a93df7f139b3607491750b74 (diff)
Adapt to esodata changes
Diffstat (limited to 'base/src/main/java/bjc/utils/graph')
-rw-r--r--base/src/main/java/bjc/utils/graph/AdjacencyMap.java20
-rw-r--r--base/src/main/java/bjc/utils/graph/Graph.java16
2 files changed, 18 insertions, 18 deletions
diff --git a/base/src/main/java/bjc/utils/graph/AdjacencyMap.java b/base/src/main/java/bjc/utils/graph/AdjacencyMap.java
index 46d27f5..978b21d 100644
--- a/base/src/main/java/bjc/utils/graph/AdjacencyMap.java
+++ b/base/src/main/java/bjc/utils/graph/AdjacencyMap.java
@@ -6,12 +6,12 @@ import java.io.PrintStream;
import java.util.InputMismatchException;
import java.util.Scanner;
-import bjc.data.IHolder;
+import bjc.data.Holder;
import bjc.data.Identity;
import bjc.funcdata.FunctionalList;
import bjc.funcdata.FunctionalMap;
-import bjc.funcdata.IList;
-import bjc.funcdata.IMap;
+import bjc.funcdata.ListEx;
+import bjc.funcdata.MapEx;
import bjc.utils.funcutils.FuncUtils;
/**
@@ -62,13 +62,13 @@ public class AdjacencyMap<T> {
if (vertexCount <= 0) throw new InputMismatchException(
"The number of vertices must be greater than 0");
- final IList<Integer> vertices = new FunctionalList<>();
+ final ListEx<Integer> vertices = new FunctionalList<>();
FuncUtils.doTimes(vertexCount, vertexNo -> vertices.add(vertexNo));
adjacency = new AdjacencyMap<>(vertices);
- final IHolder<Integer> row = new Identity<>(0);
+ final Holder<Integer> row = new Identity<>(0);
input.forEachRemaining(strang -> {
readRow(adjacency, vertexCount, row, strang);
@@ -80,7 +80,7 @@ public class AdjacencyMap<T> {
/* Read a row of edges. */
private static void readRow(final AdjacencyMap<Integer> adjacency,
- final int vertexCount, final IHolder<Integer> row, final String strang) {
+ final int vertexCount, final Holder<Integer> row, final String strang) {
final String[] parts = strang.split(" ");
if (parts.length != vertexCount) {
@@ -115,7 +115,7 @@ public class AdjacencyMap<T> {
}
/** The backing storage of the map */
- private final IMap<T, IMap<T, Integer>> adjacency = new FunctionalMap<>();
+ private final MapEx<T, MapEx<T, Integer>> adjacency = new FunctionalMap<>();
/**
* Create a new map from a set of vertices
@@ -123,11 +123,11 @@ public class AdjacencyMap<T> {
* @param vertices
* The set of vertices to create a map from
*/
- public AdjacencyMap(final IList<T> vertices) {
+ public AdjacencyMap(final ListEx<T> vertices) {
if (vertices == null) throw new NullPointerException("Vertices must not be null");
vertices.forEach(vertex -> {
- final IMap<T, Integer> row = new FunctionalMap<>();
+ final MapEx<T, Integer> row = new FunctionalMap<>();
vertices.forEach(target -> {
row.put(target, 0);
@@ -143,7 +143,7 @@ public class AdjacencyMap<T> {
* @return Whether or not the graph is directed
*/
public boolean isDirected() {
- final IHolder<Boolean> result = new Identity<>(true);
+ final Holder<Boolean> result = new Identity<>(true);
adjacency.forEach((sourceKey, sourceValue) -> {
sourceValue.forEach((targetKey, targetValue) -> {
diff --git a/base/src/main/java/bjc/utils/graph/Graph.java b/base/src/main/java/bjc/utils/graph/Graph.java
index 88b0d08..f32e07f 100644
--- a/base/src/main/java/bjc/utils/graph/Graph.java
+++ b/base/src/main/java/bjc/utils/graph/Graph.java
@@ -10,11 +10,11 @@ import java.util.Set;
import java.util.function.BiConsumer;
import java.util.function.BiPredicate;
-import bjc.data.IHolder;
+import bjc.data.Holder;
import bjc.data.Identity;
import bjc.funcdata.FunctionalMap;
-import bjc.funcdata.IList;
-import bjc.funcdata.IMap;
+import bjc.funcdata.ListEx;
+import bjc.funcdata.MapEx;
/**
* A directed weighted graph, where the vertices have some arbitrary label.
@@ -47,7 +47,7 @@ public class Graph<T> {
}
/** The backing representation of the graph. */
- private final IMap<T, IMap<T, Integer>> backing;
+ private final MapEx<T, MapEx<T, Integer>> backing;
/** Create a new empty graph. */
public Graph() {
@@ -120,7 +120,7 @@ public class Graph<T> {
* The vertex to use as a source.
* @return All of the edges with the specified vertex as a source.
*/
- public IMap<T, Integer> getEdges(final T source) {
+ public MapEx<T, Integer> getEdges(final T source) {
/* Can't find edges for a null source. */
if (source == null) {
throw new NullPointerException("The source cannot be null.");
@@ -159,7 +159,7 @@ public class Graph<T> {
final Set<T> visited = new HashSet<>();
/* Start at the initial vertex and visit it */
- final IHolder<T> source = new Identity<>(getInitial());
+ final Holder<T> source = new Identity<>(getInitial());
visited.add(source.getValue());
@@ -177,7 +177,7 @@ public class Graph<T> {
);
/* Get the edge with the minimum distance. */
- final IHolder<Edge<T>> minimum = new Identity<>(available.poll());
+ final Holder<Edge<T>> minimum = new Identity<>(available.poll());
/*
* Only consider edges where we haven't visited the target of the edge.
@@ -213,7 +213,7 @@ public class Graph<T> {
*
* @return A unmodifiable set of all the vertices in the graph.
*/
- public IList<T> getVertices() {
+ public ListEx<T> getVertices() {
return backing.keyList();
}