src/Misc/EFTools/DesignXmlCore/VirtualTreeGrid/Provider/ColumnItemEnumerator.cs
/// <summary>
///     Move to the next item in the column
/// </summary>
/// <returns>true if there is a next item</returns>
Move to the next item in the column
Move to the next item in the column
private bool MoveNextFiltered()
        {
            var maxFilterRow = myFilter.Length - 1;
            if (myFilterRow > maxFilterRow)
            {
                return false;
            }
            var testIndex = myFilter[myFilterRow];
            if (myBranch == null
                || myCurrentRelativeRow >= myLastRelativeRow)
            {
                if (myTrailingBlanks > 0)
                {
                    while ((myCurrentRow + myTrailingBlanks) >= testIndex)
                    {
                        if (myMarkFilterExclusions)
                        {
                            myFilter[myFilterRow] = ~testIndex;
                        }
                        ++myFilterRow;
                        if (myFilterRow > maxFilterRow)
                        {
                            return false;
                        }
                        testIndex = myFilter[myFilterRow];
                    }
                    myTrailingBlanks = 0;
                }
                myCurrentRow = testIndex - 1;
                Debug.Assert(myCurrentRow < myLimitRow);
                myNextStartRow = testIndex;
            }
            while (MoveNextUnfiltered())
            {
                if (testIndex == myCurrentRow)
                {
                    ++myFilterRow;
                    return true;
                }
                else if (testIndex < myCurrentRow)
                {
                    while (testIndex < myCurrentRow)
                    {
                        if (myMarkFilterExclusions)
                        {
                            myFilter[myFilterRow] = ~testIndex;
                        }
                        ++myFilterRow;
                        if (myFilterRow > maxFilterRow)
                        {
                            return false;
                        }
                        testIndex = myFilter[myFilterRow];
                    }
                    if (testIndex == myCurrentRow)
                    {
                        ++myFilterRow;
                        return true;
                    }
                }
                if (myCurrentRelativeRow >= myLastRelativeRow)
                {
                    myBranch = null;
                    if (myTrailingBlanks > 0)
                    {
                        while ((myCurrentRow + myTrailingBlanks) >= testIndex)
                        {
                            if (myMarkFilterExclusions)
                            {
                                myFilter[myFilterRow] = ~testIndex;
                            }
                            ++myFilterRow;
                            if (myFilterRow > maxFilterRow)
                            {
                                return false;
                            }
                            testIndex = myFilter[myFilterRow];
                        }
                        myTrailingBlanks = 0;
                    }
                    myCurrentRow = testIndex - 1;
                    Debug.Assert(myCurrentRow < myLimitRow);
                    myNextStartRow = testIndex;
                }
                else
                {
                    var remainingSectionItems = myLastRelativeRow - myCurrentRelativeRow;
                    var distanceToRemaining = myCurrentRow + remainingSectionItems - testIndex;
                    if (distanceToRemaining >= 0)
                    {
                        ++myFilterRow;
                        myCurrentRow = testIndex;
                        myCurrentRelativeRow = myLastRelativeRow - distanceToRemaining;
                        return true;
                    }
                }
            }
            if (myMarkFilterExclusions && myFilterRow <= maxFilterRow)
            {
                for (var i = myFilterRow; i <= maxFilterRow; ++i)
                {
                    myFilter[i] = ~myFilter[i];
                }
            }
            return false;
        }
private bool MoveNextFiltered ( ) { var maxFilterRow = myFilter . Length - 1 ; if ( myFilterRow > maxFilterRow ) { return false ; } var testIndex = myFilter [ myFilterRow ] ; if ( myBranch == null || myCurrentRelativeRow >= myLastRelativeRow ) { if ( myTrailingBlanks > 0 ) { while ( ( myCurrentRow + myTrailingBlanks ) >= testIndex ) { if ( myMarkFilterExclusions ) { myFilter [ myFilterRow ] = ~ testIndex ; } ++ myFilterRow ; if ( myFilterRow > maxFilterRow ) { return false ; } testIndex = myFilter [ myFilterRow ] ; } myTrailingBlanks = 0 ; } myCurrentRow = testIndex - 1 ; Debug . Assert ( myCurrentRow < myLimitRow ) ; myNextStartRow = testIndex ; } while ( MoveNextUnfiltered ( ) ) { if ( testIndex == myCurrentRow ) { ++ myFilterRow ; return true ; } else if ( testIndex < myCurrentRow ) { while ( testIndex < myCurrentRow ) { if ( myMarkFilterExclusions ) { myFilter [ myFilterRow ] = ~ testIndex ; } ++ myFilterRow ; if ( myFilterRow > maxFilterRow ) { return false ; } testIndex = myFilter [ myFilterRow ] ; } if ( testIndex == myCurrentRow ) { ++ myFilterRow ; return true ; } } if ( myCurrentRelativeRow >= myLastRelativeRow ) { myBranch = null ; if ( myTrailingBlanks > 0 ) { while ( ( myCurrentRow + myTrailingBlanks ) >= testIndex ) { if ( myMarkFilterExclusions ) { myFilter [ myFilterRow ] = ~ testIndex ; } ++ myFilterRow ; if ( myFilterRow > maxFilterRow ) { return false ; } testIndex = myFilter [ myFilterRow ] ; } myTrailingBlanks = 0 ; } myCurrentRow = testIndex - 1 ; Debug . Assert ( myCurrentRow < myLimitRow ) ; myNextStartRow = testIndex ; } else { var remainingSectionItems = myLastRelativeRow - myCurrentRelativeRow ; var distanceToRemaining = myCurrentRow + remainingSectionItems - testIndex ; if ( distanceToRemaining >= 0 ) { ++ myFilterRow ; myCurrentRow = testIndex ; myCurrentRelativeRow = myLastRelativeRow - distanceToRemaining ; return true ; } } } if ( myMarkFilterExclusions && myFilterRow <= maxFilterRow ) { for ( var i = myFilterRow ; i <= maxFilterRow ; ++ i ) { myFilter [ i ] = ~ myFilter [ i ] ; } } return false ; }
Move to the next item in the column
Move to the next item in the column
// Fastforward MoveNextUnfiltered // The limit row is based on the last filter row. If this assert fails, mark trailing filter rows and get out // See if we have a match // Iterating columns has already skipped the value // The row we're looking for is now higher than the current row in the enumerator. // At this point we could just let this loop spin, but that is very inefficient // if we're moving a long way, so we make a couple of extra checks. // The limit row is based on the last filter row. If this assert fails, mark trailing filter rows and get out // Clean up any exclusions we haven't hit yet
true if there is a next item
true if there is a next item