Hacker News
new
|
past
|
comments
|
ask
|
show
|
jobs
|
submit
login
teo_zero
on Oct 10, 2023
|
parent
|
context
|
favorite
| on:
Text showdown: Gap Buffers vs. Ropes
The trick is to decouple the concept of 'position' in the text, that is independent of the gap, from 'pointer' into the buffer. If you keep track of line beginnings as positions, you can immediately get the pointers:
ptr = pos if pos<=gapstart else pos + gapsize
teo_zero
on Oct 10, 2023
[–]
Replying to myself: it's actually a bad idea because you have to update all indices at each inserted char! Forget about it...
Guidelines
|
FAQ
|
Lists
|
API
|
Security
|
Legal
|
Apply to YC
|
Contact
Search: