< Summary

Information
Class: Pozitron.QuerySpecification.SpecSelectIterator<T1, T2>
Assembly: Pozitron.QuerySpecification
File(s): /home/runner/work/QuerySpecification/QuerySpecification/src/QuerySpecification/Internals/SpecSelectIterator.cs
Tag: 52_11740816328
Line coverage
100%
Covered lines: 17
Uncovered lines: 0
Coverable lines: 17
Total lines: 43
Line coverage: 100%
Branch coverage
100%
Covered branches: 6
Total branches: 6
Branch coverage: 100%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.ctor(...)100%11100%
Clone()100%11100%
MoveNext()100%66100%

File(s)

/home/runner/work/QuerySpecification/QuerySpecification/src/QuerySpecification/Internals/SpecSelectIterator.cs

#LineLine coverage
 1using System.Diagnostics;
 2
 3namespace Pozitron.QuerySpecification;
 4
 5internal sealed class SpecSelectIterator<TObject, TResult> : Iterator<TResult>
 6{
 7    private readonly SpecItem[] _source;
 8    private readonly Func<TObject, int, TResult> _selector;
 9    private readonly int _type;
 10
 20411    public SpecSelectIterator(SpecItem[] source, int type, Func<TObject, int, TResult> selector)
 12    {
 13        Debug.Assert(source != null && source.Length > 0);
 14        Debug.Assert(selector != null);
 20415        _type = type;
 20416        _source = source;
 20417        _selector = selector;
 20418    }
 19
 20    public override Iterator<TResult> Clone() =>
 5621        new SpecSelectIterator<TObject, TResult>(_source, _type, _selector);
 22
 23    public override bool MoveNext()
 24    {
 61125        var index = _state - 1;
 61126        var source = _source;
 61127        var type = _type;
 28
 73429        while (unchecked((uint)index < (uint)source.Length))
 30        {
 61831            var item = source[index];
 61832            index = _state++;
 61833            if (item.Type == type && item.Reference is TObject reference)
 34            {
 49535                _current = _selector(reference, item.Bag);
 49536                return true;
 37            }
 38        }
 39
 11640        Dispose();
 11641        return false;
 42    }
 43}