Over at LightGraphs we have been discussing support for collections indexed by integers that can be either dense like Vector{T} or sparse like Dict{Int,T}. The idea is that you want to collect some T's together indexed by a range of integers 1:n. Often you will have a value for all or most of the indices and should use a Vector{T} for that case. But sometimes you will only have a few values and don't want to allocate O(n) storage just to hold a much smaller amount of data.
What is the best way to express this in types? Does Union{Associative{Int,T}, AbstractArray{T}} express this with no performance penalty? Is there any reason to avoid Union types? Thanks, James