code: private int getIndex(int ind) {
  
          // Try to find column index
          int i = Arrays.binarySearchGreater(index, ind, 0, used);
  
          // Found
          if (i < used && index[i] == ind)
              return i;
  
          int[] newIndex = index;
          double[] newData = data;
  
          // Check available memory
          if (++used > data.length) {
  
              // If zero-length, use new length of 1, else double the bandwidth
              int newLength = data.length != 0 ? data.length << 1 : 1;
  
              // Enforce the maximum size.
              newLength = Math.min(newLength, this.size);
  
              // Copy existing data into new arrays
              newIndex = new int[newLength];
              newData = new double[newLength];
              System.arraycopy(index, 0, newIndex, 0, i);
              System.arraycopy(data, 0, newData, 0, i);
          }
  
          // All ok, make room for insertion
          System.arraycopy(index, i, newIndex, i + 1, used - i - 1);
          System.arraycopy(data, i, newData, i + 1, used - i - 1);
  
          // Put in new structure
          newIndex[i] = ind;
          newData[i] = 0.;
  
          // Update pointers
          index = newIndex;
          data = newData;
  
          // Return insertion index
          return i;
      }
docs: Tries to find the index. If it is not found, a reallocation is done, and
  a new index is returned.