diff --git a/Project.toml b/Project.toml index 1b6c1f7..b3036bb 100644 --- a/Project.toml +++ b/Project.toml @@ -1,12 +1,12 @@ name = "PooledArrays" uuid = "2dfb63ee-cc39-5dd5-95bd-886bf059d720" -version = "1.0.0" +version = "1.1.0" [deps] DataAPI = "9a962f9c-6df0-11e9-0e5d-c546b8b5ee8a" [compat] -DataAPI = "1" +DataAPI = "1.5" julia = "1" [extras] diff --git a/src/PooledArrays.jl b/src/PooledArrays.jl index 9479039..fa4b9d0 100644 --- a/src/PooledArrays.jl +++ b/src/PooledArrays.jl @@ -118,6 +118,9 @@ The `compress` argument controls whether the default size of 32 bits is used (`U unsigned, `Int32` for signed) or if smaller integer types are chosen when they can be used. If `array` is not a `PooledArray` then the order of elements in `refpool` in the resulting `PooledArray` is the order of first appereance of elements in `array`. + +Note that if you hold mutable objects in `PooledArray` it is not allowed to modify them +after they are stored in it. """ PooledArray @@ -156,6 +159,7 @@ PooledArray(t::Type, r::Type) = PooledArray(Array(t,0), r) DataAPI.refarray(pa::PooledArray) = pa.refs DataAPI.refvalue(pa::PooledArray, i::Integer) = pa.pool[i] DataAPI.refpool(pa::PooledArray) = pa.pool +DataAPI.invrefpool(pa::PooledArray) = pa.invpool Base.size(pa::PooledArray) = size(pa.refs) Base.length(pa::PooledArray) = length(pa.refs) diff --git a/test/runtests.jl b/test/runtests.jl index a503773..60c99b7 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -1,6 +1,6 @@ using Test using PooledArrays -using DataAPI: refarray, refvalue, refpool +using DataAPI: refarray, refvalue, refpool, invrefpool @testset "PooledArrays" begin a = rand(10) @@ -87,7 +87,8 @@ using DataAPI: refarray, refvalue, refpool @test refvalue(s, refarray(s)[i]) == s[i] end @test refpool(s) == ["a", "b"] - + @test invrefpool(s) == Dict("a" => 1, "b" => 2) + @testset "push!" begin xs = PooledArray([10, 20, 30]) @test xs === push!(xs, -100)