unique_() is a usually faster alternative to unique() with optional
sorting included. The internal API of this function is designed to be
simple and generic to allow for working with all kinds of objects that can
be reduced to a unique set.
Internally unique_() calculates unique group IDs for the given vector
in the range [1, n] where 1 denotes the first group and n denotes
the nth group.
This function will work correctly as long as there
is a correctly implemented collapse::GRP method and a [ method
for the object.
In the future cheapr will include a group_id S3 generic to replace the use
of collapse::GRP here, of which is arguably more difficult to write correct
methods for.