use of org.eclipse.collections.impl.set.mutable.primitive.IntHashSet in project eclipse-collections by eclipse.
the class CodePointAdapter method distinct.
@Override
public CodePointAdapter distinct() {
StringBuilder builder = new StringBuilder();
IntHashSet seenSoFar = new IntHashSet();
int length = this.adapted.length();
for (int i = 0; i < length; ) {
int codePoint = this.adapted.codePointAt(i);
if (seenSoFar.add(codePoint)) {
builder.appendCodePoint(codePoint);
}
i += Character.charCount(codePoint);
}
return new CodePointAdapter(builder.toString());
}
use of org.eclipse.collections.impl.set.mutable.primitive.IntHashSet in project eclipse-collections by eclipse.
the class SetAdapter method collectInt.
@Override
public MutableIntSet collectInt(IntFunction<? super T> intFunction) {
IntHashSet result = new IntHashSet(this.size());
this.forEach(new CollectIntProcedure<>(intFunction, result));
return result;
}
use of org.eclipse.collections.impl.set.mutable.primitive.IntHashSet in project eclipse-collections by eclipse.
the class StackIterableTestCase method collectIntWithTarget.
@Override
@Test
public void collectIntWithTarget() {
IntHashSet target = new IntHashSet();
StackIterable<Integer> stack = this.newStackFromTopToBottom(1, 2, 3);
IntHashSet result = stack.collectInt(PrimitiveFunctions.unboxIntegerToInt(), target);
Assert.assertEquals(IntHashSet.newSetWith(1, 2, 3), result);
Assert.assertSame("Target sent as parameter not returned", target, result);
}
use of org.eclipse.collections.impl.set.mutable.primitive.IntHashSet in project eclipse-collections by eclipse.
the class IntHashSetAddTest method runHashPut.
private void runHashPut(int[] values) {
for (int i = 0; i < 100; i++) {
this.runHashContains(this.runHashPut(values, 1000, 1000), values, 1000, 1000);
}
for (int i = 0; i < 100; i++) {
this.runHashContains(this.runHashPut(values, 1000000, 1), values, 1000000, 1);
}
IntHashSet set = null;
long now1 = System.currentTimeMillis();
for (int i = 0; i < 100; i++) {
set = this.runHashPut(values, 1000000, 1);
}
long time1 = System.currentTimeMillis() - now1;
LOGGER.info("IntHashSet, set size 1,000,000, puts/msec: {}", 100000000 / time1);
long now2 = System.currentTimeMillis();
for (int i = 0; i < 100; i++) {
this.runHashContains(this.runHashPut(values, 1000000, 1), values, 1000000, 1);
}
long time2 = System.currentTimeMillis() - now2;
LOGGER.info("IntHashSet, set size 1,000,000, contains/msec: {}", 100000000 / time2);
}
use of org.eclipse.collections.impl.set.mutable.primitive.IntHashSet in project eclipse-collections by eclipse.
the class IntIntMapProbeTest method testRandomRemove.
private void testRandomRemove(MutableIntIntMap intIntMap, int keyCount) {
Random random = new Random(0x123456789ABCDL);
MutableIntSet set = new IntHashSet(keyCount);
while (set.size() < keyCount) {
set.add(random.nextInt());
}
int[] intKeysForMap = set.toArray();
this.shuffle(intKeysForMap, random);
for (int i = 0; i < keyCount; i++) {
intIntMap.put(intKeysForMap[i], intKeysForMap[i] * 10);
}
this.shuffle(intKeysForMap, random);
for (int i = 0; i < intKeysForMap.length; i++) {
intIntMap.remove(intKeysForMap[i]);
for (int j = i + 1; j < intKeysForMap.length; j++) {
Assert.assertEquals((long) (intKeysForMap[j] * 10), intIntMap.get(intKeysForMap[j]));
}
}
}
Aggregations