I’m puzzled by the return values on Java’s Lists.
I would have expected operations such as add and remove to return the index of the added or removed element, instead they just return true on success.
While with add I may get this id calling size-1 (guess it’s not expensive), with remove I have to call indexOf, which looks like a waste to me.
Am I missing something?
I think the explanation is that add and remove are on the Collection interface, so they apply to
MapSet as well as List based data structures.