Run-length encoding (RLE) of stream segments ...
Actually, I just coded an implementation myself, but as I was testing my code, I got an Exception that to me looks like a bug more than an error from myself
~
Isn't java.lang.StringBuffer supposed to do its internal buffering by itself?
~
lbrtchx
~
~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
~
Exception in thread "main" java.lang.StringIndexOutOfBoundsException: String index out of range: 16
at java.lang.AbstractStringBuilder.insert(AbstractStringBuilder.java:979)
at java.lang.StringBuffer.insert(StringBuffer.java:446)
at AUtils00Test.main(AUtils00Test.java:104)
~
/java/lang/StringBuffer.java's insert should "ensureCapacity_unsynchronized" before doing its business as it does for all other methods; which you can see from:
~
http://www.opensource.apple.com/source/gccfast/gccfast-1622/libjava/java/lang/StringBuffer.java
~
/** Insert the <code>String</code> argument into this <code>StringBuffer</code>.
* @param offset the place to insert.
* @param str the <code>String</code> to insert.
* @return this <code>StringBuffer</code>.
* @exception IndexOutOfBoundsException if <code>offset</code> is out
* of range for this <code>StringBuffer</code>.
*/
public synchronized StringBuffer insert (int offset, String str)
{
if (offset < 0 || offset > count)
throw new StringIndexOutOfBoundsException (offset);
// Note that using `null' is from JDK 1.2.
if (str == null)
str = "null";
int len = str.length();
ensureCapacity_unsynchronized (count+len);
System.arraycopy(value, offset, value, offset+len, count-offset);
str.getChars(0, len, value, offset);
count += len;
return this;
}
~