StringBuilder vs Ropes

Good morning,

I am writing a language parser, and am looking for the best structure to use for a rollback cache which currently does the following:

  • When requesting a new character from the stream, the character is added to the cache, in case a rollback is requested.
  • When a rollback is requested, go back to a certain point in the cache so that when another character is requested, it gets it from there instead.
  • When a token is found, remove everything in the rollback cache up to the current position.

So in short, I would love to know which you feel to be the best data structure for:

  • Priority 1: appending characters (codePoints would be a welcome addition)
  • Priority 2: Doing a substring (such as StringBuilder.delete(...)) on the data structure (or clearing completely)
  • Priority 3: Being able to create a string of the cache (e.g. StringBuilder.toString())

I hope to hear from you soon!


If I were you, for such a specialised use and with possible performance and resource constraints, I'd implement my own buffer from primitives. I think it's more trouble adapting existing structures. Of course, if it didn't hurt, I'd try to conform to the well known relevant interfaces, such as CharSequence, Appendable, List, etc.

Need Your Help

ASP.NET Charting Control only working on some servers charts httphandler

Yesterday we pushed out some changes including the addition of ASP.NET MVC 3 (routing, configuration, etc.) and our ASP.NET charting controls stopped working. In our development environment the AS...

Is there a way to log into my router by using an URL?

http url login router

I want to log into my router an pass my account and password within a URl, it has to be similar to this:

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.