Although, if the keys are “dense” like in your example, you can instead store the countmap in a Vector
, which makes it then quite faster to look up:
minkey, maxkey = extrema(keys(blobs_occ))
occ = zeros(Int, maxkey-minkey+1)
for (k, v) in blobs_occ
occ[k+1-minkey] = v
end
map!(x -> occ[x+1-minkey], blob_counts, blobs)