From 8f36cfe5c63e221132ec959d8b55a91a5b2d140e Mon Sep 17 00:00:00 2001 From: Abhishek Bhatt Date: Wed, 10 Apr 2024 15:30:51 -0400 Subject: [PATCH] add filo parameter to querydelete! --- src/queries.jl | 4 ++-- test/test_tags_and_queries.jl | 14 ++++++++++++++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/queries.jl b/src/queries.jl index 41a8b03b..eb774f97 100644 --- a/src/queries.jl +++ b/src/queries.jl @@ -279,8 +279,8 @@ $TYPEDSIGNATURES A [`query`](@ref) for [`RegRef`](@ref) that also deletes the tag from the tag list for the `RegRef`. """ -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=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