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);
}
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);
});
}
}
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));
}
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);
}
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);
}
Aggregations