@Override
    public Object[] toArray() {
        Object[] result = new Object[size()];
        Iterator<T> iter = iterator();
        int i = 0;
        while (iter.hasNext()) {
            result[i++] = iter.next();
        }
        return result;
    }
This is a hash set which can be snapshotted.
<br>
See {@link SnapshottableHashTable} for more details about the implementation.
<br>
This class requires external synchronization.  Null values are not supported.

@param <T>   The value type of the set.
server-common/src/main/java/org/apache/kafka/timeline/TimelineHashSet.java