Skip to content

Commit 241a203

Browse files
authored
Add invrefpool (#33)
1 parent 3bff060 commit 241a203

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

Project.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "DataAPI"
22
uuid = "9a962f9c-6df0-11e9-0e5d-c546b8b5ee8a"
33
authors = ["quinnj <[email protected]>"]
4-
version = "1.4.1"
4+
version = "1.5.0"
55

66
[compat]
77
julia = "1"

src/DataAPI.jl

+24
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,30 @@ default definition.
6969
function refpool end
7070
refpool(A::AbstractArray) = nothing
7171

72+
"""
73+
invrefpool(A)
74+
75+
Whenever available, return an indexable object such that given an array `A`
76+
for which `refpool(A)` is not `nothing`:
77+
78+
* for any valid index `x` into `refpool(A)`, `invrefpool(A)[refpool(A)[x]]` is equal to `x`
79+
(according to `isequal`) and of the same type as `x`;
80+
* for any valid index `ix` into `invrefpool(A)` , `refpool(A)[invrefpool(A)[ix]]` is equal to `ix`
81+
(according to `isequal`) and of the same type as `ix`.
82+
83+
Additionally it is required that `haskey` is defined for `invrefpool(A)`,
84+
allowing to check if `ix` is a valid index into it.
85+
86+
By default, `invrefpool(A)` returns `nothing`.
87+
88+
If `invrefpool(A)` is not `nothing`, then `refpool(A)` also must not be `nothing`.
89+
90+
This generic function is owned by DataAPI.jl itself, which is the sole provider of the
91+
default definition.
92+
"""
93+
function invrefpool end
94+
invrefpool(A::AbstractArray) = nothing
95+
7296
"""
7397
describe(io::IO, x)
7498

0 commit comments

Comments
 (0)