そのため、SimpleGraph (無向グラフ、JGraphT) のすべてのエッジを削除しようとしていますが、何らかの理由で ConcurrentModificationException が発生し続けます。
これが私がやろうとしていることです:
まず、次のようなクラス Point があります。
class Point
{
private int x;
private int y;
public Point(int x, int y)
{
this.x = x;
this.y = y;
}
//getters and setters
public boolean equals (Object rhs)
{
if (rhs == null || !(rhs instanceof Point))
return false;
else
{
Point rhsPoint = (Point) rhs;
return rhsPoint.x == this.x && rhsPoint.y == this.y;
}
}
public int hashCode()
{
int hash = 3;
hash = 83 * hash + (int) (this.col ^ (this.col >>> 32));
hash = 83 * hash + (int) (this.row ^ (this.row >>> 32));
return hash;
}
}
頂点が Point のインスタンスであり、2D 配列に格納されているグラフ g
Point[][] pointContainer = new Point[100][100];
SimpleGraph<Point, DefaultEdge.class> g = new SimpleGraph<Point, DefaultEdge.class>();
public void initGraph()
{
for (int row = 0; row < 100; ++row)
for (int col = 0; col < 100; ++col)
{
Point p = new Point(col, row);
pointContainer[row][col] = p;
g.addVertex(p);
}
//Then I added edges between any adjacent vertices
//so except for those vertices near the edges of the grid, each vertex has 8 edges
}
public void removeEdges(int row, int col)
{
Set edges = g.edgesOf(pointContainer[row][col]);
g.removeAllEdges(edges);
}
ここで私が間違ったことを誰か教えてもらえますか? ConCurrentModificationException が発生し続けるのはなぜですか?