Search in sources :

Example 6 with MutableIntList

use of org.eclipse.collections.api.list.primitive.MutableIntList in project eclipse-collections by eclipse.

the class PrimitiveCaseProcedureSerializationTest method oneCaseWithDefaultIntProcecure.

@Test
public void oneCaseWithDefaultIntProcecure() {
    MutableIntList ifOneList = IntLists.mutable.empty();
    MutableIntList defaultList = IntLists.mutable.empty();
    MutableIntList list = IntLists.mutable.with(1, 2);
    IntCaseProcedure procedure = new IntCaseProcedure(defaultList::add).addCase(value -> value == 1, ifOneList::add);
    Verify.assertSerializedForm(1L, "rO0ABXNyAEdvcmcuZWNsaXBzZS5jb2xsZWN0aW9ucy5pbXBsLmJsb2NrLnByb2NlZHVyZS5wcmlt\n" + "aXRpdmUuSW50Q2FzZVByb2NlZHVyZQAAAAAAAAABAgACTAAQZGVmYXVsdFByb2NlZHVyZXQARExv\n" + "cmcvZWNsaXBzZS9jb2xsZWN0aW9ucy9hcGkvYmxvY2svcHJvY2VkdXJlL3ByaW1pdGl2ZS9JbnRQ\n" + "cm9jZWR1cmU7TAATcHJlZGljYXRlUHJvY2VkdXJlc3QALkxvcmcvZWNsaXBzZS9jb2xsZWN0aW9u\n" + "cy9hcGkvbGlzdC9NdXRhYmxlTGlzdDt4cHNyACFqYXZhLmxhbmcuaW52b2tlLlNlcmlhbGl6ZWRM\n" + "YW1iZGFvYdCULCk2hQIACkkADmltcGxNZXRob2RLaW5kWwAMY2FwdHVyZWRBcmdzdAATW0xqYXZh\n" + "L2xhbmcvT2JqZWN0O0wADmNhcHR1cmluZ0NsYXNzdAARTGphdmEvbGFuZy9DbGFzcztMABhmdW5j\n" + "dGlvbmFsSW50ZXJmYWNlQ2xhc3N0ABJMamF2YS9sYW5nL1N0cmluZztMAB1mdW5jdGlvbmFsSW50\n" + "ZXJmYWNlTWV0aG9kTmFtZXEAfgAHTAAiZnVuY3Rpb25hbEludGVyZmFjZU1ldGhvZFNpZ25hdHVy\n" + "ZXEAfgAHTAAJaW1wbENsYXNzcQB+AAdMAA5pbXBsTWV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vSW50UHJlZGljYXRldAAGYWNjZXB0cQB+\n" + "ABR0AF5vcmcvZWNsaXBzZS9jb2xsZWN0aW9ucy9pbXBsL2Jsb2NrL3Byb2NlZHVyZS9wcmltaXRp\n" + "dmUvUHJpbWl0aXZlQ2FzZVByb2NlZHVyZVNlcmlhbGl6YXRpb25UZXN0dAAwbGFtYmRhJG9uZUNh\n" + "c2VXaXRoRGVmYXVsdEludFByb2NlY3VyZSQxODg0ZGZjMCQxcQB+ABRxAH4AFHNxAH4ABAAAAAl1\n" + "cQB+AAkAAAABc3EAfgALdwQAAAAAeHEAfgAOcQB+AA9xAH4AEHEAfgARcQB+ABJxAH4AE3EAfgAU\n" + "cQB+ABF4", procedure);
    // After the execution the internal state of the procedure should change
    // because ifOneList and defaultList are captured in the lambdas
    list.each(procedure);
    Verify.assertSerializedForm(1L, "rO0ABXNyAEdvcmcuZWNsaXBzZS5jb2xsZWN0aW9ucy5pbXBsLmJsb2NrLnByb2NlZHVyZS5wcmlt\n" + "aXRpdmUuSW50Q2FzZVByb2NlZHVyZQAAAAAAAAABAgACTAAQZGVmYXVsdFByb2NlZHVyZXQARExv\n" + "cmcvZWNsaXBzZS9jb2xsZWN0aW9ucy9hcGkvYmxvY2svcHJvY2VkdXJlL3ByaW1pdGl2ZS9JbnRQ\n" + "cm9jZWR1cmU7TAATcHJlZGljYXRlUHJvY2VkdXJlc3QALkxvcmcvZWNsaXBzZS9jb2xsZWN0aW9u\n" + "cy9hcGkvbGlzdC9NdXRhYmxlTGlzdDt4cHNyACFqYXZhLmxhbmcuaW52b2tlLlNlcmlhbGl6ZWRM\n" + "YW1iZGFvYdCULCk2hQIACkkADmltcGxNZXRob2RLaW5kWwAMY2FwdHVyZWRBcmdzdAATW0xqYXZh\n" + "L2xhbmcvT2JqZWN0O0wADmNhcHR1cmluZ0NsYXNzdAARTGphdmEvbGFuZy9DbGFzcztMABhmdW5j\n" + "dGlvbmFsSW50ZXJmYWNlQ2xhc3N0ABJMamF2YS9sYW5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mV0ABJMamF2YS9sYW5nL09iamVjdDtM\n" + "AAN0d29xAH4AGHhwc3EAfgAEAAAABnVxAH4ACQAAAABxAH4ADnQAQm9yZy9lY2xpcHNlL2NvbGxl\n" + "Y3Rpb25zL2FwaS9ibG9jay9wcmVkaWNhdGUvcHJpbWl0aXZlL0ludFByZWRpY2F0ZXQABmFjY2Vw\n" + "dHEAfgAUdABeb3JnL2VjbGlwc2UvY29sbGVjdGlvbnMvaW1wbC9ibG9jay9wcm9jZWR1cmUvcHJp\n" + "bWl0aXZlL1ByaW1pdGl2ZUNhc2VQcm9jZWR1cmVTZXJpYWxpemF0aW9uVGVzdHQAMGxhbWJkYSRv\n" + "bmVDYXNlV2l0aERlZmF1bHRJbnRQcm9jZWN1cmUkMTg4NGRmYzAkMXEAfgAUcQB+ABRzcQB+AAQA\n" + "AAAJdXEAfgAJAAAAAXNxAH4AC3cIAAAAAQAAAAF4cQB+AA5xAH4AD3EAfgAQcQB+ABFxAH4AEnEA\n" + "fgATcQB+ABRxAH4AEXg=", procedure);
}
Also used : MutableIntList(org.eclipse.collections.api.list.primitive.MutableIntList) Test(org.junit.Test)

