<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body style="overflow-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;">
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.
<div><br>
</div>
<div>The notion is that “element indexes” are the buckets and “position indexes” are the possible insertion points
<i>between</i> buckets. I personally find it simpler to think of a method like `subList` as simply accepting two position indexes, rather than thinking about half-open ranges.</div>
<div><br>
</div>
<div>To me this was clarifying, but for people who never have this explained to them it’s probably not that clear.</div>
<div><br>
</div>
<div>And basically, the adoption counts for those methods always remained very low. And I remember seeing a number of misuses, too.</div>
<div><br>
</div>
<div>Not sure what to make of all this; just adding some context.</div>
<div><br>
</div>
<div><br id="lineBreakAtBeginningOfMessage">
<div><br>
<blockquote type="cite">
<div>On Jan 13, 2025, at 11:36 AM, Glavo <zjx001202@gmail.com> wrote:</div>
<br class="Apple-interchange-newline">
<div>
<div dir="ltr">
<div dir="ltr">
<div dir="ltr">
<div dir="ltr">
<div dir="ltr">
<div dir="ltr">
<div dir="ltr">Currently the java.util.Objects provide the method `checkIndex(int, int)` for checking indexes.</div>
<div dir="ltr">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.</div>
<div dir="ltr">So is it possible to add a new method to Objects to check this kind of index?</div>
<div dir="ltr">This is useful for implementing collections.</div>
<div dir="ltr">(The checkPositionIndex in the title is its name in guava. I don't like the name, but I don't have a better idea.) </div>
<div dir="ltr"><br>
</div>
<div>Glavo</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</blockquote>
</div>
<br>
</div>
</body>
</html>