TaggedStatePayloadSidecarImage<DataType extends Object> constructor
Creates an explicit payload and allocation-sidecar image.
Implementation
TaggedStatePayloadSidecarImage({
required Iterable<DataType?> payloads,
required Iterable<int> allocatedTags,
}) : payloads = List.unmodifiable(payloads),
allocatedTags = Set.unmodifiable(allocatedTags) {
if (this.payloads.isEmpty ||
this
.allocatedTags
.any((tag) => tag < 0 || tag >= this.payloads.length)) {
throw ArgumentError('Payloads and allocated tags must share a '
'positive, in-range capacity.');
}
if (this.allocatedTags.any((tag) => this.payloads[tag] == null)) {
throw ArgumentError('Every allocated tag must have a non-null payload.');
}
}