Skip to content

Commit

Permalink
Add hashes
Browse files Browse the repository at this point in the history
  • Loading branch information
YingboMa committed Feb 21, 2024
1 parent d04c8cf commit b0d61aa
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/equations.jl
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ struct Connection <: Real
systems
end
Connection() = Connection(nothing)
Base.hash(c::Connection, seed::UInt) = hash(c.systems, (0xc80093537bdc1311 % UInt) seed)
hide_lhs(_::Connection) = true

function connect(sys1, sys2, syss...)
Expand Down
5 changes: 5 additions & 0 deletions src/struct.jl
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,11 @@ struct Struct <: Real
v::Vector{StructElement}
end

function Base.hash(x::Struct, seed::UInt)
h1 = hash(juliatype(x), seed)
h2 = foldr(hash, getelements(x), init = h1)
h2 (0x0e39036b7de2101a % UInt)
end

"""
symstruct(T)
Expand Down

0 comments on commit b0d61aa

Please sign in to comment.