/**
226 * Creates a <i>mutable</i> {@code HashSet} instance containing the given elements. A very thin
227 * convenience for creating an empty set and then calling {@link Iterators#addAll}.
228 *
229 * <p><b>Note:</b> if mutability is not required and the elements are non-null, use {@link
230 * ImmutableSet#copyOf(Iterator)} instead.
231 *
232 * <p><b>Note:</b> if {@code E} is an {@link Enum} type, you should create an {@link EnumSet}
233 * instead.
234 *
235 * <p>Overall, this method is not very useful and will likely be deprecated in the future.
236 */
237 public static <E> HashSet<E> newHashSet(Iterator<? extends E> elements) {
238 HashSet<E> set = newHashSet();
239 Iterators.addAll(set, elements);
240 return set;
241 }