UniqueTypes returns the set of unique Types in types in sorted order. types will be sorted and deduplicated in place.
(types []Type)
| 383 | // UniqueTypes returns the set of unique Types in types in sorted |
| 384 | // order. types will be sorted and deduplicated in place. |
| 385 | func UniqueTypes(types []Type) []Type { |
| 386 | sort.SliceStable(types, func(i, j int) bool { |
| 387 | return CompareTypes(types[i], types[j]) < 0 |
| 388 | }) |
| 389 | out := types[:0] |
| 390 | var prev Type |
| 391 | for _, typ := range types { |
| 392 | if typ != prev { |
| 393 | out = append(out, typ) |
| 394 | prev = typ |
| 395 | } |
| 396 | } |
| 397 | return out |
| 398 | } |
| 399 | |
| 400 | func CompareTypes(a, b Type) int { |
| 401 | aID, bID := a.ID(), b.ID() |
no test coverage detected