You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
66 lines
1.9 KiB
66 lines
1.9 KiB
5 years ago
|
#if FAT
|
||
|
|
||
|
using System;
|
||
|
using System.Collections.Generic;
|
||
|
|
||
|
using LinqInternal.Core;
|
||
|
|
||
|
namespace LinqInternal.Collections
|
||
|
{
|
||
|
[System.Diagnostics.DebuggerNonUserCode]
|
||
|
internal class ConversionSet<TInput, TOutput> : ProgressiveSet<TOutput>
|
||
|
{
|
||
|
public ConversionSet(IEnumerable<TInput> wrapped, Func<TInput, TOutput> converter)
|
||
|
: base(BuildEnumerable(wrapped, converter))
|
||
|
{
|
||
|
//Empty
|
||
|
}
|
||
|
|
||
|
public ConversionSet(IEnumerable<TInput> wrapped, Func<TInput, TOutput> converter, Predicate<TInput> filter)
|
||
|
: base(BuildEnumerable(wrapped, converter, filter))
|
||
|
{
|
||
|
//Empty
|
||
|
}
|
||
|
|
||
|
private static IEnumerable<TOutput> BuildEnumerable(IEnumerable<TInput> wrapped, Func<TInput, TOutput> converter)
|
||
|
{
|
||
|
if (wrapped == null)
|
||
|
{
|
||
|
throw new ArgumentNullException("wrapped");
|
||
|
}
|
||
|
if (converter == null)
|
||
|
{
|
||
|
throw new ArgumentNullException("converter");
|
||
|
}
|
||
|
foreach (var item in wrapped)
|
||
|
{
|
||
|
yield return converter(item);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
private static IEnumerable<TOutput> BuildEnumerable(IEnumerable<TInput> wrapped, Func<TInput, TOutput> converter, Predicate<TInput> filter)
|
||
|
{
|
||
|
if (wrapped == null)
|
||
|
{
|
||
|
throw new ArgumentNullException("wrapped");
|
||
|
}
|
||
|
if (converter == null)
|
||
|
{
|
||
|
throw new ArgumentNullException("converter");
|
||
|
}
|
||
|
if (filter == null)
|
||
|
{
|
||
|
throw new ArgumentNullException("filter");
|
||
|
}
|
||
|
foreach (var item in wrapped)
|
||
|
{
|
||
|
if (filter(item))
|
||
|
{
|
||
|
yield return converter(item);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
#endif
|