Bags
Index
Mill.AbstractBagsMill.AlignedBagsMill.AlignedBagsMill.AlignedBagsMill.AlignedBagsMill.ScatteredBagsMill.ScatteredBagsMill.ScatteredBagsMill.adjustbagsMill.bagsMill.length2bagsMill.remapbags
API
Mill.AbstractBags — TypeAbstractBags{T}Supertype for structures storing indices of type T of bags' instances in BagNodes.
Mill.AlignedBags — TypeAlignedBags{T <: Integer} <: AbstractBags{T}AlignedBags struct stores indices of bags' instances in one or more UnitRange{T}s. This is only possible if instances of every bag are stored in one contiguous block.
See also: ScatteredBags.
Mill.AlignedBags — MethodAlignedBags()Construct a new AlignedBags struct containing no bags.
Examples
julia> AlignedBags()
AlignedBags{Int64}(UnitRange{Int64}[])Mill.AlignedBags — MethodAlignedBags(bags::UnitRange{<:Integer}...)Construct a new AlignedBags struct from bags in arguments.
Examples
julia> AlignedBags(1:3, 4:8)
AlignedBags{Int64}(UnitRange{Int64}[1:3, 4:8])Mill.AlignedBags — MethodAlignedBags(k::Vector{<:Integer})Construct a new AlignedBags struct from Vector k specifying the index of the bag each instance belongs to. Throws ArgumentError if this is not possible.
Examples
julia> AlignedBags([1, 1, 2, 2, 2, 4])
AlignedBags{Int64}(UnitRange{Int64}[1:2, 3:5, 0:-1, 6:6])Mill.ScatteredBags — TypeScatteredBags{T <: Integer} <: AbstractBags{T}ScatteredBags struct stores indices of bags' instances that are not necessarily contiguous.
See also: AlignedBags.
Mill.ScatteredBags — MethodScatteredBags()Construct a new ScatteredBags struct containing no bags.
Examples
julia> ScatteredBags()
ScatteredBags{Int64}(Vector{Int64}[])Mill.ScatteredBags — MethodScatteredBags(k::Vector{<:Integer})Construct a new ScatteredBags struct from Vector k specifying the index of the bag each instance belongs to.
Examples
julia> ScatteredBags([2, 2, 1, 1, 1, 3])
ScatteredBags{Int64}([[3, 4, 5], [1, 2], [6]])Mill.length2bags — Functionlength2bags(ls::Vector{<:Integer})Convert lengths of bags given in ls to AlignedBags with contiguous blocks.
Examples
julia> length2bags([1, 3, 2])
AlignedBags{Int64}(UnitRange{Int64}[1:1, 2:4, 5:6])See also: AlignedBags.
Mill.bags — Functionbags(k::Vector{<:Integer})
bags(k::Vector{T}) where T <: UnitRange{<:Integer}
bags(b::AbstractBags)Construct an AbstractBags structure that is most suitable for the input (AlignedBags if possible, ScatteredBags otherwise).
Examples
julia> bags([1, 1, 3])
AlignedBags{Int64}(UnitRange{Int64}[1:2, 0:-1, 3:3])
julia> bags([2, 3, 1, 2])
ScatteredBags{Int64}([[3], [1, 4], [2]])
julia> bags([1:3, 4:5])
AlignedBags{Int64}(UnitRange{Int64}[1:3, 4:5])
julia> bags(ScatteredBags())
ScatteredBags{Int64}(Vector{Int64}[])See also: AlignedBags, ScatteredBags.
Mill.remapbags — Functionremapbags(b::AbstractBags, idcs::VecOrRange{<:Integer}) -> (rb, I)Select a subset of bags in b corresponding to indices idcs and remap instance indices appropriately. Return new bags rb as well as a Vector of remapped instances I.
Examples
julia> remapbags(AlignedBags([1:1, 2:3, 4:5]), [1, 3])
(AlignedBags{Int64}(UnitRange{Int64}[1:1, 2:3]), [1, 4, 5])
julia> remapbags(ScatteredBags([[1,3], [2], Int[]]), [2])
(ScatteredBags{Int64}([[1]]), [2])Mill.adjustbags — Functionadjustbags(b::AlignedBags, mask::AbstractVector{Bool})Remove indices of instances brom bags b and remap the remaining instances accordingly.
Examples
julia> adjustbags(AlignedBags([1:2, 0:-1, 3:4]), [false, false, true, true])
AlignedBags{Int64}(UnitRange{Int64}[0:-1, 0:-1, 1:2])