private void massiveInsertionIteration(Random rnd, List<OIdentifiable> rids, ORidBag bag) {
Iterator<OIdentifiable> bagIterator = bag.iterator();
while (bagIterator.hasNext()) {
OIdentifiable bagValue = bagIterator.next();
Assert.assertTrue(rids.contains(bagValue));
}
Assert.assertEquals(bag.size(), rids.size());
for (int i = 0; i < 100; i++) {
if (rnd.nextDouble() < 0.2 & rids.size() > 5) {
final int index = rnd.nextInt(rids.size());
final OIdentifiable rid = rids.remove(index);
bag.remove(rid);
} else {
final int positionIndex = rnd.nextInt(300);
final OClusterPosition position = OClusterPositionFactory.INSTANCE.valueOf(positionIndex);
final ORecordId recordId = new ORecordId(1, position);
rids.add(recordId);
bag.add(recordId);
}
}
bagIterator = bag.iterator();
while (bagIterator.hasNext()) {
final OIdentifiable bagValue = bagIterator.next();
Assert.assertTrue(rids.contains(bagValue));
if (rnd.nextDouble() < 0.05) {
bagIterator.remove();
Assert.assertTrue(rids.remove(bagValue));
}
}
Assert.assertEquals(bag.size(), rids.size());
bagIterator = bag.iterator();
while (bagIterator.hasNext()) {
final OIdentifiable bagValue = bagIterator.next();
Assert.assertTrue(rids.contains(bagValue));
}
}