Search in sources :

Example 11 with MutableIntList

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

the class IntIntervalTest method asReversed.

@Test
public void asReversed() {
    MutableIntList list = IntLists.mutable.empty();
    list.addAll(this.intInterval.asReversed());
    Assert.assertEquals(IntLists.mutable.with(3, 2, 1), list);
}
Also used : MutableIntList(org.eclipse.collections.api.list.primitive.MutableIntList) Test(org.junit.Test)

Example 12 with MutableIntList

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

the class IndexTxStateUpdater method onDeleteUncreated.

// PROPERTY CHANGES
/**
 * Creating an entity with its data in a transaction adds also adds that state to index transaction state (for matching indexes).
 * When deleting an entity this method will delete this state from the index transaction state.
 *
 * @param entity entity that was deleted.
 * @param propertyCursor property cursor for accessing the properties of the entity.
 * @param tokens the entity tokens this entity has.
 */
private void onDeleteUncreated(EntityCursor entity, PropertyCursor propertyCursor, long[] tokens) {
    assert noSchemaChangedInTx();
    entity.properties(propertyCursor);
    MutableIntList propertyKeyList = IntLists.mutable.empty();
    while (propertyCursor.next()) {
        propertyKeyList.add(propertyCursor.propertyKey());
    }
    // Make sure to sort the propertyKeyIds since SchemaMatcher.onMatchingSchema requires it.
    int[] propertyKeyIds = propertyKeyList.toSortedArray();
    Collection<IndexDescriptor> indexes = storageReader.valueIndexesGetRelated(tokens, propertyKeyIds, entity.entityType());
    if (!indexes.isEmpty()) {
        MutableIntObjectMap<Value> materializedProperties = IntObjectMaps.mutable.empty();
        SchemaMatcher.onMatchingSchema(indexes.iterator(), ANY_PROPERTY_KEY, propertyKeyIds, index -> {
            MemoryTracker memoryTracker = read.txState().memoryTracker();
            SchemaDescriptor schema = index.schema();
            Value[] values = getValueTuple(entity, propertyCursor, ANY_PROPERTY_KEY, NO_VALUE, schema.getPropertyIds(), materializedProperties, memoryTracker);
            ValueTuple valueTuple = ValueTuple.of(values);
            memoryTracker.allocateHeap(valueTuple.getShallowSize());
            read.txState().indexDoUpdateEntry(schema, entity.reference(), valueTuple, null);
        });
    }
}
Also used : SchemaDescriptor(org.neo4j.internal.schema.SchemaDescriptor) MutableIntList(org.eclipse.collections.api.list.primitive.MutableIntList) ValueTuple(org.neo4j.values.storable.ValueTuple) Value(org.neo4j.values.storable.Value) IndexDescriptor(org.neo4j.internal.schema.IndexDescriptor) MemoryTracker(org.neo4j.memory.MemoryTracker)

Example 13 with MutableIntList

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

the class SimpleBitSetTest method shouldAllowIterating.

@Test
void shouldAllowIterating() {
    // Given
    SimpleBitSet set = new SimpleBitSet(64);
    set.put(4);
    set.put(7);
    set.put(63);
    set.put(78);
    // When
    IntIterator iterator = set.iterator();
    MutableIntList found = new IntArrayList();
    while (iterator.hasNext()) {
        found.add(iterator.next());
    }
    // Then
    assertThat(found).isEqualTo(IntLists.immutable.of(4, 7, 63, 78));
}
Also used : IntIterator(org.eclipse.collections.api.iterator.IntIterator) MutableIntList(org.eclipse.collections.api.list.primitive.MutableIntList) IntArrayList(org.eclipse.collections.impl.list.mutable.primitive.IntArrayList) Test(org.junit.jupiter.api.Test)

Example 14 with MutableIntList

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

the class ArrayListIterateTest method collectIntOverOptimizeLimit.

@Test
public void collectIntOverOptimizeLimit() {
    ArrayList<Integer> list = new ArrayList<>(Interval.zeroTo(OVER_OPTIMIZED_LIMIT));
    MutableIntList actual = ArrayListIterate.collectInt(list, PrimitiveFunctions.unboxIntegerToInt());
    IntArrayList expected = new IntArrayList(list.size());
    for (int i = 0; i <= OVER_OPTIMIZED_LIMIT; i++) {
        expected.add(i);
    }
    Assert.assertEquals(expected, actual);
}
Also used : MutableIntList(org.eclipse.collections.api.list.primitive.MutableIntList) DoubleArrayList(org.eclipse.collections.impl.list.mutable.primitive.DoubleArrayList) ShortArrayList(org.eclipse.collections.impl.list.mutable.primitive.ShortArrayList) IntArrayList(org.eclipse.collections.impl.list.mutable.primitive.IntArrayList) ByteArrayList(org.eclipse.collections.impl.list.mutable.primitive.ByteArrayList) CharArrayList(org.eclipse.collections.impl.list.mutable.primitive.CharArrayList) FloatArrayList(org.eclipse.collections.impl.list.mutable.primitive.FloatArrayList) LongArrayList(org.eclipse.collections.impl.list.mutable.primitive.LongArrayList) ArrayList(java.util.ArrayList) BooleanArrayList(org.eclipse.collections.impl.list.mutable.primitive.BooleanArrayList) IntArrayList(org.eclipse.collections.impl.list.mutable.primitive.IntArrayList) Test(org.junit.Test)

Example 15 with MutableIntList

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

the class ArrayListIterateTest method collectIntWithTargetOverOptimizeLimit.

@Test
public void collectIntWithTargetOverOptimizeLimit() {
    ArrayList<Integer> list = new ArrayList<>(Interval.zeroTo(OVER_OPTIMIZED_LIMIT));
    MutableIntList target = new IntArrayList();
    MutableIntList actual = ArrayListIterate.collectInt(list, PrimitiveFunctions.unboxIntegerToInt(), target);
    IntArrayList expected = new IntArrayList(list.size());
    for (int i = 0; i <= OVER_OPTIMIZED_LIMIT; i++) {
        expected.add(i);
    }
    Assert.assertEquals(expected, actual);
    Assert.assertSame("Target sent as parameter was not returned as result", target, actual);
}
Also used : MutableIntList(org.eclipse.collections.api.list.primitive.MutableIntList) DoubleArrayList(org.eclipse.collections.impl.list.mutable.primitive.DoubleArrayList) ShortArrayList(org.eclipse.collections.impl.list.mutable.primitive.ShortArrayList) IntArrayList(org.eclipse.collections.impl.list.mutable.primitive.IntArrayList) ByteArrayList(org.eclipse.collections.impl.list.mutable.primitive.ByteArrayList) CharArrayList(org.eclipse.collections.impl.list.mutable.primitive.CharArrayList) FloatArrayList(org.eclipse.collections.impl.list.mutable.primitive.FloatArrayList) LongArrayList(org.eclipse.collections.impl.list.mutable.primitive.LongArrayList) ArrayList(java.util.ArrayList) BooleanArrayList(org.eclipse.collections.impl.list.mutable.primitive.BooleanArrayList) IntArrayList(org.eclipse.collections.impl.list.mutable.primitive.IntArrayList) 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