public int compareTo(KruskalCell another) { if (getX() < another.getX()) return -1; else if (getX() > another.getX()) return 1; else { if (getY() < another.getY()) return -1; else if (getY() > another.getY()) return 1; } return 0; }
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; KruskalCell other = (KruskalCell) obj; if ((getX() == other.getX()) && (getY() == other.getY())) return true; return false; }
public boolean joinSet(KruskalCell otherCell) { if (!mSet.contains(otherCell)) { mSet.addAll(otherCell.mSet); Iterator<KruskalCell> it = otherCell.mSet.iterator(); while (it.hasNext()) { KruskalCell cell = it.next(); cell.mSet = mSet; } return true; } return false; }