Sdk: API for deleting a set of characters within StringBuffer

Created on 2 Mar 2016  路  6Comments  路  Source: dart-lang/sdk

Hi

Problem
Need for deleting a set of characters within the StringBuffer similar to the delete & deleteCharAt methods in Java's StringBuilder

Solution Request
Currently, StringBuffer allows to clear the entire buffer. Is it possible to provide API for delete methods, like in Java's StringBuilder.

area-library core-n library-core type-enhancement

Most helpful comment

we really need a StringBuilder that would be more powerfull than a StringBuffer and allows for insertion and remove operations for Dart.

All 6 comments

It's a reasonable request.
It might not be as effective as in Java because the Dart StringBuffer doesn't store the contents of a string buffer as a flat array.

It might not be as effective as in Java because the Dart StringBuffer doesn't store the contents of a string buffer as a flat array.

More correctly, it stores the contents of a string buffer as an array of strings but not as an array of each string element (i.e code units of each string buffer element - string).

Dart
List _parts;

Java
char[] value;

Also difference in that the Java StringBuilder implements a CharSequence interface but the Dart StringBuffer does not provide such functionality (sequencing characters).

Just as important as deleting (if not more) is the need to insertAt(), which is also missing in Dart's StringBuffer. If the API only allows you to append, it's not much more useful than manual String concatenation.

A StringBuffer is not more useful than manual string concatenation, only more efficient.

If you want efficient insertion at random positions, then you need quite a different data structure. That's not a goal for StringBuffer.

I'm not opposed to creating a more complicated and powerful string builder, but I think it would be better to make it as a separate class.

we really need a StringBuilder that would be more powerfull than a StringBuffer and allows for insertion and remove operations for Dart.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

gspencergoog picture gspencergoog  路  3Comments

jmesserly picture jmesserly  路  3Comments

DartBot picture DartBot  路  3Comments

matanlurey picture matanlurey  路  3Comments

xster picture xster  路  3Comments