Rope (data structure)
en.wikipedia.org
en.wikipedia.org
'uint8_t *str = rope_createcstr(rope, NULL);'
Did you mean 'r' instead of 'rope'?
Nice lib, though. I'll keep it in mind.
https://github.com/fishman/dart-mutablestring
some things working some things missing, but it's been a while so i don't really remember
So while you might think a JavaScript string is just a pointer + length, the implementation is actually significantly more complex: the engine will pick different implementations depending on how it thinks you're using it.
http://mxr.mozilla.org/mozilla-central/source/js/src/vm/Stri...
http://www.cs.unm.edu/~crowley/papers/sds.pdf
The material about the “piece table” method is particularly interesting IMHO.
Yes, I'm deliberately being contrarian, as the data structure takes a bit of work to comprehend, and even more work to understand the merge and split operations when you make updates. Not saying that I would never use it, just that the need better justify the effort. (not against going outside the out-of-the-box libraries to do things like tries or radix sort, for example, just want a justification to do the work)
http://scienceblogs.com/goodmath/2009/02/18/gap-buffers-or-w...;
2-3 finger trees are immutable/persistent and support access to both ends in amortized constant time and logarithmic concatenation and splitting.
The complicating factor being that for flyweight values, like characters, the interior nodes of the tree would be prohibitive for one leaf per character. Surely there must be a variant of 2-3 finger trees that addresses this.
1. break the array into two extents (start address / length pairs)
2. make a rope out of those two extents
3. do the insert on the resulting rope
this assumes that you're okay with starting with an array of characters and ending up with a rope.ISTR this pattern was common-ish in erlang last time I looked at erlang, but they call ropes (of bytes) "iolists", and support for iolists goes all the way down into the standard library.
Well, in any OO language, I guess both a string and a rope would still be considered a String object, whether it's a character array or a tree-like structure backing it wouldn't really matter to the public interface.
Good evaluation of them remains
http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/a0006...
Thus, the root node has a value equal to the length of the string; it has two child nodes, with values equal to the lengths of the first and second 'half' of the string, and so on.
I'd be curious if there is anything else that makes this different?
(it's fairly easy to adjust any balanced binary tree to allow the "report" function, ie generating a ordered sublist of size me in O(log(n) + m) time )