public static PrimitiveIntSet asSetAllowDuplicates(PrimitiveIntIterator iterator) { PrimitiveIntSet set = Primitive.intSet(); while (iterator.hasNext()) { set.add(iterator.next()); } return set; }
public static PrimitiveIntSet asSet(int[] values) { PrimitiveIntSet set = Primitive.intSet(values.length); for (int value : values) { set.add(value); } return set; }
public static PrimitiveIntSet asSet(PrimitiveIntIterator iterator) { PrimitiveIntSet set = Primitive.intSet(); while (iterator.hasNext()) { int next = iterator.next(); if (!set.add(next)) { throw new IllegalStateException("Duplicate " + next + " from " + iterator); } } return set; }