Java Reference
In-Depth Information
if (neighbour) neighborCount++;
}
}
return neighborCount;
}
@Override
protected void compute() {
if (getArea() < 20) {
computeDirectly();
return;
}
int halfRows = (endRow - startRow) / 2;
int halfCols = (endCol - startCol) / 2;
if (halfRows > halfCols) {
// split the rows
invokeAll(new
GameOfLifeAdvancer(originalBoard, startRow, startCol,
startRow+halfRows,
endCol,destinationBoard),
new
GameOfLifeAdvancer(originalBoard, startRow+halfRows+1,
startCol,
endRow,
endCol,destinationBoard));
} else {
invokeAll(new
GameOfLifeAdvancer(originalBoard, startRow, startCol,
endRow,
startCol+
halfCols,destinationBoard),
new
GameOfLifeAdvancer(originalBoard, startRow,
startCol+halfCols+1,
endRow,
endCol,destinationBoard));
}
}
Search WWH ::




Custom Search