ds/interfaces.go

38 lines
566 B
Go
Raw Normal View History

2023-01-20 21:48:46 +01:00
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
Set(index K, value T)
2023-01-20 21:48:46 +01:00
}
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))
}