Documentation ¶
Overview ¶
generics
泛型工具庫 ¶
數組與集合 ¶
Types:
// ZeroStruct 空結構 type ZeroStruct struct{} // TList 列表 type TList[T comparable] []T // TMap 字典 type TMap[K comparable, V any] map[K]V
Constraints:
// Zero 空結構對象 var Zero = ZeroStruct{}
Index ¶
- Variables
- type LessFunc
- type TList
- func (list TList[T]) Distinct() (res TList[T])
- func (list TList[T]) Empty() bool
- func (list TList[T]) ForEach(handle func(index int, value T) error) (succeeded int, err error)
- func (list TList[T]) Len() int
- func (list TList[T]) Root() []T
- func (list TList[T]) Sort(less LessFunc) TList[T]
- func (list TList[T]) SortStable(less LessFunc) TList[T]
- func (list TList[T]) ToSet() (set TMap[T, ZeroStruct])
- type TMap
- func (m TMap[K, V]) Delete(key K) TMap[K, V]
- func (m TMap[K, V]) Empty() bool
- func (m TMap[K, V]) Filter(filter func(key K, value V) bool) TMap[K, V]
- func (m TMap[K, V]) ForEach(handle func(key K, value V) error) (succeeded int, err error)
- func (m TMap[K, V]) Keys() (list TList[K])
- func (m TMap[K, V]) Len() int
- func (m TMap[K, V]) Root() map[K]V
- func (m TMap[K, V]) Values() (list []V)
- type ZeroStruct
Constants ¶
This section is empty.
Variables ¶
View Source
var Zero = ZeroStruct{}
Zero 空結構對象
Functions ¶
This section is empty.
Types ¶
type LessFunc ¶
比較函數
func Ascending ¶
Ascending 構造 LessFunc 用於升序排序
arr := []uint32{3, 1, 4, 1, 5, 9} List(arr).Sort(Ascending(arr))
func Descending ¶
Descending 構造 LessFunc 用於降序排序
arr := []uint32{3, 1, 4, 1, 5, 9} List(arr).Sort(Descending(arr))
type TList ¶
type TList[T comparable] []T
TList 任意類型列表
func (TList[T]) SortStable ¶
對列表排序, 包裝 sort.SliceStable
Click to show internal directories.
Click to hide internal directories.