ds/interfaces.go
2023-01-20 21:48:46 +01:00

37 lines
543 B
Go

package ds
type Addable[T any] interface {
Add(value T)
AddAll(values Iterable[T])
}
type Retrievable[T comparable] interface {
Has(value T) bool
}
type Indexable[K comparable, T any] interface {
Get(index K) T
}
type IndexedRemovable[K comparable, T any] interface {
RemoveAt(index K) T
}
type ComparingRemovable[T any] interface {
Remove(value T)
RemoveAll(values Iterable[T])
}
type Clearable interface {
Clear()
}
type Sized interface {
Size() int
Empty() bool
}
type Iterable[T any] interface {
Each(f func(value T))
}