Documentation ¶
Index ¶
- Variables
- func DoWhile[T any](enumerator IEnumerator[T], action func(T) bool)
- func Equal[T1, T2 any](a T1, b T2) bool
- func Reduce[T1, T2 any](from Queryable[T1], initializer T2, f func(T2, T1) T2) T2
- func Sum[T Number](query Queryable[T]) T
- type ArrayList
- func (list *ArrayList[T]) Contains(elem T) bool
- func (list *ArrayList[T]) Count() int
- func (list *ArrayList[T]) GetEnumerator() IEnumerator[T]
- func (list *ArrayList[T]) IndexOf(T) int
- func (list *ArrayList[T]) Push(x T)
- func (list *ArrayList[T]) Remove(item T)
- func (list *ArrayList[T]) RemoveAt(i int)
- func (list *ArrayList[T]) ToQueryable() Queryable[T]
- func (list *ArrayList[T]) ToSlice() []T
- type BTree
- type BTreeNode
- type ICollection
- type IEnumerator
- type LinkedList
- func (lst *LinkedList[T]) Contains(elem T) bool
- func (lst *LinkedList[T]) Count() int
- func (lst *LinkedList[T]) GetEnumerator() IEnumerator[T]
- func (lst *LinkedList[T]) IndexOf(elem T) int
- func (lst *LinkedList[T]) IsEmpty() bool
- func (lst *LinkedList[T]) Push(v T)
- func (lst *LinkedList[T]) Remove(data T)
- func (lst *LinkedList[T]) RemoveAt(index int)
- func (lst *LinkedList[T]) ToQueryable() Queryable[T]
- func (lst *LinkedList[T]) ToSlice() []T
- type LinkedListEnumerable
- type ListEnumerable
- type Number
- type Ordered
- type Queryable
- func (query Queryable[T]) All(predicate func(T) bool) bool
- func (query Queryable[T]) Any(predicate func(T) bool) bool
- func (query Queryable[T]) Count() int
- func (query Queryable[T]) CountIf(predicate func(T) bool) int
- func (query Queryable[T]) Distinct() Queryable[T]
- func (query Queryable[T]) First() (T, error)
- func (query Queryable[T]) FirstIf(predicate func(T) bool) (T, error)
- func (query Queryable[T]) ForEach(action func(int, T))
- func (query Queryable[T]) GetEnumerator() IEnumerator[T]
- func (query Queryable[T]) Skip(n int) Queryable[T]
- func (query Queryable[T]) Sort(cmp func(T, T) bool)
- func (query Queryable[T]) Take(n int) Queryable[T]
- func (query Queryable[T]) ToChannel(result chan<- T)
- func (query Queryable[T]) ToSlice() []T
- func (query Queryable[T]) Where(predicate func(T) bool) Queryable[T]
- type Stack
Constants ¶
This section is empty.
Variables ¶
var ( ErrorCannotFound = errors.New("can not find element") ErrorIndexoutOfBounds = errors.New("index out of bounds") )
Functions ¶
func DoWhile ¶
func DoWhile[T any](enumerator IEnumerator[T], action func(T) bool)
Types ¶
type ArrayList ¶
type ArrayList[T any] struct { // contains filtered or unexported fields }
ArrayList Array List for the slice
func (*ArrayList[T]) GetEnumerator ¶
func (list *ArrayList[T]) GetEnumerator() IEnumerator[T]
GetEnumerator get enumerable object
func (*ArrayList[T]) Remove ¶
func (list *ArrayList[T]) Remove(item T)
Remove removes an element from the list.
func (*ArrayList[T]) ToQueryable ¶
ToQueryable from ArrayList[T] to Queryable[T
type BTree ¶ added in v0.2.0
type BTree[K, V any] struct { // contains filtered or unexported fields }
BTree a B-tree data structures
func (*BTree[K, V]) Each ¶ added in v0.2.0
func (t *BTree[K, V]) Each(fn func(key K, val V))
Each calls 'fn' on every BTreeNode in the tree in order.
func (*BTree[K, V]) Put ¶ added in v0.2.0
func (t *BTree[K, V]) Put(key K, val V)
Put associates 'key' with 'val'.
type BTreeNode ¶ added in v0.2.0
type BTreeNode[K, V any] struct { // contains filtered or unexported fields }
type ICollection ¶
type IEnumerator ¶
type LinkedList ¶
type LinkedList[T any] struct { // contains filtered or unexported fields }
LinkedList is double linked list data structure
func NewLinkedList ¶
func NewLinkedList[T any]() *LinkedList[T]
NewLinkedList creates a new linked list of empty.
func NewLinkedListOf ¶
func NewLinkedListOf[T any](array []T) *LinkedList[T]
NewLinkedListOf creates a new linked list of array.
func (*LinkedList[T]) Contains ¶
func (lst *LinkedList[T]) Contains(elem T) bool
Contains return bool,that element is in the list.
func (*LinkedList[T]) Count ¶
func (lst *LinkedList[T]) Count() int
Count return a number, that's list elements count.
func (*LinkedList[T]) GetEnumerator ¶
func (lst *LinkedList[T]) GetEnumerator() IEnumerator[T]
GetEnumerator get enumerable object
func (*LinkedList[T]) IndexOf ¶
func (lst *LinkedList[T]) IndexOf(elem T) int
func (*LinkedList[T]) Remove ¶
func (lst *LinkedList[T]) Remove(data T)
Remove removes an element from the list.
func (*LinkedList[T]) RemoveAt ¶
func (lst *LinkedList[T]) RemoveAt(index int)
RemoveAt removes an element from the list by index.
func (*LinkedList[T]) ToQueryable ¶
func (lst *LinkedList[T]) ToQueryable() Queryable[T]
ToQueryable from LinkedList[T] to Queryable[T
func (*LinkedList[T]) ToSlice ¶
func (lst *LinkedList[T]) ToSlice() []T
ToSlice from ArrayList[T] to []T
type LinkedListEnumerable ¶
type LinkedListEnumerable[T any] struct { // contains filtered or unexported fields }
LinkedListEnumerable 支持遍历链表元素。
func (*LinkedListEnumerable[T]) Next ¶
func (it *LinkedListEnumerable[T]) Next() bool
Next 移动迭代器到下一个元互。 如果已经到达尾部则返回 false。
func (*LinkedListEnumerable[T]) Reset ¶
func (it *LinkedListEnumerable[T]) Reset()
func (*LinkedListEnumerable[T]) Value ¶
func (it *LinkedListEnumerable[T]) Value() (T, bool)
Value 返回当前元素内容。 如果元素为空 bool 值为 false。
type ListEnumerable ¶
type ListEnumerable[T any] struct { // contains filtered or unexported fields }
func (*ListEnumerable[T]) Next ¶
func (e *ListEnumerable[T]) Next() bool
func (*ListEnumerable[T]) Reset ¶
func (e *ListEnumerable[T]) Reset()
func (*ListEnumerable[T]) Value ¶
func (e *ListEnumerable[T]) Value() (T, bool)
type Queryable ¶
type Queryable[T any] []T
Queryable query collection
func (Queryable[T]) ForEach ¶
ForEach performs the specified action on each element of a collection.
func (Queryable[T]) GetEnumerator ¶
func (query Queryable[T]) GetEnumerator() IEnumerator[T]
GetEnumerator get enumerable object
type Stack ¶
type Stack[T any] []T
func NewStackOf ¶
func (*Stack[T]) GetEnumerator ¶
func (s *Stack[T]) GetEnumerator() IEnumerator[T]
GetEnumerator get enumerable object