/
OrderedParallelQuery.cs
51 lines (44 loc) · 1.51 KB
/
OrderedParallelQuery.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// =+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
//
// OrderedParallelQuery.cs
//
// =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
using System;
using System.Collections.Generic;
using System.Text;
using System.Linq.Parallel;
using System.Diagnostics;
namespace System.Linq
{
/// <summary>
/// Represents a sorted, parallel sequence.
/// </summary>
public class OrderedParallelQuery<TSource> : ParallelQuery<TSource>
{
private readonly QueryOperator<TSource> _sortOp;
internal OrderedParallelQuery(QueryOperator<TSource> sortOp)
: base(sortOp.SpecifiedQuerySettings)
{
_sortOp = sortOp;
Debug.Assert(sortOp is IOrderedEnumerable<TSource>);
}
internal QueryOperator<TSource> SortOperator
{
get { return _sortOp; }
}
internal IOrderedEnumerable<TSource> OrderedEnumerable
{
get { return (IOrderedEnumerable<TSource>)_sortOp; }
}
/// <summary>
/// Returns an enumerator that iterates through the sequence.
/// </summary>
/// <returns>An enumerator that iterates through the sequence.</returns>
public override IEnumerator<TSource> GetEnumerator()
{
return _sortOp.GetEnumerator();
}
}
}