joomla/joomla-platform — pull request #1730 by eddieajau (2012-12-03 00:14:03+00:00)
Title: Fix bug in `JDataSet` when unsetting within a foreach loop.

The use of `offsetUnset` on the current iterator point within a foreach
loop was causing unpredictable results. If the current pointer is being
unset, the pointer is moved back one unless it's the first element of
the array, in which case the pointer is set to false. The `next` method
then checks for this special case of `false` and rolls to be 'first'
element of the array (which would have been the 'next' one if the offset
had not been unset).

This PR also adds a new `clear` method to reset the contents of the set,
and a `keys` method that works in a similar way to the `array_keys`
function.

Tests and documentation have been updated accordingly. The tests on `JData::count` are also consolidated.