@@ -163,11 +163,16 @@ end
163163Base. nameof (l:: ConnectionElement ) = renamespace (nameof (l. sys), getname (l. v))
164164Base. isequal (l1:: ConnectionElement , l2:: ConnectionElement ) = l1 == l2
165165function Base.:(== )(l1:: ConnectionElement , l2:: ConnectionElement )
166- nameof (l1. sys) == nameof (l2. sys) && isequal (l1. v, l2. v) && l1 . isouter == l2 . isouter
166+ l1 . isouter == l2 . isouter && nameof (l1. sys) == nameof (l2. sys) && isequal (l1. v, l2. v)
167167end
168168
169169const _debug_mode = Base. JLOptions (). check_bounds == 1
170170
171+ function Base. show (io:: IO , c:: ConnectionElement )
172+ @unpack sys, v, isouter = c
173+ print (io, nameof (sys), " ." , v, " ::" , isouter ? " outer" : " inner" )
174+ end
175+
171176function Base. hash (e:: ConnectionElement , salt:: UInt )
172177 if _debug_mode
173178 @assert e. h === _hash_impl (e. sys, e. v, e. isouter)
@@ -189,6 +194,8 @@ struct ConnectionSet
189194end
190195ConnectionSet () = ConnectionSet (ConnectionElement[])
191196Base. copy (c:: ConnectionSet ) = ConnectionSet (copy (c. set))
197+ Base.:(== )(a:: ConnectionSet , b:: ConnectionSet ) = a. set == b. set
198+ Base. sort (a:: ConnectionSet ) = ConnectionSet (sort (a. set, by = string))
192199
193200function Base. show (io:: IO , c:: ConnectionSet )
194201 print (io, " <" )
@@ -389,21 +396,25 @@ function Base.merge(csets::AbstractVector{<:ConnectionSet}, allouter = false)
389396 id
390397 end
391398 end
399+ # isequal might not be equal? lol
400+ if v. sys. namespace != = nothing
401+ idx2ele[id] = v
402+ end
392403 if j > 1
393404 union! (union_find, prev_id[], id)
394405 end
395406 prev_id[] = id
396407 end
397- id2set = Dict {Int, ConnectionSet } ()
408+ id2set = Dict {Int, Int } ()
398409 merged_set = ConnectionSet[]
399410 for (id, ele) in enumerate (idx2ele)
400411 rid = find_root (union_find, id)
401- set = get! (id2set, rid) do
412+ set_idx = get! (id2set, rid) do
402413 set = ConnectionSet ()
403414 push! (merged_set, set)
404- set
415+ length (merged_set)
405416 end
406- push! (set . set, ele)
417+ push! (merged_set[set_idx] . set, ele)
407418 end
408419 merged_set
409420end
0 commit comments