Check if this object is a duplicate of another. Objects are duplicates if they contain the same list of directed edges, possibly offset.
@param other The other object to check against.
@return True if this object is a duplicate of other, false otherwise.
*/
publicbooleanisDuplicate(TemporaryObjectother){
List<DirectedEdge>myEdges=getEdges();
List<DirectedEdge>otherEdges=other.getEdges();
if(myEdges.size()!=otherEdges.size()){
returnfalse;
}
Iterator<DirectedEdge>it=myEdges.iterator();
DirectedEdgestart=it.next();
// See if we can find an equivalent edge in other
Iterator<DirectedEdge>ix=otherEdges.iterator();
DirectedEdgeotherStart=null;
while(ix.hasNext()){
DirectedEdgetest=ix.next();
if(test.equals(start)){
// Found!
otherStart=test;
break;
}
}
if(otherStart==null){
// Edge not found in other so can't be a duplicate
returnfalse;
}
// Check that edges are equivalent
// Walk through the edge lists starting at the beginning for me and at the equivalent edge in other. When we reach the end of other go back to the start.
while(ix.hasNext()){
DirectedEdgea=it.next();
DirectedEdgeb=ix.next();
if(!a.equals(b)){
returnfalse;
}
}
ix=otherEdges.iterator();
while(it.hasNext()){
DirectedEdgea=it.next();
DirectedEdgeb=ix.next();
if(!a.equals(b)){
returnfalse;
}
}
returntrue;
}
/**
Check if this object is a entirely inside another.
@param other The other object to check against.
@return True if this object is entirely inside the other, false otherwise.
Replace all references to an edge with another edge. This does not delete the old edge from the map. The two edges must have the same pair of start and end nodes but may be in different directions.