Skip to content

Commit

Permalink
Remote IndexStyle for VNV
Browse files Browse the repository at this point in the history
  • Loading branch information
mhauru committed Oct 3, 2024
1 parent 172d128 commit 186a846
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/varnamedvector.jl
Original file line number Diff line number Diff line change
Expand Up @@ -391,18 +391,17 @@ function num_allocated(vnv::VarNamedVector, idx::Int)
return length(getrange(vnv, idx)) + num_inactive(vnv, idx)
end

# Basic Dictionary interface.
Base.eltype(vnv::VarNamedVector) = eltype(vnv.vals)
Base.isempty(vnv::VarNamedVector) = isempty(vnv.varnames)
Base.IndexStyle(::Type{<:VarNamedVector}) = IndexLinear()

# Dictionary interface.
Base.isempty(vnv::VarNamedVector) = isempty(vnv.varnames)
Base.length(vnv::VarNamedVector) = length(vnv.varnames)
Base.keys(vnv::VarNamedVector) = vnv.varnames
Base.values(vnv::VarNamedVector) = Iterators.map(Base.Fix1(getindex, vnv), vnv.varnames)
Base.pairs(vnv::VarNamedVector) = (vn => vnv[vn] for vn in keys(vnv))
Base.haskey(vnv::VarNamedVector, vn::VarName) = haskey(vnv.varname_to_index, vn)

# Vector-like interface.
Base.eltype(vnv::VarNamedVector) = eltype(vnv.vals)

"""
length_internal(vnv::VarNamedVector)
Expand Down

0 comments on commit 186a846

Please sign in to comment.