Custom collection types
Index
RigidBodyDynamics.CustomCollections.CacheIndexDict
RigidBodyDynamics.CustomCollections.ConstVector
RigidBodyDynamics.CustomCollections.DiscardVector
RigidBodyDynamics.CustomCollections.IndexDict
RigidBodyDynamics.CustomCollections.NullDict
RigidBodyDynamics.CustomCollections.SegmentedVector
Types
type CacheIndexDict{K, KeyRange<:AbstractUnitRange{K}, V} <: RigidBodyDynamics.CustomCollections.AbstractIndexDict{K,V}
Like IndexDict
, but contains an additional Bool
dirty bit to be used in algorithms involving cached data.
struct ConstVector{T} <: AbstractArray{T,1}
An immutable AbstractVector
for which all elements are the same, represented compactly and as an isbits type if the element type is isbits
.
bitstype 64 DiscardVector <: AbstractArray{Any,1}
DiscardVector
is an AbstractVector
whose setindex!
simply discards the value. This is useful for broadcast!
calls where the output of the broadcasted function is not interesting, specifically when the broadcasted function is in-place and there are arguments that need to be treated as scalars, so that a simple foreach doesn't do the job.
struct IndexDict{K, KeyRange<:AbstractUnitRange{K}, V} <: RigidBodyDynamics.CustomCollections.AbstractIndexDict{K,V}
An associative type whose keys are an AbstractUnitRange
, and whose values are stored in a Vector
. IndexDict
is an ordered associative collection, with the order determined by key range. The nature of the keys enables very fast lookups and stores.
Examples
julia> IndexDict(2 : 4, [4, 5, 6])
RigidBodyDynamics.CustomCollections.IndexDict{Int64,UnitRange{Int64},Int64} with 3 entries:
2 => 4
3 => 5
4 => 6
julia> IndexDict{Int32, UnitRange{Int32}}(i => 3 * i for i in Int32[4, 2, 3])
RigidBodyDynamics.CustomCollections.IndexDict{Int32,UnitRange{Int32},Int64} with 3 entries:
2 => 6
3 => 9
4 => 12
struct NullDict{K, V} <: Associative{K,V}
An immutable associative type that signifies an empty dictionary and does not allocate any memory.
struct SegmentedVector{K, T, KeyRange<:Range{K}, P<:AbstractArray{T,1}} <: AbstractArray{T,1}
SegmentedVector
is an AbstractVector
backed by another AbstractVector
(its parent), which additionally stores an IndexDict
containing views into the parent. Together, these views cover the parent.
Examples
julia> x = [1., 2., 3., 4.]
4-element Array{Float64,1}:
1.0
2.0
3.0
4.0
julia> viewlength(i) = 2
viewlength (generic function with 1 method)
julia> xseg = SegmentedVector{Int}(x, 1 : 2, viewlength)
4-element RigidBodyDynamics.CustomCollections.SegmentedVector{Int64,Float64,Base.OneTo{Int64},Array{Float64,1}}:
1.0
2.0
3.0
4.0
julia> segments(xseg)[1]
2-element SubArray{Float64,1,Array{Float64,1},Tuple{UnitRange{Int64}},true}:
1.0
2.0
julia> yseg = similar(xseg, Int32); yseg .= 1 : 4 # same view ranges, different element type
4-element RigidBodyDynamics.CustomCollections.SegmentedVector{Int64,Int32,Base.OneTo{Int64},Array{Int32,1}}:
1
2
3
4
julia> segments(yseg)[2]
2-element SubArray{Int32,1,Array{Int32,1},Tuple{UnitRange{Int64}},true}:
3
4