Skip to content

Commit ae68f5d

Browse files
committed
[Global] remove unnecessary methods
1 parent 6f99b73 commit ae68f5d

File tree

9 files changed

+272
-534
lines changed

9 files changed

+272
-534
lines changed

src/StructLinq/ForEach/ForEachStructEnumerable.cs

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,25 +7,16 @@ namespace StructLinq
77
{
88
public static partial class StructEnumerable
99
{
10-
#region private methods
11-
private static void ForEach<T, TEnumerator, TAction>(TEnumerator enumerator, ref TAction action)
12-
where TEnumerator : IEnumerator<T>
13-
where TAction : struct, IAction<T>
14-
15-
{
16-
while (enumerator.MoveNext())
17-
{
18-
action.Do(enumerator.Current);
19-
}
20-
}
21-
#endregion
2210
public static void ForEach<T, TEnumerator, TAction>(this ITypedEnumerable<T, TEnumerator> enumerable, ref TAction action)
2311
where TEnumerator : struct, IEnumerator<T>
2412
where TAction : struct, IAction<T>
2513
{
2614
using (var enumerator = enumerable.GetTypedEnumerator())
2715
{
28-
ForEach<T, TEnumerator, TAction>(enumerator, ref action);
16+
while (enumerator.MoveNext())
17+
{
18+
action.Do(enumerator.Current);
19+
}
2920
}
3021
}
3122
public static void ForEach<T, TEnumerator>(this ITypedEnumerable<T, TEnumerator> enumerable, Action<T> action)

src/StructLinq/Max/MaxStructEnumerable.cs

Lines changed: 80 additions & 170 deletions
Original file line numberDiff line numberDiff line change
@@ -10,289 +10,199 @@ namespace StructLinq
1010
{
1111
public static partial class StructEnumerable
1212
{
13-
#region private fields
14-
private static Int16 Int16Max<TEnumerator>(TEnumerator enumerator)
15-
where TEnumerator : struct, IEnumerator<Int16>
16-
{
17-
if (!enumerator.MoveNext())
18-
throw new ArgumentOutOfRangeException("No elements");
19-
Int16 result = enumerator.Current;
20-
while (enumerator.MoveNext())
21-
{
22-
var current = enumerator.Current;
23-
if (current > result)
24-
result = current;
25-
}
26-
return result;
27-
}
28-
#endregion
2913
public static Int16 Max<TEnumerator>(this ITypedEnumerable<Int16, TEnumerator> enumerable)
3014
where TEnumerator : struct, IEnumerator<Int16>
3115
{
3216
using (var enumerator = enumerable.GetTypedEnumerator())
3317
{
34-
return Int16Max(enumerator);
18+
Int16 result = enumerator.Current;
19+
while (enumerator.MoveNext())
20+
{
21+
var current = enumerator.Current;
22+
if (current > result)
23+
result = current;
24+
}
25+
return result;
3526
}
3627
}
3728
}
3829

3930

4031
public static partial class StructEnumerable
4132
{
42-
#region private fields
43-
private static Int32 Int32Max<TEnumerator>(TEnumerator enumerator)
44-
where TEnumerator : struct, IEnumerator<Int32>
45-
{
46-
if (!enumerator.MoveNext())
47-
throw new ArgumentOutOfRangeException("No elements");
48-
Int32 result = enumerator.Current;
49-
while (enumerator.MoveNext())
50-
{
51-
var current = enumerator.Current;
52-
if (current > result)
53-
result = current;
54-
}
55-
return result;
56-
}
57-
#endregion
5833
public static Int32 Max<TEnumerator>(this ITypedEnumerable<Int32, TEnumerator> enumerable)
5934
where TEnumerator : struct, IEnumerator<Int32>
6035
{
6136
using (var enumerator = enumerable.GetTypedEnumerator())
6237
{
63-
return Int32Max(enumerator);
38+
Int32 result = enumerator.Current;
39+
while (enumerator.MoveNext())
40+
{
41+
var current = enumerator.Current;
42+
if (current > result)
43+
result = current;
44+
}
45+
return result;
6446
}
6547
}
6648
}
6749

6850

6951
public static partial class StructEnumerable
7052
{
71-
#region private fields
72-
private static Int64 Int64Max<TEnumerator>(TEnumerator enumerator)
73-
where TEnumerator : struct, IEnumerator<Int64>
74-
{
75-
if (!enumerator.MoveNext())
76-
throw new ArgumentOutOfRangeException("No elements");
77-
Int64 result = enumerator.Current;
78-
while (enumerator.MoveNext())
79-
{
80-
var current = enumerator.Current;
81-
if (current > result)
82-
result = current;
83-
}
84-
return result;
85-
}
86-
#endregion
8753
public static Int64 Max<TEnumerator>(this ITypedEnumerable<Int64, TEnumerator> enumerable)
8854
where TEnumerator : struct, IEnumerator<Int64>
8955
{
9056
using (var enumerator = enumerable.GetTypedEnumerator())
9157
{
92-
return Int64Max(enumerator);
58+
Int64 result = enumerator.Current;
59+
while (enumerator.MoveNext())
60+
{
61+
var current = enumerator.Current;
62+
if (current > result)
63+
result = current;
64+
}
65+
return result;
9366
}
9467
}
9568
}
9669

9770

9871
public static partial class StructEnumerable
9972
{
100-
#region private fields
101-
private static UInt16 UInt16Max<TEnumerator>(TEnumerator enumerator)
102-
where TEnumerator : struct, IEnumerator<UInt16>
103-
{
104-
if (!enumerator.MoveNext())
105-
throw new ArgumentOutOfRangeException("No elements");
106-
UInt16 result = enumerator.Current;
107-
while (enumerator.MoveNext())
108-
{
109-
var current = enumerator.Current;
110-
if (current > result)
111-
result = current;
112-
}
113-
return result;
114-
}
115-
#endregion
11673
public static UInt16 Max<TEnumerator>(this ITypedEnumerable<UInt16, TEnumerator> enumerable)
11774
where TEnumerator : struct, IEnumerator<UInt16>
11875
{
11976
using (var enumerator = enumerable.GetTypedEnumerator())
12077
{
121-
return UInt16Max(enumerator);
78+
UInt16 result = enumerator.Current;
79+
while (enumerator.MoveNext())
80+
{
81+
var current = enumerator.Current;
82+
if (current > result)
83+
result = current;
84+
}
85+
return result;
12286
}
12387
}
12488
}
12589

12690

12791
public static partial class StructEnumerable
12892
{
129-
#region private fields
130-
private static UInt32 UInt32Max<TEnumerator>(TEnumerator enumerator)
131-
where TEnumerator : struct, IEnumerator<UInt32>
132-
{
133-
if (!enumerator.MoveNext())
134-
throw new ArgumentOutOfRangeException("No elements");
135-
UInt32 result = enumerator.Current;
136-
while (enumerator.MoveNext())
137-
{
138-
var current = enumerator.Current;
139-
if (current > result)
140-
result = current;
141-
}
142-
return result;
143-
}
144-
#endregion
14593
public static UInt32 Max<TEnumerator>(this ITypedEnumerable<UInt32, TEnumerator> enumerable)
14694
where TEnumerator : struct, IEnumerator<UInt32>
14795
{
14896
using (var enumerator = enumerable.GetTypedEnumerator())
14997
{
150-
return UInt32Max(enumerator);
98+
UInt32 result = enumerator.Current;
99+
while (enumerator.MoveNext())
100+
{
101+
var current = enumerator.Current;
102+
if (current > result)
103+
result = current;
104+
}
105+
return result;
151106
}
152107
}
153108
}
154109

155110

156111
public static partial class StructEnumerable
157112
{
158-
#region private fields
159-
private static UInt64 UInt64Max<TEnumerator>(TEnumerator enumerator)
160-
where TEnumerator : struct, IEnumerator<UInt64>
161-
{
162-
if (!enumerator.MoveNext())
163-
throw new ArgumentOutOfRangeException("No elements");
164-
UInt64 result = enumerator.Current;
165-
while (enumerator.MoveNext())
166-
{
167-
var current = enumerator.Current;
168-
if (current > result)
169-
result = current;
170-
}
171-
return result;
172-
}
173-
#endregion
174113
public static UInt64 Max<TEnumerator>(this ITypedEnumerable<UInt64, TEnumerator> enumerable)
175114
where TEnumerator : struct, IEnumerator<UInt64>
176115
{
177116
using (var enumerator = enumerable.GetTypedEnumerator())
178117
{
179-
return UInt64Max(enumerator);
118+
UInt64 result = enumerator.Current;
119+
while (enumerator.MoveNext())
120+
{
121+
var current = enumerator.Current;
122+
if (current > result)
123+
result = current;
124+
}
125+
return result;
180126
}
181127
}
182128
}
183129

184130

185131
public static partial class StructEnumerable
186132
{
187-
#region private fields
188-
private static Single SingleMax<TEnumerator>(TEnumerator enumerator)
189-
where TEnumerator : struct, IEnumerator<Single>
190-
{
191-
if (!enumerator.MoveNext())
192-
throw new ArgumentOutOfRangeException("No elements");
193-
Single result = enumerator.Current;
194-
while (enumerator.MoveNext())
195-
{
196-
var current = enumerator.Current;
197-
if (current > result)
198-
result = current;
199-
}
200-
return result;
201-
}
202-
#endregion
203133
public static Single Max<TEnumerator>(this ITypedEnumerable<Single, TEnumerator> enumerable)
204134
where TEnumerator : struct, IEnumerator<Single>
205135
{
206136
using (var enumerator = enumerable.GetTypedEnumerator())
207137
{
208-
return SingleMax(enumerator);
138+
Single result = enumerator.Current;
139+
while (enumerator.MoveNext())
140+
{
141+
var current = enumerator.Current;
142+
if (current > result)
143+
result = current;
144+
}
145+
return result;
209146
}
210147
}
211148
}
212149

213150

214151
public static partial class StructEnumerable
215152
{
216-
#region private fields
217-
private static Double DoubleMax<TEnumerator>(TEnumerator enumerator)
218-
where TEnumerator : struct, IEnumerator<Double>
219-
{
220-
if (!enumerator.MoveNext())
221-
throw new ArgumentOutOfRangeException("No elements");
222-
Double result = enumerator.Current;
223-
while (enumerator.MoveNext())
224-
{
225-
var current = enumerator.Current;
226-
if (current > result)
227-
result = current;
228-
}
229-
return result;
230-
}
231-
#endregion
232153
public static Double Max<TEnumerator>(this ITypedEnumerable<Double, TEnumerator> enumerable)
233154
where TEnumerator : struct, IEnumerator<Double>
234155
{
235156
using (var enumerator = enumerable.GetTypedEnumerator())
236157
{
237-
return DoubleMax(enumerator);
158+
Double result = enumerator.Current;
159+
while (enumerator.MoveNext())
160+
{
161+
var current = enumerator.Current;
162+
if (current > result)
163+
result = current;
164+
}
165+
return result;
238166
}
239167
}
240168
}
241169

242170

243171
public static partial class StructEnumerable
244172
{
245-
#region private fields
246-
private static Byte ByteMax<TEnumerator>(TEnumerator enumerator)
247-
where TEnumerator : struct, IEnumerator<Byte>
248-
{
249-
if (!enumerator.MoveNext())
250-
throw new ArgumentOutOfRangeException("No elements");
251-
Byte result = enumerator.Current;
252-
while (enumerator.MoveNext())
253-
{
254-
var current = enumerator.Current;
255-
if (current > result)
256-
result = current;
257-
}
258-
return result;
259-
}
260-
#endregion
261173
public static Byte Max<TEnumerator>(this ITypedEnumerable<Byte, TEnumerator> enumerable)
262174
where TEnumerator : struct, IEnumerator<Byte>
263175
{
264176
using (var enumerator = enumerable.GetTypedEnumerator())
265177
{
266-
return ByteMax(enumerator);
178+
Byte result = enumerator.Current;
179+
while (enumerator.MoveNext())
180+
{
181+
var current = enumerator.Current;
182+
if (current > result)
183+
result = current;
184+
}
185+
return result;
267186
}
268187
}
269188
}
270189

271190

272191
public static partial class StructEnumerable
273192
{
274-
#region private fields
275-
private static SByte SByteMax<TEnumerator>(TEnumerator enumerator)
276-
where TEnumerator : struct, IEnumerator<SByte>
277-
{
278-
if (!enumerator.MoveNext())
279-
throw new ArgumentOutOfRangeException("No elements");
280-
SByte result = enumerator.Current;
281-
while (enumerator.MoveNext())
282-
{
283-
var current = enumerator.Current;
284-
if (current > result)
285-
result = current;
286-
}
287-
return result;
288-
}
289-
#endregion
290193
public static SByte Max<TEnumerator>(this ITypedEnumerable<SByte, TEnumerator> enumerable)
291194
where TEnumerator : struct, IEnumerator<SByte>
292195
{
293196
using (var enumerator = enumerable.GetTypedEnumerator())
294197
{
295-
return SByteMax(enumerator);
198+
SByte result = enumerator.Current;
199+
while (enumerator.MoveNext())
200+
{
201+
var current = enumerator.Current;
202+
if (current > result)
203+
result = current;
204+
}
205+
return result;
296206
}
297207
}
298208
}

0 commit comments

Comments
 (0)