Ropes

dsimcha dsimcha at yahoo.com
Fri Jul 23 14:59:29 PDT 2010


== Quote from sybrandy (sybrandy at gmail.com)'s article
> Not sure if this is what's used by an Appender, but this seems like a
> cool data structure:
> http://ahmadsoft.org/ropes/
> http://en.wikipedia.org/wiki/Rope_%28computer_science%29
> It's not good for indexing, but concatenation is an O(1) operation, so
> using it when you have to do a lot of appending seems to make a lot of
> sense.  And, if I understand appender correctly, it's meant only for
> appending data and that you need to convert it to a range/array before
> you work with it.
> Casey

Appender is just a wrapper over the builtin array that caches the capacity instead
of having to look it up in the bowels of the GC implementation.  Appending to a
regular array is amortized O(1) provided that the array implementation isn't
absolutely asinine.  (Most cases of concatenation, at least in my experience, are
appending.)


More information about the Digitalmars-d mailing list