public final void clear(int expectedNumElements) {
        if (expectedNumElements == 0) {
            // Optimize away object allocations for empty sets.
            this.head = HeadElement.EMPTY;
            this.elements = EMPTY_ELEMENTS;
            this.size = 0;
        } else {
            this.head = new HeadElement();
            this.elements = new Element[calculateCapacity(expectedNumElements)];
            this.size = 0;
        }
    }
Removes all of the elements from this set, and resets the set capacity
based on the provided expected number of elements.
clients/src/main/java/org/apache/kafka/common/utils/ImplicitLinkedHashCollection.java