Example 7 with MutableIntList

use of org.eclipse.collections.api.list.primitive.MutableIntList in project eclipse-collections by eclipse.

the class IntIntMapProbeTest method getSmallCollidingNumbers.

private MutableIntList getSmallCollidingNumbers() {
    int lower = Integer.MIN_VALUE;
    int upper = Integer.MAX_VALUE;
    MutableIntList collidingNumbers = new IntArrayList();
    int numberOne = this.smallMask(SpreadFunctions.intSpreadOne(0xABCDEF1));
    int numberTwo = this.smallMask(SpreadFunctions.intSpreadTwo(0xABCDEF1));
    for (int i = lower; i < upper && collidingNumbers.size() < SMALL_COLLIDING_KEY_COUNT; i++) {
        if (this.smallMask(SpreadFunctions.intSpreadOne(i)) == numberOne && this.smallMask(SpreadFunctions.intSpreadTwo(i)) == numberTwo) {
            collidingNumbers.add(i);
        }
    }
    return collidingNumbers;
}
Also used : MutableIntList(org.eclipse.collections.api.list.primitive.MutableIntList) IntArrayList(org.eclipse.collections.impl.list.mutable.primitive.IntArrayList)

Example 8 with MutableIntList

use of org.eclipse.collections.api.list.primitive.MutableIntList in project eclipse-collections by eclipse.

the class IntIntMapProbeTest method getLargeCollidingNumbers.

