code: @Override
      @SuppressWarnings("unchecked")
      @ConstantTime(amortized = true)
      public void insert(K key) {
          if (key == null) {
              throw new NullPointerException("Null keys not permitted");
          }
  
          // add in buffer
          insertionBuffer[insertionBufferSize++] = key;
  
          if (isBulkInsertionBufferFull()) {
              if (size + insertionBufferSize > array.length) {
                  // first try to double size
                  if (array.length == 0) {
                      ensureCapacity(1);
                  } else {
                      ensureCapacity(2 * array.length);
                  }
                  // if not enough, set to requested size
                  ensureCapacity(size + insertionBufferSize);
              }
              if (comparator == null) {
                  bulkInsert();
              } else {
                  bulkInsertWithComparator();
              }
          } else if (insertionBufferSize > 1) {
              // update minimum
              K insertionBufferMin = insertionBuffer[insertionBufferMinPos];
              if (comparator == null) {
                  if (((Comparable<? super K>) key).compareTo(insertionBufferMin) < 0) {
                      insertionBufferMinPos = insertionBufferSize - 1;
                  }
              } else {
                  if (comparator.compare(key, insertionBufferMin) < 0) {
                      insertionBufferMinPos = insertionBufferSize - 1;
                  }
              }
          }
      }
docs: {@inheritDoc}