@@ -12,179 +12,239 @@ namespace StructLinq
1212
1313 public static partial class StructEnumerable
1414 {
15+ private static Int16 SumInt16 < TEnumerator > ( TEnumerator enumerator )
16+ where TEnumerator : struct , IEnumerator < Int16 >
17+ {
18+ Int16 result = 0 ;
19+ while ( enumerator . MoveNext ( ) )
20+ {
21+ result += enumerator . Current ;
22+ }
23+ return result ;
24+ }
25+
1526 public static Int16 Sum < TEnumerator > ( this IStructEnumerable < Int16 , TEnumerator > enumerable )
1627 where TEnumerator : struct , IEnumerator < Int16 >
1728 {
1829 using ( var enumerator = enumerable . GetStructEnumerator ( ) )
1930 {
20- Int16 result = 0 ;
21- while ( enumerator . MoveNext ( ) )
22- {
23- result += enumerator . Current ;
24- }
25- return result ;
31+ return SumInt16 ( enumerator ) ;
2632 }
2733 }
2834 }
2935
3036
3137 public static partial class StructEnumerable
3238 {
39+ private static Int32 SumInt32 < TEnumerator > ( TEnumerator enumerator )
40+ where TEnumerator : struct , IEnumerator < Int32 >
41+ {
42+ Int32 result = 0 ;
43+ while ( enumerator . MoveNext ( ) )
44+ {
45+ result += enumerator . Current ;
46+ }
47+ return result ;
48+ }
49+
3350 public static Int32 Sum < TEnumerator > ( this IStructEnumerable < Int32 , TEnumerator > enumerable )
3451 where TEnumerator : struct , IEnumerator < Int32 >
3552 {
3653 using ( var enumerator = enumerable . GetStructEnumerator ( ) )
3754 {
38- Int32 result = 0 ;
39- while ( enumerator . MoveNext ( ) )
40- {
41- result += enumerator . Current ;
42- }
43- return result ;
55+ return SumInt32 ( enumerator ) ;
4456 }
4557 }
4658 }
4759
4860
4961 public static partial class StructEnumerable
5062 {
63+ private static Int64 SumInt64 < TEnumerator > ( TEnumerator enumerator )
64+ where TEnumerator : struct , IEnumerator < Int64 >
65+ {
66+ Int64 result = 0 ;
67+ while ( enumerator . MoveNext ( ) )
68+ {
69+ result += enumerator . Current ;
70+ }
71+ return result ;
72+ }
73+
5174 public static Int64 Sum < TEnumerator > ( this IStructEnumerable < Int64 , TEnumerator > enumerable )
5275 where TEnumerator : struct , IEnumerator < Int64 >
5376 {
5477 using ( var enumerator = enumerable . GetStructEnumerator ( ) )
5578 {
56- Int64 result = 0 ;
57- while ( enumerator . MoveNext ( ) )
58- {
59- result += enumerator . Current ;
60- }
61- return result ;
79+ return SumInt64 ( enumerator ) ;
6280 }
6381 }
6482 }
6583
6684
6785 public static partial class StructEnumerable
6886 {
87+ private static UInt16 SumUInt16 < TEnumerator > ( TEnumerator enumerator )
88+ where TEnumerator : struct , IEnumerator < UInt16 >
89+ {
90+ UInt16 result = 0 ;
91+ while ( enumerator . MoveNext ( ) )
92+ {
93+ result += enumerator . Current ;
94+ }
95+ return result ;
96+ }
97+
6998 public static UInt16 Sum < TEnumerator > ( this IStructEnumerable < UInt16 , TEnumerator > enumerable )
7099 where TEnumerator : struct , IEnumerator < UInt16 >
71100 {
72101 using ( var enumerator = enumerable . GetStructEnumerator ( ) )
73102 {
74- UInt16 result = 0 ;
75- while ( enumerator . MoveNext ( ) )
76- {
77- result += enumerator . Current ;
78- }
79- return result ;
103+ return SumUInt16 ( enumerator ) ;
80104 }
81105 }
82106 }
83107
84108
85109 public static partial class StructEnumerable
86110 {
111+ private static UInt32 SumUInt32 < TEnumerator > ( TEnumerator enumerator )
112+ where TEnumerator : struct , IEnumerator < UInt32 >
113+ {
114+ UInt32 result = 0 ;
115+ while ( enumerator . MoveNext ( ) )
116+ {
117+ result += enumerator . Current ;
118+ }
119+ return result ;
120+ }
121+
87122 public static UInt32 Sum < TEnumerator > ( this IStructEnumerable < UInt32 , TEnumerator > enumerable )
88123 where TEnumerator : struct , IEnumerator < UInt32 >
89124 {
90125 using ( var enumerator = enumerable . GetStructEnumerator ( ) )
91126 {
92- UInt32 result = 0 ;
93- while ( enumerator . MoveNext ( ) )
94- {
95- result += enumerator . Current ;
96- }
97- return result ;
127+ return SumUInt32 ( enumerator ) ;
98128 }
99129 }
100130 }
101131
102132
103133 public static partial class StructEnumerable
104134 {
135+ private static UInt64 SumUInt64 < TEnumerator > ( TEnumerator enumerator )
136+ where TEnumerator : struct , IEnumerator < UInt64 >
137+ {
138+ UInt64 result = 0 ;
139+ while ( enumerator . MoveNext ( ) )
140+ {
141+ result += enumerator . Current ;
142+ }
143+ return result ;
144+ }
145+
105146 public static UInt64 Sum < TEnumerator > ( this IStructEnumerable < UInt64 , TEnumerator > enumerable )
106147 where TEnumerator : struct , IEnumerator < UInt64 >
107148 {
108149 using ( var enumerator = enumerable . GetStructEnumerator ( ) )
109150 {
110- UInt64 result = 0 ;
111- while ( enumerator . MoveNext ( ) )
112- {
113- result += enumerator . Current ;
114- }
115- return result ;
151+ return SumUInt64 ( enumerator ) ;
116152 }
117153 }
118154 }
119155
120156
121157 public static partial class StructEnumerable
122158 {
159+ private static Single SumSingle < TEnumerator > ( TEnumerator enumerator )
160+ where TEnumerator : struct , IEnumerator < Single >
161+ {
162+ Single result = 0 ;
163+ while ( enumerator . MoveNext ( ) )
164+ {
165+ result += enumerator . Current ;
166+ }
167+ return result ;
168+ }
169+
123170 public static Single Sum < TEnumerator > ( this IStructEnumerable < Single , TEnumerator > enumerable )
124171 where TEnumerator : struct , IEnumerator < Single >
125172 {
126173 using ( var enumerator = enumerable . GetStructEnumerator ( ) )
127174 {
128- Single result = 0 ;
129- while ( enumerator . MoveNext ( ) )
130- {
131- result += enumerator . Current ;
132- }
133- return result ;
175+ return SumSingle ( enumerator ) ;
134176 }
135177 }
136178 }
137179
138180
139181 public static partial class StructEnumerable
140182 {
183+ private static Double SumDouble < TEnumerator > ( TEnumerator enumerator )
184+ where TEnumerator : struct , IEnumerator < Double >
185+ {
186+ Double result = 0 ;
187+ while ( enumerator . MoveNext ( ) )
188+ {
189+ result += enumerator . Current ;
190+ }
191+ return result ;
192+ }
193+
141194 public static Double Sum < TEnumerator > ( this IStructEnumerable < Double , TEnumerator > enumerable )
142195 where TEnumerator : struct , IEnumerator < Double >
143196 {
144197 using ( var enumerator = enumerable . GetStructEnumerator ( ) )
145198 {
146- Double result = 0 ;
147- while ( enumerator . MoveNext ( ) )
148- {
149- result += enumerator . Current ;
150- }
151- return result ;
199+ return SumDouble ( enumerator ) ;
152200 }
153201 }
154202 }
155203
156204
157205 public static partial class StructEnumerable
158206 {
207+ private static Byte SumByte < TEnumerator > ( TEnumerator enumerator )
208+ where TEnumerator : struct , IEnumerator < Byte >
209+ {
210+ Byte result = 0 ;
211+ while ( enumerator . MoveNext ( ) )
212+ {
213+ result += enumerator . Current ;
214+ }
215+ return result ;
216+ }
217+
159218 public static Byte Sum < TEnumerator > ( this IStructEnumerable < Byte , TEnumerator > enumerable )
160219 where TEnumerator : struct , IEnumerator < Byte >
161220 {
162221 using ( var enumerator = enumerable . GetStructEnumerator ( ) )
163222 {
164- Byte result = 0 ;
165- while ( enumerator . MoveNext ( ) )
166- {
167- result += enumerator . Current ;
168- }
169- return result ;
223+ return SumByte ( enumerator ) ;
170224 }
171225 }
172226 }
173227
174228
175229 public static partial class StructEnumerable
176230 {
231+ private static SByte SumSByte < TEnumerator > ( TEnumerator enumerator )
232+ where TEnumerator : struct , IEnumerator < SByte >
233+ {
234+ SByte result = 0 ;
235+ while ( enumerator . MoveNext ( ) )
236+ {
237+ result += enumerator . Current ;
238+ }
239+ return result ;
240+ }
241+
177242 public static SByte Sum < TEnumerator > ( this IStructEnumerable < SByte , TEnumerator > enumerable )
178243 where TEnumerator : struct , IEnumerator < SByte >
179244 {
180245 using ( var enumerator = enumerable . GetStructEnumerator ( ) )
181246 {
182- SByte result = 0 ;
183- while ( enumerator . MoveNext ( ) )
184- {
185- result += enumerator . Current ;
186- }
187- return result ;
247+ return SumSByte ( enumerator ) ;
188248 }
189249 }
190250 }
0 commit comments