static final short[] RLEStringToShortArray(String s){
  int length=(((int)s.charAt(0)) << 16) | ((int)s.charAt(1));
  short[] array=new short[length];
  int ai=0;
  for (int i=2; i < s.length(); ++i) {
    char c=s.charAt(i);
    if (c == ESCAPE) {
      c=s.charAt(++i);
      if (c == ESCAPE)       array[ai++]=(short)c;
 else {
        int runLength=(int)c;
        short runValue=(short)s.charAt(++i);
        for (int j=0; j < runLength; ++j)         array[ai++]=runValue;
      }
    }
 else {
      array[ai++]=(short)c;
    }
  }
  if (ai != length)   throw new InternalError("Bad run-length encoded short array");
  return array;
}

static final short [ ] RLEStringToShortArray ( String s ) { int length = ( ( ( int ) s . charAt ( 0 ) ) << 16 ) | ( ( int ) s . charAt ( 1 ) ) ; short [ ] array = new short [ length ] ; int ai = 0 ; for ( int i = 2 ; i < s . length ( ) ; ++ i ) { char c = s . charAt ( i ) ; if ( c == ESCAPE ) { c = s . charAt ( ++ i ) ; if ( c == ESCAPE ) array [ ai ++ ] = ( short ) c ; else { int runLength = ( int ) c ; short runValue = ( short ) s . charAt ( ++ i ) ; for ( int j = 0 ; j < runLength ; ++ j ) array [ ai ++ ] = runValue ; } } else { array [ ai ++ ] = ( short ) c ; } } if ( ai != length ) throw new InternalError ( "Bad run-length encoded short array" ) ; return array ; }
construct an array of shorts from a run - length encoded string .
