-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Open
Description
Some interfaces defined in the package support only comparable types.
sets.Set
type Set[T comparable] interface {
Add(elements ...T)
Remove(elements ...T)
Contains(elements ...T) bool
containers.Container[T]
// Empty() bool
// Size() int
// Clear()
// Values() []interface{}
// String() string
}
maps.Map
type Map[K comparable, V any] interface {
Put(key K, value V)
Get(key K) (value V, found bool)
Remove(key K)
Keys() []K
containers.Container[V]
// Empty() bool
// Size() int
// Clear()
// Values() []interface{}
// String() string
}
lists.List
type List[T comparable] interface {
Get(index int) (T, bool)
Remove(index int)
Add(values ...T)
Contains(values ...T) bool
Sort(comparator utils.Comparator[T])
Swap(index1, index2 int)
Insert(index int, values ...T)
Set(index int, value T)
containers.Container[T]
// Empty() bool
// Size() int
// Clear()
// Values() []interface{}
// String() string
}
However, some implementations of these interfaces can support any type with a custom comparator.
Is it possible to change the type in the interface from comparable
to any
? This would allow
implementations to support any type with a custom comparator without breaking backward compatibility.
Metadata
Metadata
Assignees
Labels
No labels