@@ -26,6 +26,28 @@ func (q Query) Aggregate(
26
26
return result
27
27
}
28
28
29
+ // AggregateT is the typed version of Aggregate.
30
+ //
31
+ // NOTE: Aggregate method has better performance than AggregateT
32
+ //
33
+ // f is of type: func(TSource, TSource) TSource
34
+ func (q Query ) AggregateT (f interface {}) interface {} {
35
+
36
+ fGenericFunc , err := newGenericFunc (
37
+ "AggregateT" , "f" , f ,
38
+ simpleParamValidator (newElemTypeSlice (new (genericType ), new (genericType )), newElemTypeSlice (new (genericType ))),
39
+ )
40
+ if err != nil {
41
+ panic (err )
42
+ }
43
+
44
+ fFunc := func (result interface {}, current interface {}) interface {} {
45
+ return fGenericFunc .Call (result , current )
46
+ }
47
+
48
+ return q .Aggregate (fFunc )
49
+ }
50
+
29
51
// AggregateWithSeed applies an accumulator function over a sequence.
30
52
// The specified seed value is used as the initial accumulator value.
31
53
//
@@ -52,6 +74,27 @@ func (q Query) AggregateWithSeed(
52
74
return result
53
75
}
54
76
77
+ // AggregateWithSeedT is the typed version of AggregateWithSeed.
78
+ //
79
+ // NOTE: AggregateWithSeed method has better performance than AggregateWithSeedT
80
+ //
81
+ // f is of a type "func(TAccumulate, TSource) TAccumulate"
82
+ func (q Query ) AggregateWithSeedT (seed interface {}, f interface {}) interface {} {
83
+ fGenericFunc , err := newGenericFunc (
84
+ "AggregateWithSeed" , "f" , f ,
85
+ simpleParamValidator (newElemTypeSlice (new (genericType ), new (genericType )), newElemTypeSlice (new (genericType ))),
86
+ )
87
+ if err != nil {
88
+ panic (err )
89
+ }
90
+
91
+ fFunc := func (result interface {}, current interface {}) interface {} {
92
+ return fGenericFunc .Call (result , current )
93
+ }
94
+
95
+ return q .AggregateWithSeed (seed , fFunc )
96
+ }
97
+
55
98
// AggregateWithSeedBy applies an accumulator function over a sequence.
56
99
// The specified seed value is used as the initial accumulator value,
57
100
// and the specified function is used to select the result value.
@@ -63,7 +106,6 @@ func (q Query) AggregateWithSeed(
63
106
// as the initial aggregate value. The result of func replaces the previous aggregated value.
64
107
//
65
108
// The final result of func is passed to resultSelector to obtain the final result of Aggregate.
66
- //
67
109
func (q Query ) AggregateWithSeedBy (
68
110
seed interface {},
69
111
f func (interface {}, interface {}) interface {},
@@ -79,3 +121,38 @@ func (q Query) AggregateWithSeedBy(
79
121
80
122
return resultSelector (result )
81
123
}
124
+
125
+ // AggregateWithSeedByT is the typed version of AggregateWithSeedBy.
126
+ //
127
+ // NOTE: AggregateWithSeedBy method has better performance than AggregateWithSeedByT
128
+ //
129
+ // f is of a type "func(TAccumulate, TSource) TAccumulate"
130
+ //
131
+ // resultSelectorFn is of type "func(TAccumulate) TResult"
132
+ func (q Query ) AggregateWithSeedByT (seed interface {}, f interface {}, resultSelectorFn interface {}) interface {} {
133
+ fGenericFunc , err := newGenericFunc (
134
+ "AggregateWithSeedByT" , "f" , f ,
135
+ simpleParamValidator (newElemTypeSlice (new (genericType ), new (genericType )), newElemTypeSlice (new (genericType ))),
136
+ )
137
+ if err != nil {
138
+ panic (err )
139
+ }
140
+
141
+ fFunc := func (result interface {}, current interface {}) interface {} {
142
+ return fGenericFunc .Call (result , current )
143
+ }
144
+
145
+ resultSelectorGenericFunc , err := newGenericFunc (
146
+ "AggregateWithSeedByT" , "resultSelectorFn" , resultSelectorFn ,
147
+ simpleParamValidator (newElemTypeSlice (new (genericType )), newElemTypeSlice (new (genericType ))),
148
+ )
149
+ if err != nil {
150
+ panic (err )
151
+ }
152
+
153
+ resultSelectorFunc := func (result interface {}) interface {} {
154
+ return resultSelectorGenericFunc .Call (result )
155
+ }
156
+
157
+ return q .AggregateWithSeedBy (seed , fFunc , resultSelectorFunc )
158
+ }
0 commit comments