Re: Request for Enhancement: Objects.checkPositionIndex(int, int)

2025-01-13 Thread Glavo
Hi Kevin, I’m surprised you even noticed the methods. I develop and maintain a collection library, in which I copied checkPositionIndex because it is really commonly used by me. I searched my library and found that checkPositionIndex has more than a hundred use cases in my library. And basicall

Re: Request for Enhancement: Objects.checkPositionIndex(int, int)

2025-01-13 Thread Chen Liang
lass files... From: core-libs-dev on behalf of Kevin Bourrillion Sent: Monday, January 13, 2025 2:19 PM To: Glavo Cc: core-libs-dev Subject: Re: Request for Enhancement: Objects.checkPositionIndex(int, int) Oh hey, I named those Guava methods. :-) This was my

Re: Request for Enhancement: Objects.checkPositionIndex(int, int)

2025-01-13 Thread Kevin Bourrillion
Oh hey, I named those Guava methods. :-) This was my attempt to promote the terms “position indexes vs. element indexes” and hope that the idea caught on... which I’d say it still never has. I’m surprised you even noticed the methods. The notion is that “element indexes” are the buckets and “po

Request for Enhancement: Objects.checkPositionIndex(int, int)

2025-01-13 Thread Glavo
Currently the java.util.Objects provide the method `checkIndex(int, int)` for checking indexes. It is convenient, but cannot be used to implement methods such as List::add(int, E) because these methods accept an index pointing to the end of the collection. So is it possible to add a new method to O