code: public double dividePrimitive(int index, double value) {
          if (index < 0 || index >= maxLength) 
              throw new ArrayIndexOutOfBoundsException(
                      "invalid index: " + index);
          
          int pos = Arrays.binarySearch(indices, index);
          
          // The divide operation is dividing a non-existent value in the
          // array, which is always 0, so the corresponding result is 0.
          // Therefore, we don't need to make room.
          if (pos < 0) 
              return 0;
          else {
              double newValue = values[pos] / value;
  
              // The new value is zero, so remove its position and shift
              // everything over
              if (newValue == 0) {
                  int newLength = indices.length - 1;
                  int[] newIndices = new int[newLength];
                  double[] newValues = new double[newLength];
                  for (int i = 0, j = 0; i < indices.length; ++i) {
                      if (i != pos) {
                          newIndices[j] = indices[i];
                          newValues[j] = values[i];            
                          j++;
                      }
                  }
                  // swap the arrays
                  indices = newIndices;
                  values = newValues;
              }
              // Otherwise, the new value is still non-zero, so update it in the
              // array
              else
                  values[pos] = newValue;
              return newValue;
          }
      }
docs: Divides the specified value to the index by the provided value and stores
  the result at the index (just as {@code array[index] /= value})
  
  @param index the position in the array
  @param value the value by which the value at the index will be divided
  
  @return the new value stored at the index