SCAN: refactored into scanGenericCommand.

The new implementation is capable of iterating the keyspace but also
sets, hashes, and sorted sets, and can be used to implement SSCAN, ZSCAN
and HSCAN.
SCAN is a random command and does not require output sorting.

Sorting the output helps when we want to turn a non-deterministic into a
deterministic command, in that case this is not possible.
dictScan(): empty hash table requires special handling.
SSCAN implemented.
HSCAN implemented.
ZSCAN implemented.