Here are the examples of the csharp api System.Predicate.Invoke(TOut) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
11 Examples
19
Source : SecondaryWhereDelegateProducer.cs
with MIT License
from VictorNicollet
with MIT License
from VictorNicollet
public void Produce(ref ReadOnlySpan<TIn> input, ref Span<TOut> output)
{
var copied = 0;
while (copied < output.Length)
{
// Use the part of the span where there are no values yet
// to extract as many values from the inner predicate as
// possible.
var outSpan = output.Slice(copied);
_inner.Produce(ref input, ref outSpan);
for (var i = 0; i < outSpan.Length; ++i)
if (_predicate(outSpan[i]))
output[copied++] = outSpan[i];
if (outSpan.Length < output.Length)
break;
}
output = output.Slice(0, copied);
}
19
Source : SecondaryWhereDelegateProducer.cs
with MIT License
from VictorNicollet
with MIT License
from VictorNicollet
public void Produce(ref Span<TOut> output)
{
var copied = 0;
while (copied < output.Length)
{
// Use the part of the span where there are no values yet
// to extract as many values from the inner predicate as
// possible.
var outSpan = output.Slice(copied);
_inner.Produce(ref outSpan);
for (var i = 0; i < outSpan.Length; ++i)
if (_predicate(outSpan[i]))
output[copied++] = outSpan[i];
if (outSpan.Length < output.Length - copied)
break;
}
output = output.Slice(0, copied);
}
19
Source : AllExtensions.cs
with MIT License
from VictorNicollet
with MIT License
from VictorNicollet
public static bool All<TIn, TOut, TProducer>(
this SpanEnumerable<TIn, TOut, TProducer> spanEnum,
Predicate<TOut> predicate)
where TProducer : struct, IProducer<TIn, TOut>
{
if (predicate == null)
throw new ArgumentNullException(nameof(predicate));
TOut onStack = default;
var spanOnStack = MemoryMarshal.CreateSpan(ref onStack, 1);
while (spanEnum.ConsumeInto(spanOnStack).Length > 0)
if (!predicate(onStack))
return false;
return true;
}
19
Source : AllExtensions.cs
with MIT License
from VictorNicollet
with MIT License
from VictorNicollet
public static bool All<TOut, TProducer>(
this SpanEnumerable<TOut, TProducer> spanEnum,
Predicate<TOut> predicate)
where TProducer : struct, IProducer<TOut>
{
if (predicate == null)
throw new ArgumentNullException(nameof(predicate));
TOut onStack = default;
var spanOnStack = MemoryMarshal.CreateSpan(ref onStack, 1);
while (spanEnum.ConsumeInto(spanOnStack).Length > 0)
if (!predicate(onStack))
return false;
return true;
}
19
Source : AllExtensions.cs
with MIT License
from VictorNicollet
with MIT License
from VictorNicollet
public static bool All<TOut>(
this SpanEnumerable<TOut> spanEnum,
Predicate<TOut> predicate)
{
if (predicate == null)
throw new ArgumentNullException(nameof(predicate));
TOut onStack = default;
var spanOnStack = MemoryMarshal.CreateSpan(ref onStack, 1);
while (spanEnum.ConsumeInto(spanOnStack).Length > 0)
if (!predicate(onStack))
return false;
return true;
}
19
Source : AnyExtensions.cs
with MIT License
from VictorNicollet
with MIT License
from VictorNicollet
public static bool Any<TIn, TOut, TProducer>(
this SpanEnumerable<TIn, TOut, TProducer> spanEnum,
Predicate<TOut> predicate)
where TProducer : struct, IProducer<TIn, TOut>
{
if (predicate == null)
throw new ArgumentNullException(nameof(predicate));
TOut onStack = default;
var spanOnStack = MemoryMarshal.CreateSpan(ref onStack, 1);
while (spanEnum.ConsumeInto(spanOnStack).Length > 0)
if (predicate(onStack))
return true;
return false;
}
19
Source : AnyExtensions.cs
with MIT License
from VictorNicollet
with MIT License
from VictorNicollet
public static bool Any<TOut, TProducer>(
this SpanEnumerable<TOut, TProducer> spanEnum,
Predicate<TOut> predicate)
where TProducer : struct, IProducer<TOut>
{
if (predicate == null)
throw new ArgumentNullException(nameof(predicate));
TOut onStack = default;
var spanOnStack = MemoryMarshal.CreateSpan(ref onStack, 1);
while (spanEnum.ConsumeInto(spanOnStack).Length > 0)
if (predicate(onStack))
return true;
return false;
}
19
Source : AnyExtensions.cs
with MIT License
from VictorNicollet
with MIT License
from VictorNicollet
public static bool Any<TOut>(
this SpanEnumerable<TOut> spanEnum,
Predicate<TOut> predicate)
{
if (predicate == null)
throw new ArgumentNullException(nameof(predicate));
TOut onStack = default;
var spanOnStack = MemoryMarshal.CreateSpan(ref onStack, 1);
while (spanEnum.ConsumeInto(spanOnStack).Length > 0)
if (predicate(onStack))
return true;
return false;
}
19
Source : CountExtensions.cs
with MIT License
from VictorNicollet
with MIT License
from VictorNicollet
public static int Count<TIn, TOut, TProducer>(
this SpanEnumerable<TIn, TOut, TProducer> spanEnum,
Predicate<TOut> predicate)
where TProducer : struct, IProducer<TIn, TOut>
{
if (predicate == null)
throw new ArgumentNullException(nameof(predicate));
var count = 0;
TOut onStack = default;
var spanOnStack = MemoryMarshal.CreateSpan(ref onStack, 1);
while (spanEnum.ConsumeInto(spanOnStack).Length > 0)
if (predicate(onStack))
++count;
return count;
}
19
Source : CountExtensions.cs
with MIT License
from VictorNicollet
with MIT License
from VictorNicollet
public static int Count<TOut, TProducer>(
this SpanEnumerable<TOut, TProducer> spanEnum,
Predicate<TOut> predicate)
where TProducer : struct, IProducer<TOut>
{
if (predicate == null)
throw new ArgumentNullException(nameof(predicate));
var count = 0;
TOut onStack = default;
var spanOnStack = MemoryMarshal.CreateSpan(ref onStack, 1);
while (spanEnum.ConsumeInto(spanOnStack).Length > 0)
if (predicate(onStack))
++count;
return count;
}
19
Source : CountExtensions.cs
with MIT License
from VictorNicollet
with MIT License
from VictorNicollet
public static int Count<TOut>(
this SpanEnumerable<TOut> spanEnum,
Predicate<TOut> predicate)
{
if (predicate == null)
throw new ArgumentNullException(nameof(predicate));
var count = 0;
TOut onStack = default;
var spanOnStack = MemoryMarshal.CreateSpan(ref onStack, 1);
while (spanEnum.ConsumeInto(spanOnStack).Length > 0)
if (predicate(onStack))
++count;
return count;
}