Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Cast ¶
func Cast[TOut, TIn any](source collections.ReadonlyList[TIn], selector ...collections.Selector[TIn, TOut]) collections.ReadonlyList[TOut]
Cast will create a readonly variant list which will perform a cast on each value. This will panic if any value can not be cast. This may take an optional selector to use instead of a default cast.
func From ¶
func From[T any](count CountFunc, get GetFunc[T], onChange OnChangeFunc) collections.ReadonlyList[T]
From creates a new readonly variant list which is sourced by the two given functions.
The first function returns the count of elements in the list. The second function gets an element from the list at the given index. The get function shouldn't fail for any index between zero inclusively and length exclusively. This returns nil if either function is nil.
func Wrap ¶
func Wrap(source any) collections.ReadonlyList[any]
Wrap tries to create a new readonly variant list using the giving value as the source of data. If the value can not be used, nil is returned.
The value maybe a string, any slice, any array, or from a struct, an interface which has `Count() int` and `Get(int) X`, or a struct or an interface which has `ToSlice() []X` or `Byte() []byte`. Except for the `ToSlice` or `Bytes` structs, which will create a slice and use that for the list, the rest will update the elements in the list as the underlying source is changed, if it can be changed.
Types ¶
type CountFunc ¶
type CountFunc func() int
CountFunc is a function signature to get a count of elements in a collection.
type GetFunc ¶
GetFunc is a function signature to get an element in a collection at a given index. The index should only be between zero inclusively, and the count exclusively gotten from the accompanying CountFunc.
type OnChangeFunc ¶
type OnChangeFunc func() events.Event[collections.ChangeArgs]
OnChangeFunc is a function signature for getting an event that indicates when the source changed.
This will be optional since not all data sources know when they have been changed and are able to emit an event.