Re:Judge Alsup learns to code and schools Oracle
by self on Wednesday May 16, 2012 @06:28AM
(#3981387)
Shouldn't that be "toIndex >= length"?
[ Parent
| on HN ]
Re:Judge Alsup learns to code and schools Oracle
by 6ren on Wednesday May 16, 2012 @11:39AM
(#3982442)
Bloch used > http://news.ycombinator.com/item?id=3940683
I think in defining a range, the toIndex means up-to-but-not-including the element at that index. Thus, to include the full array, you'd use the range fromIndex=0, toIndex=length (one past the last one, since the index of the last element is length-1). With this notation, you can then make ranges of any width, from 0 up to length. If instead you included the element at that index, you couldn't have 0-width ranges (unless you allowed toIndex to equal one less than fromIndex).
I don't know whether 0-width ranges are directly useful for the Timsort algorithm; or whether it's just a convenient notation that happens to have that ability as an unused side-effect.