by erichocean · 10y ago · 0 comments
http://www.chiark.greenend.org.uk/~sgtatham/algorithms/cbtre...
You can do all the normal editing operations in log time, and B-trees can (obviously) be run from disk, so you don't need to use a lot of RAM, either, and can efficiently edit extremely large text files. In-memory, B-trees also use the memory hierarchy efficiently.
You could have (a secondary index of) line counts as well as bytes so that you can also seek to specific lines in log time.