@@ -10,6 +10,8 @@ public static class UnorderedSources
10
10
{
11
11
public const int AdditionalTypeLimit = 1024 ;
12
12
13
+ // Get a set of ranges, of each count in `counts`.
14
+ // The start of each range is determined by passing the count into the `start` predicate.
13
15
private static IEnumerable < object [ ] > Ranges ( Func < int , int > start , IEnumerable < int > counts )
14
16
{
15
17
foreach ( int count in counts )
@@ -22,33 +24,80 @@ private static IEnumerable<object[]> Ranges(Func<int, int> start, IEnumerable<in
22
24
}
23
25
}
24
26
27
+ /// <summary>
28
+ /// Get a set of ranges, starting at `start`, and running for each count in `counts`.
29
+ /// </summary>
30
+ /// <param name="start">The starting element of the range.</param>
31
+ /// <param name="counts">The sizes of ranges to return.</param>
32
+ /// <returns>Entries for test data.
33
+ /// The first element is the Labeled{ParallelQuery{int}} range,
34
+ /// the second element is the count, and the third is the start.</returns>
25
35
public static IEnumerable < object [ ] > Ranges ( int start , IEnumerable < int > counts )
26
36
{
27
37
foreach ( object [ ] parms in Ranges ( x => start , counts ) ) yield return parms ;
28
38
}
29
39
30
- // Wrapper for attribute calls
40
+ /// <summary>
41
+ /// Get a set of ranges, starting at 0, and running for each count in `counts`.
42
+ /// </summary>
43
+ /// <remarks>This version is a wrapper for use from the MemberData attribute.</remarks>
44
+ /// <param name="counts">The sizes of ranges to return.</param>
45
+ /// <returns>Entries for test data.
46
+ /// The first element is the Labeled{ParallelQuery{int}} range,
47
+ /// and the second element is the count</returns>
31
48
public static IEnumerable < object [ ] > Ranges ( object [ ] counts )
32
49
{
33
50
foreach ( object [ ] parms in Ranges ( counts . Cast < int > ( ) ) ) yield return parms ;
34
51
}
35
52
53
+ /// <summary>
54
+ /// Get a set of ranges, starting at `start`, and running for each count in `counts`.
55
+ /// </summary>
56
+ /// <remarks>This version is a wrapper for use from the MemberData attribute.</remarks>
57
+ /// <param name="start">The starting element of the range.</param>
58
+ /// <param name="counts">The sizes of ranges to return.</param>
59
+ /// <returns>Entries for test data.
60
+ /// The first element is the Labeled{ParallelQuery{int}} range,
61
+ /// the second element is the count, and the third is the start.</returns>
36
62
public static IEnumerable < object [ ] > Ranges ( int start , object [ ] counts )
37
63
{
38
64
foreach ( object [ ] parms in Ranges ( start , counts . Cast < int > ( ) ) ) yield return parms ;
39
65
}
40
66
67
+ /// <summary>
68
+ /// Return pairs of ranges, both from 0 to each respective count in `counts`.
69
+ /// </summary>
70
+ /// <remarks>This version is a wrapper for use from the MemberData attribute.</remarks>
71
+ /// <param name="leftCounts">The sizes of left ranges to return.</param>
72
+ /// <param name="rightCounts">The sizes of right ranges to return.</param>
73
+ /// <returns>Entries for test data.
74
+ /// The first element is the left Labeled{ParallelQuery{int}} range, the second element is the left count,
75
+ /// the third element is the right Labeled{ParallelQuery{int}} range, and the fourth element is the right count, .</returns>
41
76
public static IEnumerable < object [ ] > BinaryRanges ( object [ ] leftCounts , object [ ] rightCounts )
42
77
{
43
78
foreach ( object [ ] parms in BinaryRanges ( leftCounts . Cast < int > ( ) , rightCounts . Cast < int > ( ) ) ) yield return parms ;
44
79
}
45
80
46
- // Simple labeled-range source - just return a set of ranges from 0 to each of the counts.
81
+ /// <summary>
82
+ /// Get a set of ranges, starting at 0, and running for each count in `counts`.
83
+ /// </summary>
84
+ /// <param name="counts">The sizes of ranges to return.</param>
85
+ /// <returns>Entries for test data.
86
+ /// The first element is the Labeled{ParallelQuery{int}} range,
87
+ /// and the second element is the count</returns>
47
88
public static IEnumerable < object [ ] > Ranges ( IEnumerable < int > counts )
48
89
{
49
90
foreach ( object [ ] parms in Ranges ( x => 0 , counts ) ) yield return parms . Take ( 2 ) . ToArray ( ) ;
50
91
}
51
92
93
+ /// <summary>
94
+ /// Return pairs of ranges, both from 0 to each respective count in `counts`.
95
+ /// </summary>
96
+ /// <param name="leftCounts">The sizes of left ranges to return.</param>
97
+ /// <param name="rightCounts">The sizes of right ranges to return.</param>
98
+ /// <returns>Entries for test data.
99
+ /// The first element is the left Labeled{ParallelQuery{int}} range, the second element is the left count,
100
+ /// the third element is the right Labeled{ParallelQuery{int}} range, and the fourth element is the right count.</returns>
52
101
public static IEnumerable < object [ ] > BinaryRanges ( IEnumerable < int > leftCounts , IEnumerable < int > rightCounts )
53
102
{
54
103
foreach ( object [ ] left in Ranges ( leftCounts ) )
@@ -60,6 +109,16 @@ public static IEnumerable<object[]> BinaryRanges(IEnumerable<int> leftCounts, IE
60
109
}
61
110
}
62
111
112
+ /// <summary>
113
+ /// Return pairs of ranges, for each respective count in `counts`.
114
+ /// </summary>
115
+ /// <param name="leftCounts">The sizes of left ranges to return.</param>
116
+ /// <param name="rightStart">A predicate to determine the start of the right range, by passing the left and right range size.</param>
117
+ /// <param name="rightCounts">The sizes of right ranges to return.</param>
118
+ /// <returns>Entries for test data.
119
+ /// The first element is the left Labeled{ParallelQuery{int}} range, the second element is the left count,
120
+ /// the third element is the right Labeled{ParallelQuery{int}} range, the fourth element is the right count,
121
+ /// and the fifth is the right start..</returns>
63
122
public static IEnumerable < object [ ] > BinaryRanges ( IEnumerable < int > leftCounts , Func < int , int , int > rightStart , IEnumerable < int > rightCounts )
64
123
{
65
124
foreach ( object [ ] left in Ranges ( leftCounts ) )
@@ -71,8 +130,17 @@ public static IEnumerable<object[]> BinaryRanges(IEnumerable<int> leftCounts, Fu
71
130
}
72
131
}
73
132
74
- // Allows for a set of output modifiers to be passed.
75
- // This is useful for things like showing an average (via the use of `x => (double)SumRange(0, x) / x`)
133
+ /// <summary>
134
+ /// Get a set of ranges, starting at 0, and running for each count in `counts`.
135
+ /// </summary>
136
+ /// <remarks>
137
+ /// This is useful for things like showing an average (via the use of `x => (double)SumRange(0, x) / x`)
138
+ /// </remarks>
139
+ /// <param name="counts">The sizes of ranges to return.</param>
140
+ /// <param name="modifiers">A set of modifiers to return as additional parameters.</param>
141
+ /// <returns>Entries for test data.
142
+ /// The first element is the Labeled{ParallelQuery{int}} range,
143
+ /// the second element is the count, and one additional element for each modifier.</returns>
76
144
public static IEnumerable < object [ ] > Ranges < T > ( IEnumerable < int > counts , params Func < int , T > [ ] modifiers )
77
145
{
78
146
if ( modifiers == null || ! modifiers . Any ( ) )
@@ -89,10 +157,19 @@ public static IEnumerable<object[]> Ranges<T>(IEnumerable<int> counts, params Fu
89
157
}
90
158
}
91
159
92
- // For each count, each modifier has multiple outputs.
93
- // This is useful for things like dealing with `Max(predicate)`,
94
- // allowing multiple predicate values for the same source count to be tested.
95
- // The number of variations is equal to the longest inner enumeration (all others will cycle).
160
+ /// <summary>
161
+ /// Get a set of ranges, starting at 0, and running for each count in `counts`.
162
+ /// </summary>
163
+ /// <remarks>
164
+ /// This is useful for things like dealing with `Max(predicate)`,
165
+ /// allowing multiple predicate values for the same source count to be tested.
166
+ /// The number of variations is equal to the longest modifier enumeration (all others will cycle).
167
+ /// </remarks>
168
+ /// <param name="counts">The sizes of ranges to return.</param>
169
+ /// <param name="modifiers">A set of modifiers to return as additional parameters.</param>
170
+ /// <returns>Entries for test data.
171
+ /// The first element is the Labeled{ParallelQuery{int}} range,
172
+ /// the second element is the count, and one additional element for each modifier.</returns>
96
173
public static IEnumerable < object [ ] > Ranges < T > ( IEnumerable < int > counts , params Func < int , IEnumerable < T > > [ ] modifiers )
97
174
{
98
175
if ( modifiers == null || ! modifiers . Any ( ) )
@@ -119,11 +196,11 @@ private static IEnumerable<Labeled<ParallelQuery<int>>> LabeledRanges(int start,
119
196
yield return Labeled . Label ( "Enumerable.Range" , Enumerable . Range ( start , count ) . AsParallel ( ) ) ;
120
197
int [ ] rangeArray = GetRangeArray ( start , count ) ;
121
198
yield return Labeled . Label ( "Array" , rangeArray . AsParallel ( ) ) ;
199
+ IList < int > rangeList = rangeArray . ToList ( ) ;
200
+ yield return Labeled . Label ( "List" , rangeList . AsParallel ( ) ) ;
122
201
if ( count < AdditionalTypeLimit + 1 )
123
202
{
124
203
yield return Labeled . Label ( "Partitioner" , Partitioner . Create ( rangeArray ) . AsParallel ( ) ) ;
125
- IList < int > rangeList = rangeArray . ToList ( ) ;
126
- yield return Labeled . Label ( "List" , rangeList . AsParallel ( ) ) ;
127
204
yield return Labeled . Label ( "ReadOnlyCollection" , new ReadOnlyCollection < int > ( rangeList ) . AsParallel ( ) ) ;
128
205
}
129
206
}
0 commit comments