// MapEquiv returns true if its arguments are equivalent as maps. // First argument is an iseq.PMap. // Second argument must be convertible to a map. (Someeday we may handle go maps.) // To be equivalent, must contain equivalent keys and values. func MapEquiv(m1 iseq.PMap, obj interface{}) bool { if m1 == obj { return true } if _, ok := obj.(map[interface{}]interface{}); ok { // TODO: figure out how to handle go maps return false } if m2, ok := obj.(iseq.PMap); ok { if m1.Count() != m2.Count() { return false } for s := m1.Seq(); s != nil; s = s.Next() { me := s.First().(iseq.MapEntry) found := m2.ContainsKey(me.Key()) if !found || !Equiv(me.Val(), m2.ValAt(me.Key())) { return false } } return true } return false }
// HashMap computes a hash for an iseq.PMap func HashMap(m iseq.PMap) uint32 { return HashUnordered(m.Seq()) }