Documentation ¶
Index ¶
- func Entries[A constraints.Ordered, V any](t *Table[A, V]) []*base.Pair[A, V]
- type Table
- func Empty[A comparable, V any]() *Table[A, V]
- func FromSlice[A comparable, V any](elems []*base.Pair[A, V]) *Table[A, V]
- func FromSliceBy[A any, K comparable, V any](projection func(A) K, elems []*base.Pair[A, V]) *Table[A, V]
- func NewTable[A comparable, V any](elems iterable.Iterable[*base.Pair[A, V]]) *Table[A, V]
- func NewTableBy[A any, K comparable, V any](projection func(A) K, initialElements iterable.Iterable[*base.Pair[A, V]]) *Table[A, V]
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Table ¶
type Table[A any, V any] struct { Set func(A, V) bool Delete func(A) *V Get func(A) *V Len func() int ToSlice func() []*base.Pair[A, V] Merge func(*Table[A, V]) *Table[A, V] //Intersect func(*Table[A, V]) *Table[A, *Pair[V, V]] //Difference func(*Table[A, V]) *Table[A, V] Iterator func() iterable.Iterator[*base.Pair[A, V]] }
func Empty ¶
func Empty[A comparable, V any]() *Table[A, V]
func FromSliceBy ¶
func NewTableBy ¶
func NewTableBy[A any, K comparable, V any](projection func(A) K, initialElements iterable.Iterable[*base.Pair[A, V]]) *Table[A, V]
NewTableBy allows creation of a table from an element type which isn't comparable.
Why is 'comparable' required? Because this table implementation uses a map. Unfortunately, it's not possible to add implementations of user-defined types for comparable. This uses a projection function to create a `comparable` key. VERY VERY VERY IMPORTANT NOTES about the projection function: - it should be a pure function (no side effects) - it should make intuitive sense - don't mix tables which use different projections -- the results will be unpredictable and won't make sense
Click to show internal directories.
Click to hide internal directories.