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.
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
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.
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.