private long[] convertToArray(Map<String,Long> map,int size,boolean unitOffset){
  long[] values=new long[size];
  int arrayOffset=unitOffset ? -1 : 0;
  for (  Map.Entry<String,Long> cursor : map.entrySet()) {
    int offset=Integer.parseInt(cursor.getKey()) + arrayOffset;
    values[offset]=cursor.getValue();
  }
  return values;
}

private long [ ] convertToArray ( Map < String , Long > map , int size , boolean unitOffset ) { long [ ] values = new long [ size ] ; int arrayOffset = unitOffset ? - 1 : 0 ; for ( Map . Entry < String , Long > cursor : map . entrySet ( ) ) { int offset = Integer . parseInt ( cursor . getKey ( ) ) + arrayOffset ; values [ offset ] = cursor . getValue ( ) ; } return values ; }
will convert a ( possibly sparse ) map whose keys are string versions of numbers between 0 and size , to an array .
