On Thu, Jul 27, 2017 at 09:36:31AM -0700,
howar...@gmail.com wrote:
>
https://golang.org/pkg/reflect/#DeepEqual
>
> "Pointer values are deeply equal if they are equal using Go's == operator
> or if they point to deeply equal values."
>
> By the rules described here, the fact that both pointers have the same
> value means it does not even NEED to check what they point to, so I don't
> think it ever even sees the cycle.
You are right about that, but that's a vastly simplified example
to show the basic idea of what I'm talking about. In reality, there
are no common components.
>
> So yeah, you would have to write your own implementation, or find one.
It's actually easy to do: You simply number the nodes, or well, the
memory locations being pointed to:
type state struct {
lhsm, rhsm map[interface{}] int
lhsc, rhsc int
}
Algorithm for comparing two pointers.
if lhsm[left side pointer] == 0 {
lhsc++ // First counter is 1.
lhsm[left side pointer] = lhsc
}
... same for right ...
return lhsm[left side ptr] == rhsm[right side ptr]
Obviously you still have to do the recursion.
I guess I should try to write that.