0

Several months ago I stumbled across something regarding large string buffers where the buffers were assembled as something similar to linked lists instead of large contiguous chunks of memory. I'm having trouble Googling this technique and was wondering if someone could help me out? The idea being you could rearrange large parts of the string without any extra reallocations (move entire sentences around, or whole paragraphs).

No clue what to search for.

Chris K
  • 11,996
  • 7
  • 37
  • 65
  • 4
    I believe you're looking for the keyword "rope", possibly. Actually, I don't know how those are implemented, I've never used them. But it's the only alternative to strings that I've heard much about. [Here's an example.](http://www.sgi.com/tech/stl/Rope.html) – Benjamin Lindley Oct 31 '12 at 16:04
  • 1
    @ben you should make that an answer; I'd +1 it :) – Ian Oct 31 '12 at 16:09
  • @Ian: I didn't want to at first. I thought someone with a little more experience with them might offer something more substantive. But since nobody is stepping up, I guess I will. – Benjamin Lindley Oct 31 '12 at 16:13

2 Answers2

4

I believe you're looking for the keyword "rope", possibly. Actually, I don't know how those are implemented, I've never used them. But it's the only alternative to contiguous strings that I've heard much about. And the use cases, as described, seem to be similar to what you are describing.

Here's an example, in the SGI STL.

Benjamin Lindley
  • 101,917
  • 9
  • 204
  • 274
  • Thanks a bunch. I've been wracking my head looking for these. Not so much for implementation details, but for theory and discussion. Cheers! – Chris K Nov 01 '12 at 16:34
1

It is indeed called a rope (because it's ... a big string).

There's some discussion of the practicalities in this question, but I'm afraid I don't know of any implementations other than the SGI one Benjamin linked.

Community
  • 1
  • 1
Useless
  • 64,155
  • 6
  • 88
  • 132