4 ms·
How about many readers and zero writers? :) For my text editor, I went with an immutable balanced tree. I was surprised by how easily I was about to implement
by afc 3y ago
How about many readers and zero writers? :)
For my text editor, I went with an immutable balanced tree. I was surprised by how easily I was about to implement all operations I needed with reasonable runtime complexity (log N mostly, operations like "give me a copy with element at position i removed"): https://github.com/alefore/edge/blob/master/src/language/const_tree.h https://github.com/alefore/edge/blob/master/src/language/con...
I use this throughout my editor. For example, I load a file into a sequence of lines represented here: https://github.com/alefore/edge/blob/8fdf7f76ffa167497a7e9e9228b26b1f2dcf95e9/src/language/text/line_sequence.h#L21 https://github.com/alefore/edge/blob/8fdf7f76ffa167497a7e9e9...
I found that the good performance, relatively straightforward implementation and very strong thread safety (making the data immutable means a whole class of problems just disappears) works very well.