Skip to content

Commit fe7b4b9

Browse files
committed
Fix order of methods in CompositeRangeExtensions.cs
1 parent 8dc496f commit fe7b4b9

1 file changed

Lines changed: 107 additions & 109 deletions

File tree

CodeJam.Main/Ranges/[RangeExtensions]/CompositeRangeExtensions.cs

Lines changed: 107 additions & 109 deletions
Original file line numberDiff line numberDiff line change
@@ -45,116 +45,7 @@ public static CompositeRange<T, TKey> ToCompositeRange<TSource, T, TKey>(
4545
source
4646
.Select(s => Range.Create(fromValueSelector(s), toValueSelector(s), keySelector(s)))
4747
.ToCompositeRange();
48-
#endregion
49-
50-
#region ToCompositeRangeExclusive
51-
/// <summary>Converts sequence of elements to the composite range.</summary>
52-
/// <typeparam name="T">The type of the range values.</typeparam>
53-
/// <typeparam name="TKey">The type of the range key</typeparam>
54-
/// <param name="source">Original collection.</param>
55-
/// <param name="fromValueSelector">Callback to obtain a value for the From boundary.</param>
56-
/// <param name="toValueSelector">Callback to obtain a value for the To boundary.</param>
57-
/// <returns>A new composite range with keys filled from the original collection.</returns>
58-
[Pure]
59-
public static CompositeRange<T, TKey> ToCompositeRangeExclusive<T, TKey>(
60-
[NotNull] this IEnumerable<TKey> source,
61-
[NotNull, InstantHandle] Func<TKey, T> fromValueSelector,
62-
[NotNull, InstantHandle] Func<TKey, T> toValueSelector) =>
63-
source
64-
.Select(s => Range.CreateExclusive(fromValueSelector(s), toValueSelector(s), s))
65-
.ToCompositeRange();
66-
67-
/// <summary>Converts sequence of elements to the composite range.</summary>
68-
/// <typeparam name="TSource">The type of the values in original collection.</typeparam>
69-
/// <typeparam name="T">The type of the range values.</typeparam>
70-
/// <typeparam name="TKey">The type of the range key</typeparam>
71-
/// <param name="source">Original collection.</param>
72-
/// <param name="fromValueSelector">Callback to obtain a value for the From boundary.</param>
73-
/// <param name="toValueSelector">Callback to obtain a value for the To boundary.</param>
74-
/// <param name="keySelector">Callback to obtain a value for the range key.</param>
75-
/// <returns>A new composite range with keys filled from the original collection.</returns>
76-
[Pure]
77-
public static CompositeRange<T, TKey> ToCompositeRangeExclusive<TSource, T, TKey>(
78-
[NotNull] this IEnumerable<TSource> source,
79-
[NotNull, InstantHandle] Func<TSource, T> fromValueSelector,
80-
[NotNull, InstantHandle] Func<TSource, T> toValueSelector,
81-
[NotNull, InstantHandle] Func<TSource, TKey> keySelector) =>
82-
source
83-
.Select(s => Range.CreateExclusive(fromValueSelector(s), toValueSelector(s), keySelector(s)))
84-
.ToCompositeRange();
85-
86-
/// <summary>Converts sequence of elements to the composite range.</summary>
87-
/// <typeparam name="T">The type of the range values.</typeparam>
88-
/// <typeparam name="TKey">The type of the range key</typeparam>
89-
/// <param name="source">Original collection.</param>
90-
/// <param name="fromValueSelector">Callback to obtain a value for the From boundary.</param>
91-
/// <param name="toValueSelector">Callback to obtain a value for the To boundary.</param>
92-
/// <returns>A new composite range with keys filled from the original collection.</returns>
93-
[Pure]
94-
public static CompositeRange<T, TKey> ToCompositeRangeExclusiveFrom<T, TKey>(
95-
[NotNull] this IEnumerable<TKey> source,
96-
[NotNull, InstantHandle] Func<TKey, T> fromValueSelector,
97-
[NotNull, InstantHandle] Func<TKey, T> toValueSelector) =>
98-
source
99-
.Select(s => Range.CreateExclusiveFrom(fromValueSelector(s), toValueSelector(s), s))
100-
.ToCompositeRange();
101-
102-
/// <summary>Converts sequence of elements to the composite range.</summary>
103-
/// <typeparam name="TSource">The type of the values in original collection.</typeparam>
104-
/// <typeparam name="T">The type of the range values.</typeparam>
105-
/// <typeparam name="TKey">The type of the range key</typeparam>
106-
/// <param name="source">Original collection.</param>
107-
/// <param name="fromValueSelector">Callback to obtain a value for the From boundary.</param>
108-
/// <param name="toValueSelector">Callback to obtain a value for the To boundary.</param>
109-
/// <param name="keySelector">Callback to obtain a value for the range key.</param>
110-
/// <returns>A new composite range with keys filled from the original collection.</returns>
111-
[Pure]
112-
public static CompositeRange<T, TKey> ToCompositeRangeExclusiveFrom<TSource, T, TKey>(
113-
[NotNull] this IEnumerable<TSource> source,
114-
[NotNull, InstantHandle] Func<TSource, T> fromValueSelector,
115-
[NotNull, InstantHandle] Func<TSource, T> toValueSelector,
116-
[NotNull, InstantHandle] Func<TSource, TKey> keySelector) =>
117-
source
118-
.Select(s => Range.CreateExclusiveFrom(fromValueSelector(s), toValueSelector(s), keySelector(s)))
119-
.ToCompositeRange();
120-
121-
/// <summary>Converts sequence of elements to the composite range.</summary>
122-
/// <typeparam name="T">The type of the range values.</typeparam>
123-
/// <typeparam name="TKey">The type of the range key</typeparam>
124-
/// <param name="source">Original collection.</param>
125-
/// <param name="fromValueSelector">Callback to obtain a value for the From boundary.</param>
126-
/// <param name="toValueSelector">Callback to obtain a value for the To boundary.</param>
127-
/// <returns>A new composite range with keys filled from the original collection.</returns>
128-
[Pure]
129-
public static CompositeRange<T, TKey> ToCompositeRangeExclusiveTo<T, TKey>(
130-
[NotNull] this IEnumerable<TKey> source,
131-
[NotNull, InstantHandle] Func<TKey, T> fromValueSelector,
132-
[NotNull, InstantHandle] Func<TKey, T> toValueSelector) =>
133-
source
134-
.Select(s => Range.CreateExclusiveTo(fromValueSelector(s), toValueSelector(s), s))
135-
.ToCompositeRange();
136-
137-
/// <summary>Converts sequence of elements to the composite range.</summary>
138-
/// <typeparam name="TSource">The type of the values in original collection.</typeparam>
139-
/// <typeparam name="T">The type of the range values.</typeparam>
140-
/// <typeparam name="TKey">The type of the range key</typeparam>
141-
/// <param name="source">Original collection.</param>
142-
/// <param name="fromValueSelector">Callback to obtain a value for the From boundary.</param>
143-
/// <param name="toValueSelector">Callback to obtain a value for the To boundary.</param>
144-
/// <param name="keySelector">Callback to obtain a value for the range key.</param>
145-
/// <returns>A new composite range with keys filled from the original collection.</returns>
146-
[Pure]
147-
public static CompositeRange<T, TKey> ToCompositeRangeExclusiveTo<TSource, T, TKey>(
148-
[NotNull] this IEnumerable<TSource> source,
149-
[NotNull, InstantHandle] Func<TSource, T> fromValueSelector,
150-
[NotNull, InstantHandle] Func<TSource, T> toValueSelector,
151-
[NotNull, InstantHandle] Func<TSource, TKey> keySelector) =>
152-
source
153-
.Select(s => Range.CreateExclusiveTo(fromValueSelector(s), toValueSelector(s), keySelector(s)))
154-
.ToCompositeRange();
155-
#endregion
15648

157-
#region ToCompositeRangeFrom & ToCompositeRangeTo
15849
/// <summary>
15950
/// Converts sequence of elements to the composite range using only From boundary.
16051
/// The To boundary value is taken from the next item in sequence (+∞ for the last item in sequence)
@@ -284,6 +175,113 @@ public static CompositeRange<T, TKey> ToCompositeRangeTo<TSource, T, TKey>(
284175
}
285176
#endregion
286177

178+
#region ToCompositeRangeExclusive
179+
/// <summary>Converts sequence of elements to the composite range.</summary>
180+
/// <typeparam name="T">The type of the range values.</typeparam>
181+
/// <typeparam name="TKey">The type of the range key</typeparam>
182+
/// <param name="source">Original collection.</param>
183+
/// <param name="fromValueSelector">Callback to obtain a value for the From boundary.</param>
184+
/// <param name="toValueSelector">Callback to obtain a value for the To boundary.</param>
185+
/// <returns>A new composite range with keys filled from the original collection.</returns>
186+
[Pure]
187+
public static CompositeRange<T, TKey> ToCompositeRangeExclusive<T, TKey>(
188+
[NotNull] this IEnumerable<TKey> source,
189+
[NotNull, InstantHandle] Func<TKey, T> fromValueSelector,
190+
[NotNull, InstantHandle] Func<TKey, T> toValueSelector) =>
191+
source
192+
.Select(s => Range.CreateExclusive(fromValueSelector(s), toValueSelector(s), s))
193+
.ToCompositeRange();
194+
195+
/// <summary>Converts sequence of elements to the composite range.</summary>
196+
/// <typeparam name="TSource">The type of the values in original collection.</typeparam>
197+
/// <typeparam name="T">The type of the range values.</typeparam>
198+
/// <typeparam name="TKey">The type of the range key</typeparam>
199+
/// <param name="source">Original collection.</param>
200+
/// <param name="fromValueSelector">Callback to obtain a value for the From boundary.</param>
201+
/// <param name="toValueSelector">Callback to obtain a value for the To boundary.</param>
202+
/// <param name="keySelector">Callback to obtain a value for the range key.</param>
203+
/// <returns>A new composite range with keys filled from the original collection.</returns>
204+
[Pure]
205+
public static CompositeRange<T, TKey> ToCompositeRangeExclusive<TSource, T, TKey>(
206+
[NotNull] this IEnumerable<TSource> source,
207+
[NotNull, InstantHandle] Func<TSource, T> fromValueSelector,
208+
[NotNull, InstantHandle] Func<TSource, T> toValueSelector,
209+
[NotNull, InstantHandle] Func<TSource, TKey> keySelector) =>
210+
source
211+
.Select(s => Range.CreateExclusive(fromValueSelector(s), toValueSelector(s), keySelector(s)))
212+
.ToCompositeRange();
213+
214+
/// <summary>Converts sequence of elements to the composite range.</summary>
215+
/// <typeparam name="T">The type of the range values.</typeparam>
216+
/// <typeparam name="TKey">The type of the range key</typeparam>
217+
/// <param name="source">Original collection.</param>
218+
/// <param name="fromValueSelector">Callback to obtain a value for the From boundary.</param>
219+
/// <param name="toValueSelector">Callback to obtain a value for the To boundary.</param>
220+
/// <returns>A new composite range with keys filled from the original collection.</returns>
221+
[Pure]
222+
public static CompositeRange<T, TKey> ToCompositeRangeExclusiveFrom<T, TKey>(
223+
[NotNull] this IEnumerable<TKey> source,
224+
[NotNull, InstantHandle] Func<TKey, T> fromValueSelector,
225+
[NotNull, InstantHandle] Func<TKey, T> toValueSelector) =>
226+
source
227+
.Select(s => Range.CreateExclusiveFrom(fromValueSelector(s), toValueSelector(s), s))
228+
.ToCompositeRange();
229+
230+
/// <summary>Converts sequence of elements to the composite range.</summary>
231+
/// <typeparam name="TSource">The type of the values in original collection.</typeparam>
232+
/// <typeparam name="T">The type of the range values.</typeparam>
233+
/// <typeparam name="TKey">The type of the range key</typeparam>
234+
/// <param name="source">Original collection.</param>
235+
/// <param name="fromValueSelector">Callback to obtain a value for the From boundary.</param>
236+
/// <param name="toValueSelector">Callback to obtain a value for the To boundary.</param>
237+
/// <param name="keySelector">Callback to obtain a value for the range key.</param>
238+
/// <returns>A new composite range with keys filled from the original collection.</returns>
239+
[Pure]
240+
public static CompositeRange<T, TKey> ToCompositeRangeExclusiveFrom<TSource, T, TKey>(
241+
[NotNull] this IEnumerable<TSource> source,
242+
[NotNull, InstantHandle] Func<TSource, T> fromValueSelector,
243+
[NotNull, InstantHandle] Func<TSource, T> toValueSelector,
244+
[NotNull, InstantHandle] Func<TSource, TKey> keySelector) =>
245+
source
246+
.Select(s => Range.CreateExclusiveFrom(fromValueSelector(s), toValueSelector(s), keySelector(s)))
247+
.ToCompositeRange();
248+
249+
/// <summary>Converts sequence of elements to the composite range.</summary>
250+
/// <typeparam name="T">The type of the range values.</typeparam>
251+
/// <typeparam name="TKey">The type of the range key</typeparam>
252+
/// <param name="source">Original collection.</param>
253+
/// <param name="fromValueSelector">Callback to obtain a value for the From boundary.</param>
254+
/// <param name="toValueSelector">Callback to obtain a value for the To boundary.</param>
255+
/// <returns>A new composite range with keys filled from the original collection.</returns>
256+
[Pure]
257+
public static CompositeRange<T, TKey> ToCompositeRangeExclusiveTo<T, TKey>(
258+
[NotNull] this IEnumerable<TKey> source,
259+
[NotNull, InstantHandle] Func<TKey, T> fromValueSelector,
260+
[NotNull, InstantHandle] Func<TKey, T> toValueSelector) =>
261+
source
262+
.Select(s => Range.CreateExclusiveTo(fromValueSelector(s), toValueSelector(s), s))
263+
.ToCompositeRange();
264+
265+
/// <summary>Converts sequence of elements to the composite range.</summary>
266+
/// <typeparam name="TSource">The type of the values in original collection.</typeparam>
267+
/// <typeparam name="T">The type of the range values.</typeparam>
268+
/// <typeparam name="TKey">The type of the range key</typeparam>
269+
/// <param name="source">Original collection.</param>
270+
/// <param name="fromValueSelector">Callback to obtain a value for the From boundary.</param>
271+
/// <param name="toValueSelector">Callback to obtain a value for the To boundary.</param>
272+
/// <param name="keySelector">Callback to obtain a value for the range key.</param>
273+
/// <returns>A new composite range with keys filled from the original collection.</returns>
274+
[Pure]
275+
public static CompositeRange<T, TKey> ToCompositeRangeExclusiveTo<TSource, T, TKey>(
276+
[NotNull] this IEnumerable<TSource> source,
277+
[NotNull, InstantHandle] Func<TSource, T> fromValueSelector,
278+
[NotNull, InstantHandle] Func<TSource, T> toValueSelector,
279+
[NotNull, InstantHandle] Func<TSource, TKey> keySelector) =>
280+
source
281+
.Select(s => Range.CreateExclusiveTo(fromValueSelector(s), toValueSelector(s), keySelector(s)))
282+
.ToCompositeRange();
283+
#endregion
284+
287285
#region GetComplementation
288286
/// <summary>
289287
/// Returns complementation composite range.

0 commit comments

Comments
 (0)