Search in sources :

Example 16 with IntHashSet

use of org.eclipse.collections.impl.set.mutable.primitive.IntHashSet in project eclipse-collections by eclipse.

the class AbstractImmutableSet method collectInt.

@Override
public ImmutableIntSet collectInt(IntFunction<? super T> intFunction) {
    MutableIntSet result = new IntHashSet(this.size());
    this.forEach(new CollectIntProcedure<>(intFunction, result));
    return result.toImmutable();
}
Also used : MutableIntSet(org.eclipse.collections.api.set.primitive.MutableIntSet) IntHashSet(org.eclipse.collections.impl.set.mutable.primitive.IntHashSet)

Example 17 with IntHashSet

use of org.eclipse.collections.impl.set.mutable.primitive.IntHashSet in project eclipse-collections by eclipse.

the class AbstractMutableSet method collectInt.

@Override
public MutableIntSet collectInt(IntFunction<? super T> intFunction) {
    MutableIntSet result = new IntHashSet(this.size());
    this.forEach(new CollectIntProcedure<>(intFunction, result));
    return result;
}
Also used : MutableIntSet(org.eclipse.collections.api.set.primitive.MutableIntSet) IntHashSet(org.eclipse.collections.impl.set.mutable.primitive.IntHashSet)

Example 18 with IntHashSet

use of org.eclipse.collections.impl.set.mutable.primitive.IntHashSet in project eclipse-collections by eclipse.

the class IntIntMapProbeTest method testRandomGet.

private void testRandomGet(MutableIntIntMap intIntMap, int keyCount) {
    Random random = new Random(0x123456789ABCDL);
    MutableIntSet set = new IntHashSet(keyCount);
    while (set.size() < keyCount) {
        set.add(random.nextInt());
    }
    int[] randomNumbersForMap = set.toArray();
    this.shuffle(randomNumbersForMap, random);
    for (int i = 0; i < keyCount; i++) {
        intIntMap.put(randomNumbersForMap[i], randomNumbersForMap[i] * 10);
    }
    for (int i = 0; i < intIntMap.size(); i++) {
        Assert.assertEquals((long) (randomNumbersForMap[i] * 10), intIntMap.get(randomNumbersForMap[i]));
    }
}
Also used : MutableIntSet(org.eclipse.collections.api.set.primitive.MutableIntSet) Random(java.util.Random) IntHashSet(org.eclipse.collections.impl.set.mutable.primitive.IntHashSet)

Example 19 with IntHashSet

use of org.eclipse.collections.impl.set.mutable.primitive.IntHashSet in project eclipse-collections by eclipse.

the class IntLongMapProbeTest method testRandomRemove.

private void testRandomRemove(MutableIntLongMap intlongMap, 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++) {
        intlongMap.put(intKeysForMap[i], (long) (intKeysForMap[i] * 10));
    }
    this.shuffle(intKeysForMap, random);
    for (int i = 0; i < intKeysForMap.length; i++) {
        intlongMap.remove(intKeysForMap[i]);
        for (int j = i + 1; j < intKeysForMap.length; j++) {
            Assert.assertEquals((long) (intKeysForMap[j] * 10), intlongMap.get(intKeysForMap[j]));
        }
    }
}
Also used : MutableIntSet(org.eclipse.collections.api.set.primitive.MutableIntSet) Random(java.util.Random) IntHashSet(org.eclipse.collections.impl.set.mutable.primitive.IntHashSet)

Example 20 with IntHashSet

use of org.eclipse.collections.impl.set.mutable.primitive.IntHashSet in project eclipse-collections by eclipse.

the class CodePointAdapter method toSet.

@Override
public MutableIntSet toSet() {
    IntHashSet set = new IntHashSet(this.adapted.length());
    for (int i = 0; i < this.adapted.length(); ) {
        int codePoint = this.adapted.codePointAt(i);
        set.add(codePoint);
        i += Character.charCount(codePoint);
    }
    return set;
}
Also used : IntHashSet(org.eclipse.collections.impl.set.mutable.primitive.IntHashSet)

Aggregations

IntHashSet (org.eclipse.collections.impl.set.mutable.primitive.IntHashSet)22 MutableIntSet (org.eclipse.collections.api.set.primitive.MutableIntSet)8 Random (java.util.Random)4 FasterList (jcog.list.FasterList)2 BitSet (java.util.BitSet)1 List (java.util.List)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 Supplier (java.util.function.Supplier)1 ChangedTextInput (nars.op.in.ChangedTextInput)1 Term (nars.term.Term)1 Anom (nars.term.anon.Anom)1 Int (nars.term.atom.Int)1 Variable (nars.term.var.Variable)1 IntIterator (org.eclipse.collections.api.iterator.IntIterator)1 MutableIntIterator (org.eclipse.collections.api.iterator.MutableIntIterator)1 MutableList (org.eclipse.collections.api.list.MutableList)1 IntObjectPair (org.eclipse.collections.api.tuple.primitive.IntObjectPair)1 IntIntHashMap (org.eclipse.collections.impl.map.mutable.primitive.IntIntHashMap)1 IntObjectHashMap (org.eclipse.collections.impl.map.mutable.primitive.IntObjectHashMap)1 Test (org.junit.Test)1