Source reconstructed at patch state 0 of 1 — not the installed (fully patched) source.
1 Debian patch touch this file
| 1 |
package list |
| 2 |
|
| 3 |
import ( |
| 4 |
"github.com/jesseduffield/generics/slices" |
| 5 |
) |
| 6 |
|
| 7 |
type ComparableList[T comparable] struct { |
| 8 |
*List[T] |
| 9 |
} |
| 10 |
|
| 11 |
func NewComparable[T comparable]() *ComparableList[T] { |
| 12 |
return &ComparableList[T]{List: New[T]()} |
| 13 |
} |
| 14 |
|
| 15 |
func NewComparableFromSlice[T comparable](slice []T) *ComparableList[T] { |
| 16 |
return &ComparableList[T]{List: NewFromSlice(slice)} |
| 17 |
} |
| 18 |
|
| 19 |
func (l *ComparableList[T]) Equal(other *ComparableList[T]) bool { |
| 20 |
return l.EqualSlice(other.ToSlice()) |
| 21 |
} |
| 22 |
|
| 23 |
func (l *ComparableList[T]) EqualSlice(other []T) bool { |
| 24 |
return slices.Equal(l.ToSlice(), other) |
| 25 |
} |
| 26 |
|
| 27 |
func (l *ComparableList[T]) Compact() { |
| 28 |
l.slice = slices.Compact(l.slice) |
| 29 |
} |
| 30 |
|
| 31 |
func (l *ComparableList[T]) Index(needle T) int { |
| 32 |
return slices.Index(l.slice, needle) |
| 33 |
} |
| 34 |
|
| 35 |
func (l *ComparableList[T]) Contains(needle T) bool { |
| 36 |
return slices.Contains(l.slice, needle) |
| 37 |
} |
| 38 |
|
| 39 |
// Sorts in-place |
| 40 |
func (l *ComparableList[T]) SortFunc(test func(a T, b T) bool) { |
| 41 |
slices.SortFunc(l.slice, test) |
| 42 |
} |