private MutableIntList getLargeCollidingNumbers() {
    int lower = Integer.MIN_VALUE;
    int upper = Integer.MAX_VALUE;
    int number = 23;
    MutableIntList collidingNumbers = new IntArrayList();
    for (int i = lower; i < upper && collidingNumbers.size() < LARGE_COLLIDING_KEY_COUNT; i++) {
        int index = this.largeMask(SpreadFunctions.intSpreadOne(i));
        if (index >= number && index <= number + 100) {
            collidingNumbers.add(i);
        }
    }
    return collidingNumbers;
}
Also used : MutableIntList(org.eclipse.collections.api.list.primitive.MutableIntList) IntArrayList(org.eclipse.collections.impl.list.mutable.primitive.IntArrayList)

Example 9 with MutableIntList

use of org.eclipse.collections.api.list.primitive.MutableIntList in project eclipse-collections by eclipse.

the class IntLongMapProbeTest method getLargeCollidingNumbers.

private MutableIntList getLargeCollidingNumbers() {
    int lower = Integer.MIN_VALUE;
    int upper = Integer.MAX_VALUE;
    int number = 23;
    MutableIntList collidingNumbers = new IntArrayList();
    for (int i = lower; i < upper && collidingNumbers.size() < LARGE_COLLIDING_KEY_COUNT; i++) {
        int index = this.largeMask(SpreadFunctions.intSpreadOne(i));
        if (index >= number && index <= number + 100) {
            collidingNumbers.add(i);
        }
    }
    return collidingNumbers;
}
Also used : MutableIntList(org.eclipse.collections.api.list.primitive.MutableIntList) IntArrayList(org.eclipse.collections.impl.list.mutable.primitive.IntArrayList)

Example 10 with MutableIntList

use of org.eclipse.collections.api.list.primitive.MutableIntList in project eclipse-collections by eclipse.

the class IntIntervalTest method each.

@Test
public void each() {
    MutableIntList list1 = IntLists.mutable.empty();
    IntInterval interval1 = IntInterval.oneTo(5);
    interval1.each(list1::add);
    Assert.assertEquals(list1, interval1);
    IntInterval interval2 = IntInterval.fromTo(5, 1);
    MutableIntList list2 = IntLists.mutable.empty();
    interval2.each(list2::add);
    Assert.assertEquals(list2, interval2);
}
Also used : MutableIntList(org.eclipse.collections.api.list.primitive.MutableIntList) Test(org.junit.Test)

Aggregations

MutableIntList (org.eclipse.collections.api.list.primitive.MutableIntList)19 IntArrayList (org.eclipse.collections.impl.list.mutable.primitive.IntArrayList)8 Test (org.junit.Test)8 ArrayList (java.util.ArrayList)2 IntIterable (org.eclipse.collections.api.IntIterable)2 LazyIntIterable (org.eclipse.collections.api.LazyIntIterable)2 IntIterator (org.eclipse.collections.api.iterator.IntIterator)2 ReverseIntIterable (org.eclipse.collections.impl.lazy.primitive.ReverseIntIterable)2 BooleanArrayList (org.eclipse.collections.impl.list.mutable.primitive.BooleanArrayList)2 ByteArrayList (org.eclipse.collections.impl.list.mutable.primitive.ByteArrayList)2 CharArrayList (org.eclipse.collections.impl.list.mutable.primitive.CharArrayList)2 DoubleArrayList (org.eclipse.collections.impl.list.mutable.primitive.DoubleArrayList)2 FloatArrayList (org.eclipse.collections.impl.list.mutable.primitive.FloatArrayList)2 LongArrayList (org.eclipse.collections.impl.list.mutable.primitive.LongArrayList)2 ShortArrayList (org.eclipse.collections.impl.list.mutable.primitive.ShortArrayList)2 MutableLong (org.apache.commons.lang3.mutable.MutableLong)1 SelectIntIterable (org.eclipse.collections.impl.lazy.primitive.SelectIntIterable)1 AbstractIntIterable (org.eclipse.collections.impl.primitive.AbstractIntIterable)1 Test (org.junit.jupiter.api.Test)1 IndexDescriptor (org.neo4j.internal.schema.IndexDescriptor)1