TaggedReplayBufferImage<DataType extends Object> constructor
Creates an explicit replay payload and sidecar image.
Implementation
TaggedReplayBufferImage({
required Iterable<DataType?> payloads,
required Iterable<int?> reasons,
required Iterable<int> occupiedTags,
required Iterable<int> eligibleTags,
required Iterable<int> backoffRemaining,
}) : payloads = List.unmodifiable(payloads),
reasons = List.unmodifiable(reasons),
occupiedTags = Set.unmodifiable(occupiedTags),
eligibleTags = Set.unmodifiable(eligibleTags),
backoffRemaining = List.unmodifiable(backoffRemaining) {
final capacity = this.payloads.length;
if (capacity == 0 ||
this.reasons.length != capacity ||
this.backoffRemaining.length != capacity) {
throw ArgumentError('Replay payload and sidecar regions must share '
'a positive capacity.');
}
_validateTags(this.occupiedTags, capacity, 'occupiedTags');
_validateTags(this.eligibleTags, capacity, 'eligibleTags');
if (this.eligibleTags.difference(this.occupiedTags).isNotEmpty) {
throw ArgumentError('eligibleTags must be a subset of occupiedTags.');
}
if (this.backoffRemaining.any((cycles) => cycles < 0)) {
throw ArgumentError('Backoff cycles must not be negative.');
}
for (final tag in this.occupiedTags) {
if (this.payloads[tag] == null || this.reasons[tag] == null) {
throw ArgumentError(
'Every occupied tag must have payload and reason state.');
}
}
}