More C++11

Make most array-iterating loops into range-based for loops.
Use std::find and std::any_of where possible, but replace one or two
uses with a set instead.
Fix a crash (doh)

If we want to set the deleted mcache pointer to null, we need to
iterate by reference.
Make a few more loop tweaks.

I missed these in the first pass because some of them are in header
files, and the others iterated using an int rather than unsigned or
size_t.
Tweak some shuffle_array callers.

Remove two more uses of the two-argument version; and use a range-
based for loop in one of those cases.
Whitespace fix