docs: private static <E> ImmutableSet<E> construct(int n, Object... elements) {
      switch (n) {
        case 0:
          return of();
        case 1:
          @SuppressWarnings("unchecked") // safe; elements contains only E's
          E elem = (E) elements[0];
          return of(elem);
        default:
          // continue below to handle the general case
      }
      int tableSize = chooseTableSize(n);
      Object[] table = new Object[tableSize];
      int mask = tableSize - 1;
      int hashCode = 0;
      int uniques = 0;
      for (int i = 0; i < n; i++) {
        Object element = checkElementNotNull(elements[i], i);
        int hash = element.hashCode();
        for (int j = Hashing.smear(hash); ; j++) {
          int index = j & mask;
          Object value = table[index];
          if (value == null) {
            // Came to an empty slot. Put the element here.
            elements[uniques++] = element;
            table[index] = element;
            hashCode += hash;
            break;
          } else if (value.equals(element)) {
            break;
          }
        }
      }
      Arrays.fill(elements, uniques, n, null);
      if (uniques == 1) {
        // There is only one element or elements are all duplicates
        @SuppressWarnings("unchecked") // we are careful to only pass in E
        E element = (E) elements[0];
        return new SingletonImmutableSet<E>(element, hashCode);
      } else if (tableSize != chooseTableSize(uniques)) {
        // Resize the table when the array includes too many duplicates.
        // when this happens, we have already made a copy
        return construct(uniques, elements);
      } else {
        Object[] uniqueElements =
            (uniques < elements.length) ? ObjectArrays.arraysCopyOf(elements, uniques) : elements;
        return new RegularImmutableSet<E>(uniqueElements, hashCode, table, mask);
      }
    }