shareOf function
The contiguous share [start, end) of count items that shard index of
shards owns, with inner boundaries rounded down to a multiple of
align.
Implementation
(int, int) shareOf(int count, int index, int shards, {int align = 1}) {
int boundary(int w) =>
w == shards ? count : (count * w ~/ shards) ~/ align * align;
return (boundary(index), boundary(index + 1));
}