JostleTree

A JostleTree is a new (I think?) data structure for working with long lines of tightly packed items with variable widths.

In other words, the JostleTree can be thought of as efficiently modelling a sequence of items of variable widths. It allows operations such as jumping to a position and getting whatever item is there, and, resizing items, in so doing, repositioning every one of the items after it. It does this in logarithmic time.

The positions of the elements are effectively distributed throughout the tree. Each node of the tree stores the sum width of all of the elements underneath it.

Don't hesitate to ask if you want an API feature added, I'll get to it ASAP. There are a few fairly trivial things I haven't done yet because I don't need them myself yet, and it'll be less work if it's done after non-lexical lifetimes is stabilized.

```rust let mut candidate = JostleTree::::new(); candidate.insertback(1, 'a'); candidate.insertback(9, 'b'); candidate.insertback(1, 'c'); candidate.insertback(1, 'd'); asserteq!(candidate.getitem(5).unwrap(), &'b'); asserteq!(candidate.getitem(10).unwrap(), &'c'); asserteq!(candidate.getitem(11).unwrap(), &'d');

candidate.insertat(5, 1, 'e'); asserteq!(candidate.get_item(1).unwrap(), &'e'); ```

Using floats as spans

The data structure is generic over span types, but f32s and f64s wont work because they do not implement Ord. (The reason they don't implement Ord is that there exists a float for which neither a < b nor a > b. Can you guess which float it is?. It's NaN. NaN is also the reason floats can't implement Eq. There are some data structures that will actually break and do unsafe things if you give trick them into using floats, for this reason. NaNs are pretty horrible, really.)

But fear not. You can just use https://crates.io/crates/noisy_float. It's a no-overhead wrapper around floats that disallows NaNs.

Possible Applications