From 897b7a0a34c2c64b66e82af463a3d10f868dc1e4 Mon Sep 17 00:00:00 2001 From: Sheehan Olver Date: Thu, 4 Feb 2021 12:48:18 +0000 Subject: [PATCH] Support Sets by implementing hash (#60) --- Project.toml | 2 +- src/Infinity.jl | 5 ++++- test/runtests.jl | 7 +++++++ 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/Project.toml b/Project.toml index 0eed954..f919f95 100644 --- a/Project.toml +++ b/Project.toml @@ -1,6 +1,6 @@ name = "InfiniteArrays" uuid = "4858937d-0d70-526a-a4dd-2d5cb5dd786c" -version = "0.9.2" +version = "0.9.3" [deps] ArrayLayouts = "4c555306-a7a7-4459-81d9-ec55ddd5c99a" diff --git a/src/Infinity.jl b/src/Infinity.jl index a6136e3..8e69134 100644 --- a/src/Infinity.jl +++ b/src/Infinity.jl @@ -375,4 +375,7 @@ Base.Checked.checked_add(::Integer, x::SignedInfinity) = x Base.Checked.checked_add(x::SignedInfinity, ::Integer) = x -Base.to_index(::Infinity) = ∞ \ No newline at end of file +Base.to_index(::Infinity) = ∞ + + +Base.hash(::Infinity) = 0x020113134b21797f # made up \ No newline at end of file diff --git a/test/runtests.jl b/test/runtests.jl index 1f7a37e..25395af 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -1025,3 +1025,10 @@ end AbstractArray{Float64}(transpose(1:∞)) ≡ AbstractArray{Float64}(transpose(Base.OneTo(∞))) ≡ transpose(InfUnitRange(1.0)) end + +@testset "Set" begin + s = Set([∞,1]) + @test 1 in s + @test ∞ in s + @test 2 ∉ s +end