示例#1
0
 /**
  * checks whether element is full
  *
  * @param i - row
  * @param j - column
  * @return true is is full
  */
 public boolean isFull(final int i, final int j) {
   checkBoundary(i, j);
   if (isOpen(i, j)) {
     return model.connected(model.find(getAbsoluteCoordinate(i, j)), topVirtualElement);
   }
   return false;
 }
示例#2
0
  /** open site (row i, column j) if it is not open already */
  public void open(int i, int j) {
    if (i < 1 || i > this.size || j < 1 || j > this.size) {
      throw new java.lang.IndexOutOfBoundsException();
    }
    if (this.openMatrix[i][j]) {
      return;
    }

    this.openMatrix[i][j] = true;
    int p = xyTo1D(i, j);
    if (i == 1) {
      checkBottom(p, this.virtualTop);
    }
    if (i == this.size) {
      int root = wqu.find(p);
      this.connectedToBottom[root] = true;
    }
    if (i - 1 >= 1) {
      if (isOpen(i - 1, j)) {
        int q = xyTo1D(i - 1, j);
        //                this.wqu.union(p, q);
        checkBottom(p, q);
      }
    }
    if (i + 1 <= this.size) {
      if (isOpen(i + 1, j)) {
        int q = xyTo1D(i + 1, j);
        checkBottom(p, q);
      }
    }
    if (j - 1 >= 1) {
      if (isOpen(i, j - 1)) {
        int q = xyTo1D(i, j - 1);
        checkBottom(p, q);
      }
    }
    if (j + 1 <= this.size) {
      if (isOpen(i, j + 1)) {
        int q = xyTo1D(i, j + 1);
        checkBottom(p, q);
      }
    }
  }
示例#3
0
 /**
  * checks whether bottom neighbour is existed and connects it to the current element
  *
  * @param i - row
  * @param j - column
  */
 private void connectBottomNeighbour(final int i, final int j) {
   int current = getAbsoluteCoordinate(i, j);
   if (i < end - 1 && isOpen(i + 1, j)) {
     model.union(current, model.find(checkNeighbour(i + 1, j)));
   }
 }
示例#4
0
 /**
  * checks whether top neighbour is existed and connects it to the current element
  *
  * @param i - row
  * @param j - column
  */
 private void connectTopNeighbour(final int i, final int j) {
   int current = getAbsoluteCoordinate(i, j);
   if (i > begin && isOpen(i - 1, j)) {
     model.union(current, model.find(checkNeighbour(i - 1, j)));
   }
 }