insert method
Inserts count
new consecutive indices starting from index
into
indices, at random positions.
Implementation
@override
void insert(int index, int count) {
// Offset indices after insertion point.
for (var i = 0; i < indices.length; i++) {
if (indices[i] >= index) {
indices[i] += count;
}
}
// Insert new indices at random positions after currentIndex.
final newIndices = List.generate(count, (i) => index + i);
for (var newIndex in newIndices) {
final insertionIndex = _random.nextInt(indices.length + 1);
indices.insert(insertionIndex, newIndex);
}
}