Oleg Kalnichevski wrote: > I would actually expect a IndexOutOfRangeExceptions in case of an > invalid index. What if one passes -1 by mistake and gets the interceptor > quietly appended to the list last?
I see. Good point. > For the same reason I do not quite > like the idea of using Integer.MAX_VALUE, but I have promised to myself > to not get into API purity discussions with you. I don't like Integer.MAX_VALUE as a magic number either. I wrote it only as an example in my JIRA comment, since I would map everything beyond the end of the list to the end of the list. If we define a single magic number, it should be defined as a constant in our interface. How about mapping all positive values beyond the end to the end of the list, but throwing an exception for negatives? That avoids unexpected wrap-around behavior near 0, but also avoids querying the size of the list if all you want to do is adding something at the end: if (index < 0) throw IndexOutOfBoundsException(...); if (index > ...size()) index = ...size(); cheers, Roland --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
