JasonBock / SpackleNet

Spackle is a project that contains a number of helper methods I've used to supplement the core classes in .NET.
MIT License
14 stars 1 forks source link

Create Method to Return `Range` Array For All Ranges of an `int` Array #36

Open JasonBock opened 2 years ago

JasonBock commented 2 years ago

This idea was inspired by this video. I thought, couldn't Spackle have a way to say, given a collection of ints, create all the Ranges that represent the bounds of the values in the array.

For example, if I have [3, 1, 7, 5, 2], I should get (1, 4), (5, 6), (7, 8)

Also, consider how much the list of ranges should be allocated as a best initial guess. For example, if you are given an array of X elements, at most you'd create 20 ranges. Not sure if there's any meaningful heuristic to use here to try and optimize the initial list range allocation.

JasonBock commented 1 year ago

Now that Range<T> works on INumber<T>, this really doesn't make sense....unless I go with an inheritance structure for Range<T> where I have IntegralRange<T> and FloatingRange<T>.