Percolation/Site percolation: Difference between revisions

m
Altered code to be more C++ idiomatic.
(New post.)
m (Altered code to be more C++ idiomatic.)
Line 394:
class Grid {
public:
Grid(const int32_t row_count, const int32_t col_count, const double probability) {
create_table(row_count, col_count, probability);
}
Line 407:
}
 
void display() const {
for ( uint64_t col = 0; col < table.size(); col++ ) {
for ( uint64_t row = 0; row < table[0].size(); row++ ) {
Line 417:
}
private:
bool path_exists(const int32_t x, const int32_t y) {
if ( y < 0 || x < 0 || x >= (int32_t) table[0].size() || table[y][x].compare(FILLED) != 0 ) {
return false;
Line 428:
}
 
void create_table(const int32_t row_count, const int32_t col_count, const double probability) {
table.assign(row_count, std::vector<std::string>(col_count, EMPTY));
for ( int32_t col = 0; col < row_count; col++ ) {
908

edits