[algorithms] Move the code of some algorithms from multi/ and drop TypeOf dependency.

Algorithms moved: correct, envelope, equals, length, num_geometries, perimeter, remove_spikes.