Search in sources :

Example 21 with IntHashSet

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

the class IntIntMapLargeStressTest method getJDKSequenceCollisions.

protected MutableList<Integer> getJDKSequenceCollisions(int lower, int upper) {
    MutableList<Integer> jdkCollidingNumbers = FastList.newList();
    int slots = KEY_COUNT / (1 << 12) + 1;
    MutableIntSet indices = new IntHashSet();
    for (int i = lower; i < upper && jdkCollidingNumbers.size() < KEY_COUNT; i++) {
        int index = this.jdkIndex(i);
        if (indices.size() < slots) {
            indices.add(index);
            jdkCollidingNumbers.add(i);
        } else if (indices.contains(index)) {
            jdkCollidingNumbers.add(i);
        }
    }
    return jdkCollidingNumbers;
}
Also used : MutableIntSet(org.eclipse.collections.api.set.primitive.MutableIntSet) IntHashSet(org.eclipse.collections.impl.set.mutable.primitive.IntHashSet)

Example 22 with IntHashSet

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

the class IntIntMapSmallStressTest method getJDKSequenceCollisions.

protected MutableList<Integer> getJDKSequenceCollisions(int lower, int upper) {
    MutableList<Integer> jdkCollidingNumbers = FastList.newList();
    // slots = KEY_COUNT / (1 << 32) / (1 << MAP_SIZE) + 1;
    int slots = 1;
    MutableIntSet indices = new IntHashSet();
    for (int i = lower; i < upper && jdkCollidingNumbers.size() < KEY_COUNT; i++) {
        int index = this.jdkIndex(i);
        if (indices.size() < slots) {
            indices.add(index);
            jdkCollidingNumbers.add(i);
        } else if (indices.contains(index)) {
            jdkCollidingNumbers.add(i);
        }
    }
    return jdkCollidingNumbers;
}
Also used : MutableIntSet(org.eclipse.collections.api.set.primitive.MutableIntSet) 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