back

by raphlinus·9y ago·view on hn ↗
If you really want to solve the problem, use a rope. The advantage of gap buffers is simplicity (accounting for the gap is a simple compare with a couple of numbers). Ropes are definitely more complicated, but they have massive advantages in worst-case complexity (most edit and query operations have O(log n) cost).
1 comments
The simplicity argument is absurd to me. Text editors are some of the most important programs to get right. The complex but high performance data structure is worth the effort. It's like arguing that a GIS program shouldn't use a quadtree.
You don't need to convince me, but you'd be surprised some of the pushback I've gotten[0].

I don't have a lot of experience with GIS, but you're telling me that a linear scan through all the features on a map isn't good enough? :)

[0] https://news.ycombinator.com/item?id=14129543