diff --git a/src/queries.jl b/src/queries.jl index 41a8b03b..0e110e5d 100644 --- a/src/queries.jl +++ b/src/queries.jl @@ -278,9 +278,10 @@ end $TYPEDSIGNATURES A [`query`](@ref) for [`RegRef`](@ref) that also deletes the tag from the tag list for the `RegRef`. +Allows the user to specify order of accessing tags to be FILO or FIFO. """ -function querydelete!(ref::RegRef, args...) # TODO there is a lot of code duplication here - r = query(ref, args...) +function querydelete!(ref::RegRef, args...; filo::Bool=true) # TODO there is a lot of code duplication here + r = query(ref, args...; filo) return isnothing(r) ? nothing : popat!(ref.reg.tags[ref.idx], r.depth) end diff --git a/test/test_tags_and_queries.jl b/test/test_tags_and_queries.jl index 8e295522..f83168f2 100644 --- a/test/test_tags_and_queries.jl +++ b/test/test_tags_and_queries.jl @@ -103,3 +103,17 @@ end @test queryall(reg, EntanglementCounterpart, 2, 22) == queryall(reg, EntanglementCounterpart, ==(2), ==(22)) == queryall(reg, Tag(EntanglementCounterpart, 2, 22)) @test queryall(reg, Tag(EntanglementCounterpart, 2, 22); filo=false) == reverse([(slot = reg[2], depth = 7, tag = Tag(EntanglementCounterpart,2,22)), (slot = reg[2], depth = 2, tag = Tag(EntanglementCounterpart,2,22))]) @test queryall(reg, EntanglementCounterpart, 2, 22; filo=false) == queryall(reg, EntanglementCounterpart, ==(2), ==(22); filo=false) == queryall(reg, Tag(EntanglementCounterpart, 2, 22); filo=false) + +reg = Register(4) +tag!(reg[1], EntanglementCounterpart, 4, 9) +tag!(reg[1], EntanglementCounterpart, 5, 2) +tag!(reg[1], EntanglementCounterpart, 7, 7) +tag!(reg[1], EntanglementCounterpart, 4, 9) +tag!(reg[1], EntanglementCounterpart, 2, 3) +tag!(reg[1], EntanglementCounterpart, 4, 9) + +@test reg.tags[1] == [Tag(EntanglementCounterpart, 4, 9), Tag(EntanglementCounterpart, 5, 2), Tag(EntanglementCounterpart, 7, 7), Tag(EntanglementCounterpart, 4, 9), Tag(EntanglementCounterpart, 2, 3), Tag(EntanglementCounterpart, 4, 9)] +querydelete!(reg[1], EntanglementCounterpart, 4, 9) +@test reg.tags[1] == [Tag(EntanglementCounterpart, 4, 9), Tag(EntanglementCounterpart, 5, 2), Tag(EntanglementCounterpart, 7, 7), Tag(EntanglementCounterpart, 4, 9), Tag(EntanglementCounterpart, 2, 3)] +querydelete!(reg[1], EntanglementCounterpart, 4, 9;filo=false) +@test reg.tags[1] == [Tag(EntanglementCounterpart, 5, 2), Tag(EntanglementCounterpart, 7, 7), Tag(EntanglementCounterpart, 4, 9), Tag(EntanglementCounterpart, 2, 3)] \ No newline at end of file