-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathenumerable.generated.go
94 lines (73 loc) · 1.94 KB
/
enumerable.generated.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
// This code was generated by a tool.
package enu
type Enumerable[T any] struct {
enumerator IEnumerator[T]
}
func New[T any](e IEnumerator[T]) *Enumerable[T] {
return &Enumerable[T]{enumerator: e}
}
func (e *Enumerable[T]) Each(iteratee func(T, int)) *Enumerable[T] {
each[T](e, func(item T, index int) bool {
iteratee(item, index)
return true
})
return e
}
func (e *Enumerable[T]) ToSlice() []T {
return ToSlice[T](e)
}
func (e *Enumerable[T]) Count() int {
return Count[T](e)
}
func (e *Enumerable[T]) Filter(predicate func(T, int) bool) *Enumerable[T] {
return New[T](Filter[T](e, predicate))
}
func (e *Enumerable[T]) Nth(nth int) (T, bool) {
return Nth[T](e, nth)
}
func (e *Enumerable[T]) Find(predicate func(T, int) bool) (T, bool) {
return Find[T](e, predicate)
}
func (e *Enumerable[T]) First() (T, bool) {
return First[T](e)
}
func (e *Enumerable[T]) Last() (T, bool) {
return Last[T](e)
}
func (e *Enumerable[T]) Reverse() *Enumerable[T] {
return New[T](Reverse[T](e))
}
func (e *Enumerable[T]) SortBy(sorter func(i, j T) bool) *Enumerable[T] {
return New[T](SortBy[T](e, sorter))
}
func (e *Enumerable[T]) Reject(predicate func(T, int) bool) *Enumerable[T] {
return New[T](Reject[T](e, predicate))
}
func (e *Enumerable[T]) IsAll(predicate func(T) bool) bool {
return IsAll[T](e, predicate)
}
func (e *Enumerable[T]) IsAny(predicate func(T) bool) bool {
return IsAny[T](e, predicate)
}
func (e *Enumerable[T]) Take(num int) *Enumerable[T] {
return New[T](Take[T](e, num))
}
func (e *Enumerable[T]) Result(out *[]T) *Enumerable[T] {
Result[T](e, out)
return e
}
func (e *Enumerable[T]) Err() error {
if p, ok := e.enumerator.(ErrorProvider); ok {
return p.Err()
}
return nil
}
func (e *Enumerable[T]) GetEnumerator() IEnumerator[T] {
return e.enumerator
}
func (e *Enumerable[T]) ToMap() map[int]T {
return Reduce[T](e, func(agg map[int]T, item T, index int) map[int]T {
agg[index] = item
return agg
}, map[int]T{})
}