Custom collection types
Index
RigidBodyDynamics.CustomCollections.CacheIndexDict
RigidBodyDynamics.CustomCollections.ConstDict
RigidBodyDynamics.CustomCollections.ConstVector
RigidBodyDynamics.CustomCollections.IndexDict
RigidBodyDynamics.CustomCollections.NullDict
RigidBodyDynamics.CustomCollections.SegmentedBlockDiagonalMatrix
RigidBodyDynamics.CustomCollections.SegmentedVector
Types
mutable struct 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.
An immutable AbstractDict
for which the value is the same, no matter what the key is.
struct ConstVector{T} <: AbstractArray{T,1}
An immutable AbstractVector
for which all elements are the same, represented compactly and as a bitstype if the element type is a bitstype.
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} <: AbstractDict{K,V}
An immutable associative type that signifies an empty dictionary and does not allocate any memory.
struct SegmentedBlockDiagonalMatrix{T, M<:AbstractArray{T,2}} <: AbstractArray{T,2}
SegmentedBlockDiagonalMatrix
is an AbstractMatrix
backed by a parent AbstractMatrix
, which additionally stores a sequence of views into the diagonal blocks of the parent matrix. This type is useful for storing and updating block-diagonal matrices whose block contents may change but whose overall structure is fixed, such as configuration derivative <-> velocity jacobians.
struct SegmentedVector{K, T, KeyRange<:AbstractRange{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