typelevel/spire

Sorting package / convention for (start, end) and (left, right)

Closed this issue · 6 comments

The convention is not consistent across sort methods: sometimes the end/right point is inclusive, sometimes not.

This is in https://github.com/non/spire/blob/master/core/src/main/scala/spire/math/Sorting.scala

Suggested steps:

  • Document the existing convention
  • Verify that we test for the boundary conditions. If not, write additional tests
  • Harmonize the convention across methods

If you all are interested in help with this, I'm happy to crack at it this weekend assuming no one beats me to it.

Yes, please do!

When harmonizing, I suggest reusing the Java convention where end is not inclusive.

Anyway, it is not possible to allocate arrays bigger than INT_MAX - 2 or so.

@stephen-lazaro Let me know if you need on that issue!

Thanks! Sorry there hasn't been much movement on this, got caught up in work a bit more than I expected.

@stephen-lazaro @denisrosset To become more familiar with Spire, I took a crack at this. I just submitted the pull request.

Mainly I added some unit tests so as to make tweaking the implementation safer. As per the suggestion, the indices are now consistent in their meaning across the methods (end is always exclusive).

Solved by #738 ! Thanks