本文整理汇总了C#中IntegerRangeSet类的典型用法代码示例。如果您正苦于以下问题:C# IntegerRangeSet类的具体用法?C# IntegerRangeSet怎么用?C# IntegerRangeSet使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IntegerRangeSet类属于命名空间,在下文中一共展示了IntegerRangeSet类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Reverse_Unordered_NotPipelined
public static void Reverse_Unordered_NotPipelined(Labeled<ParallelQuery<int>> labeled, int count)
{
ParallelQuery<int> query = labeled.Item;
IntegerRangeSet seen = new IntegerRangeSet(0, count);
Assert.All(query.Reverse().ToList(), x => seen.Add(x));
seen.AssertComplete();
}
示例2: ToDictionary
public static void ToDictionary(int count)
{
IntegerRangeSet seen = new IntegerRangeSet(0, count);
Assert.All(UnorderedSources.Default(count).ToDictionary(x => x * 2),
p => { seen.Add(p.Key / 2); Assert.Equal(p.Key, p.Value * 2); });
seen.AssertComplete();
}
示例3: ToDictionary_ElementSelector_CustomComparator
public static void ToDictionary_ElementSelector_CustomComparator(int count)
{
IntegerRangeSet seen = new IntegerRangeSet(0, count);
Assert.All(UnorderedSources.Default(count).ToDictionary(x => x, y => y * 2, new ModularCongruenceComparer(count)),
p => { seen.Add(p.Key); Assert.Equal(p.Key * 2, p.Value); });
seen.AssertComplete();
}
示例4: Cast_Unordered_Valid_NotPipelined
public static void Cast_Unordered_Valid_NotPipelined(Labeled<ParallelQuery<int>> labeled, int count)
{
ParallelQuery<int> query = labeled.Item;
IntegerRangeSet seen = new IntegerRangeSet(0, count);
Assert.All(query.Select(x => (object)x).Cast<int>().ToList(), x => seen.Add(x));
seen.AssertComplete();
}
示例5: GetEnumerator_Unordered
public static void GetEnumerator_Unordered(Labeled<ParallelQuery<int>> labeled, int count)
{
IntegerRangeSet seen = new IntegerRangeSet(0, count);
IEnumerator<int> enumerator = labeled.Item.GetEnumerator();
if (count == 0 && labeled.ToString().Contains("Array"))
{
Assert.Same(enumerator, labeled.Item.GetEnumerator());
}
else
{
Assert.NotSame(enumerator, labeled.Item.GetEnumerator());
}
while (enumerator.MoveNext())
{
int current = enumerator.Current;
seen.Add(current);
Assert.Equal(current, enumerator.Current);
}
seen.AssertComplete();
if (labeled.ToString().StartsWith("Enumerable.Range") || labeled.ToString().StartsWith("Partitioner"))
{
Assert.Throws<NotSupportedException>(() => enumerator.Reset());
}
else
{
enumerator.Reset();
seen = new IntegerRangeSet(0, count);
while (enumerator.MoveNext())
{
Assert.True(seen.Add(enumerator.Current));
}
seen.AssertComplete();
}
}
示例6: Distinct_Unordered_NotPipelined
public static void Distinct_Unordered_NotPipelined(LabeledOperation source, LabeledOperation operation)
{
IntegerRangeSet seen = new IntegerRangeSet(DefaultStart, DefaultSize);
ParallelQuery<int> query = operation.Item(DefaultStart * 2, DefaultSize * 2, source.Item).Select(x => x / 2).Distinct();
Assert.All(query.ToList(), x => seen.Add((int)x));
seen.AssertComplete();
}
示例7: Single_NoMatch
public static void Single_NoMatch(Labeled<ParallelQuery<int>> labeled, int count, int element)
{
ParallelQuery<int> query = labeled.Item;
IntegerRangeSet seen = new IntegerRangeSet(0, count);
Assert.Throws<InvalidOperationException>(() => query.Single(x => !seen.Add(x)));
seen.AssertComplete();
}
示例8: ForAll
public static void ForAll(Labeled<ParallelQuery<int>> labeled, int count)
{
ParallelQuery<int> query = labeled.Item;
IntegerRangeSet seen = new IntegerRangeSet(0, count);
query.ForAll<int>(x => seen.Add(x));
seen.AssertComplete();
}
示例9: ToArray_Unordered
public static void ToArray_Unordered(Labeled<ParallelQuery<int>> labeled, int count)
{
ParallelQuery<int> query = labeled.Item;
IntegerRangeSet seen = new IntegerRangeSet(0, count);
Assert.All(query.ToArray(), x => seen.Add(x));
seen.AssertComplete();
}
示例10: Where_Unordered_NotPipelined
public static void Where_Unordered_NotPipelined(Labeled<ParallelQuery<int>> labeled, int count)
{
ParallelQuery<int> query = labeled.Item;
IntegerRangeSet seen = new IntegerRangeSet(0, (count + 1) / 2);
Assert.All(query.Where(x => x % 2 == 0).ToList(), x => seen.Add(x / 2));
seen.AssertComplete();
}
示例11: Select_Unordered_NotPipelined
public static void Select_Unordered_NotPipelined(int count)
{
IntegerRangeSet seen = new IntegerRangeSet(0, count);
Assert.All(UnorderedSources.Default(count).Select(x => KeyValuePair.Create(x, x * x)).ToList(),
p => { seen.Add(p.Key); Assert.Equal(p.Key * p.Key, p.Value); });
seen.AssertComplete();
}
示例12: AsSequential_Unordered
public static void AsSequential_Unordered(Labeled<ParallelQuery<int>> labeled, int count)
{
IntegerRangeSet seen = new IntegerRangeSet(0, count);
IEnumerable<int> seq = labeled.Item.AsSequential();
Assert.All(seq, x => seen.Add(x));
seen.AssertComplete();
}
示例13: Any_AllFalse
public static void Any_AllFalse(Labeled<ParallelQuery<int>> labeled, int count)
{
ParallelQuery<int> query = labeled.Item;
IntegerRangeSet seen = new IntegerRangeSet(0, count);
Assert.False(query.Any(x => !seen.Add(x)));
seen.AssertComplete();
}
示例14: ToDictionary
public static void ToDictionary(Labeled<ParallelQuery<int>> labeled, int count)
{
ParallelQuery<int> query = labeled.Item;
IntegerRangeSet seen = new IntegerRangeSet(0, count);
Assert.All(query.ToDictionary(x => x * 2),
p => { seen.Add(p.Key / 2); Assert.Equal(p.Key, p.Value * 2); });
seen.AssertComplete();
}
示例15: Skip_Unordered_NotPipelined
public static void Skip_Unordered_NotPipelined(int count, int skip)
{
// For unordered collections, which elements are skipped isn't actually guaranteed, but an effect of the implementation.
// If this test starts failing it should be updated, and possibly mentioned in release notes.
IntegerRangeSet seen = new IntegerRangeSet(Math.Max(skip, 0), Math.Min(count, Math.Max(0, count - skip)));
Assert.All(UnorderedSources.Default(count).Skip(skip).ToList(), x => seen.Add(x));
seen.AssertComplete();
}