Data copyOnWrite(){
  Data d=data;
  d.writing=true;
  int w=writeVersion;
  if (w <= data.version) {
    return d;
  }
  Data d2=new Data(w,data);
  d2.writing=true;
  d.writing=false;
  return d2;
}

Data copyOnWrite ( ) { Data d = data ; d . writing = true ; int w = writeVersion ; if ( w <= data . version ) { return d ; } Data d2 = new Data ( w , data ) ; d2 . writing = true ; d . writing = false ; return d2 ; }
clone the data object if necessary ( if the write version is newer than the current version ) .
