code: public void set(int index, double value) {
          checkIndex(index);
  
          IndexValue item = new IndexValue(index, 0);
          int valueIndex = Collections.binarySearch(values, item, comp);
          if (valueIndex >= 0 && value != 0d) {
              // Replace a currently existing item with a non zero value.
              values.get(valueIndex).value = value;
          } else if (value != 0d) {
              // Add a new cell item into this row.
              item.value = value;
              values.add((valueIndex + 1) * -1, item);
          } else if (valueIndex >= 0) {
              // Remove the value since it's now zero.
              values.remove(valueIndex);
          }
      }
docs: {@inheritDoc}
  
  All read operations, and writes to indices which already exist are of
  time O(log n).  Writers to new indices are of time O(log n).