Write a function which finds all components of a bitmap.
Sigiloso
bool& Matrix::opertor()(int i, int j); typedef Matrix > ComponentMatrix; list > findComponents(Matrix& m) { list > res; ComponentMatrix comps; for(int i = 0; i & m, int r, int c, Matrix& visited, ComponentMatrix& comps) { for (int x = -1; x <= 1; ++x) for (int y = -1; y <= 1; ++y) if (!visited(x,y) && m(x + r, y + c) == 1 && comps(r,c) != comps(x,y)) { comps(x,y) = make_pair(i, j); handleComponents(m, x, y, comps); } else { visited(x,y) = true; } }