PORT-2: Patch applied to set so that first() and last() now return -1
when the indexes are not valid rather than throwing an exception as
before (which is against the standard).