Closed jessegrosjean closed 4 years ago
While it would definitely be possible to do that, I'm skeptical if it would actually be that useful to anyone. And it would certainly make Ropey more annoying to maintain. Knowing that the b-tree implementation is only used in Ropey is actually really nice, because it can be tailored and changed and tweaked to exactly the needs of Ropey without fear of inconveniencing anyone else or breaking anyone else's code. Making APIs public is very restricting.
A more likely approach would, I think, be for someone to fork Ropey and make a new separate project with different goals (i.e. a generic rope-like b-tree). I'm not especially interested in doing that myself, but I'd be happy to provide pointers for anyone else who wants to do it.
Thanks for response... mostly just making sure this wasn't something you were already working on. I want b-tree as base for interval tree to track spans and also for line breaks and track incremental height calculation for rich text editor view. I'll definitely let you know if I make progress.
Ah cool! Yeah, definitely let me know if you need any pointers with the code. There's some places where it's a bit hairy (although I think that's mostly at the leaf node level, which I expect you'll need to swap out for this anyway...?).
Ropey's b-tree implementation is very nice/fast/documented.
But right now it is tied to string type. Have you considered making it generic such as what xi-editor or xray editor do with their b-tree implementations? I think it would be a generally useful crate on its own if made generic.