3 ms·
I guess if you have an array of characters and you want to insert into the middle, you could promote the array into a rope as follows: 1. break the array int
by philsnow 13y ago
I guess if you have an array of characters and you want to insert into the middle, you could promote the array into a rope as follows:
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.
- Cthulhu_ 13y ago> this assumes that you're okay with starting with an array of characters and ending up with a rope. 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.