code: @Override
      @LogarithmicTime(amortized = true)
      public void insert(K key) {
          if (Constants.NOT_BENCHMARK) {
              if (key == null) {
                  throw new NullPointerException("Null keys not permitted");
              }
              // make sure there is space
              if (size == array.length) {
                  if (size == 0) {
                      ensureCapacity(1);
                  } else {
                      ensureCapacity(2 * array.length);
                  }
              }
          }
  
          array[size] = key;
          reverse.clear(size);
  
          if (size % 2 == 0) {
              reverse.clear(size / 2);
          }
  
          if (comparator == null) {
              fixup(size);
          } else {
              fixupWithComparator(size);
          }
  
          ++size;
      }
docs: {@inheritDoc}