| 1 |
// compile |
| 2 |
|
| 3 |
// Copyright 2022 The Go Authors. All rights reserved. |
| 4 |
// Use of this source code is governed by a BSD-style |
| 5 |
// license that can be found in the LICENSE file. |
| 6 |
|
| 7 |
package main |
| 8 |
|
| 9 |
type Addr struct { |
| 10 |
hi uint64 |
| 11 |
lo uint64 |
| 12 |
z *byte |
| 13 |
} |
| 14 |
|
| 15 |
func EqualMap[M1, M2 ~map[K]V, K, V comparable](m1 M1, m2 M2) bool { |
| 16 |
for k, v1 := range m1 { |
| 17 |
if v2, ok := m2[k]; !ok || v1 != v2 { |
| 18 |
return false |
| 19 |
} |
| 20 |
} |
| 21 |
return true |
| 22 |
} |
| 23 |
|
| 24 |
type Set[T comparable] map[T]struct{} |
| 25 |
|
| 26 |
func NewSet[T comparable](items ...T) Set[T] { |
| 27 |
return nil |
| 28 |
} |
| 29 |
|
| 30 |
func (s Set[T]) Equals(other Set[T]) bool { |
| 31 |
return EqualMap(s, other) |
| 32 |
} |
| 33 |
|
| 34 |
func main() { |
| 35 |
NewSet[Addr](Addr{0, 0, nil}) |
| 36 |
} |