public static int eliminateZeroMassPoints(int[] densityPoints,double[] densityValues){
  int positiveMassCount=0;
  for (int i=0; i < densityValues.length; i++) {
    if (densityValues[i] > 0) {
      positiveMassCount++;
    }
  }
  if (positiveMassCount < densityValues.length) {
    int[] newPoints=new int[positiveMassCount];
    double[] newValues=new double[positiveMassCount];
    int j=0;
    for (int i=0; i < densityValues.length; i++) {
      if (densityValues[i] > 0) {
        newPoints[j]=densityPoints[i];
        newValues[j]=densityValues[i];
        j++;
      }
    }
    System.arraycopy(newPoints,0,densityPoints,0,positiveMassCount);
    System.arraycopy(newValues,0,densityValues,0,positiveMassCount);
  }
  return positiveMassCount;
}

public static int eliminateZeroMassPoints ( int [ ] densityPoints , double [ ] densityValues ) { int positiveMassCount = 0 ; for ( int i = 0 ; i < densityValues . length ; i ++ ) { if ( densityValues [ i ] > 0 ) { positiveMassCount ++ ; } } if ( positiveMassCount < densityValues . length ) { int [ ] newPoints = new int [ positiveMassCount ] ; double [ ] newValues = new double [ positiveMassCount ] ; int j = 0 ; for ( int i = 0 ; i < densityValues . length ; i ++ ) { if ( densityValues [ i ] > 0 ) { newPoints [ j ] = densityPoints [ i ] ; newValues [ j ] = densityValues [ i ] ; j ++ ; } } System . arraycopy ( newPoints , 0 , densityPoints , 0 , positiveMassCount ) ; System . arraycopy ( newValues , 0 , densityValues , 0 , positiveMassCount ) ; } return positiveMassCount ; }
eliminates points with zero mass from densitypoints and densityvalues parallel arrays . returns the number of positive mass points and collapses the arrays so that the first < returned value > elements of the input arrays represent the positive mass points .
