/** {@inheritDoc} */ @Override public KTypeHashSet<KType> clone() { // clone to size() to prevent eventual exponential growth final KTypeHashSet<KType> cloned = new KTypeHashSet<KType>(this.size(), this.loadFactor); // We must NOT clone, because of the independent perturbation seeds cloned.addAll(this); return cloned; }
@Test public void testRemoveAllFromLookupContainer() { addFromArray(this.set, asArray(0, 1, 2, 3, 4)); // test against concrete HashSet final KTypeHashSet<KType> set2 = new KTypeHashSet<KType>(); set2.add(asArray(1, 3, 5)); Assert.assertEquals(2, this.set.removeAll(set2)); Assert.assertEquals(3, this.set.size()); TestUtils.assertSortedListEquals(this.set.toArray(), 0, 2, 4); }
/** Create a set from a variable number of arguments or an array of <code>KType</code>. */ public static <KType> KTypeHashSet<KType> from(final KType... elements) { final KTypeHashSet<KType> set = new KTypeHashSet<KType>(elements.length); set.add(elements); return set; }