Beispiel #1
0
        private bool Step()
        {
            if (_tree == null)
            {
                return(false);
            }
            if (_sub != null)
            {
                if (_sub.Step())
                {
                    return(true);
                }
                _sub = null;
            }

            if (_index < 0 && !_hasVisitedTree && _order == Order.PREORDER)
            {
                _hasVisitedTree = true;
                return(true);
            }

            while (++_index < _tree.MemberCount)
            {
                Tree e = (_tree.Members[_index] as Tree);
                if (e != null)
                {
                    _sub = new TreeIterator(e, _order, _visitTreeNodes);
                    if (_sub.HasNextTreeEntry())
                    {
                        return(true);
                    }
                    _sub = null;
                    continue;
                }
                return(true);
            }

            if (_index == _tree.MemberCount && !_hasVisitedTree && _order == Order.POSTORDER)
            {
                _hasVisitedTree = true;
                return(true);
            }

            return(false);
        }
        private void Walk(Tree tree, Tree auxTree)
        {
            var       mi          = new TreeIterator(tree, TreeIterator.Order.POSTORDER);
            var       ai          = new TreeIterator(auxTree, TreeIterator.Order.POSTORDER);
            TreeEntry m           = mi.hasNext() ? mi.next() : null;
            TreeEntry a           = ai.hasNext() ? ai.next() : null;
            int       curIndexPos = IndexCounter;

            GitIndex.Entry entry = (IndexCounter < _indexMembers.Count) ? _indexMembers[IndexCounter++] : null;
            while (((m != null) || (a != null)) || (entry != null))
            {
                int            cmpma = Compare(m, a);
                int            cmpmi = Compare(m, entry);
                int            cmpai = Compare(a, entry);
                TreeEntry      pm    = ((cmpma <= 0) && (cmpmi <= 0)) ? m : null;
                TreeEntry      pa    = ((cmpma >= 0) && (cmpai <= 0)) ? a : null;
                GitIndex.Entry pi    = ((cmpmi >= 0) && (cmpai >= 0)) ? entry : null;

                if (pi != null)
                {
                    VisitEntry(pm, pa, pi);
                }
                else
                {
                    FinishVisitTree(pm, pa, curIndexPos);
                }

                if (pm != null)
                {
                    m = mi.hasNext() ? mi.next() : null;
                }

                if (pa != null)
                {
                    a = ai.hasNext() ? ai.next() : null;
                }

                if (pi != null)
                {
                    entry = (IndexCounter < _indexMembers.Count) ? _indexMembers[IndexCounter++] : null;
                }
            }
        }
Beispiel #3
0
        private bool Step()
        {
            if (_tree == null) return false;
            if (_sub != null)
            {
                if (_sub.Step()) return true;
                _sub = null;
            }

            if (_index < 0 && !_hasVisitedTree && _order == Order.PREORDER)
            {
                _hasVisitedTree = true;
                return true;
            }

            while (++_index < _tree.MemberCount)
            {
                TreeEntry e = _tree.Members[_index];
                if (e is Tree)
                {
                    _sub = new TreeIterator((Tree)e, _order, _visitTreeNodes);
                    if (_sub.HasNextTreeEntry()) return true;
                    _sub = null;
                    continue;
                }
                return true;
            }

            if (_index == _tree.MemberCount && !_hasVisitedTree && _order == Order.POSTORDER)
            {
                _hasVisitedTree = true;
                return true;
            }

            return false;
        }
Beispiel #4
0
        private void Walk(Tree tree, Tree auxTree)
        {
            var mi = new TreeIterator(tree, TreeIterator.Order.POSTORDER);
            var ai = new TreeIterator(auxTree, TreeIterator.Order.POSTORDER);
            TreeEntry m = mi.hasNext() ? mi.next() : null;
            TreeEntry a = ai.hasNext() ? ai.next() : null;
            int curIndexPos = IndexCounter;
            GitIndex.Entry entry = (IndexCounter < _indexMembers.Count) ? _indexMembers[IndexCounter++] : null;
            while (((m != null) || (a != null)) || (entry != null))
            {
                int cmpma = Compare(m, a);
                int cmpmi = Compare(m, entry);
                int cmpai = Compare(a, entry);
                TreeEntry pm = ((cmpma <= 0) && (cmpmi <= 0)) ? m : null;
                TreeEntry pa = ((cmpma >= 0) && (cmpai <= 0)) ? a : null;
                GitIndex.Entry pi = ((cmpmi >= 0) && (cmpai >= 0)) ? entry : null;

                if (pi != null)
                {
                    VisitEntry(pm, pa, pi);
                }
                else
                {
                    FinishVisitTree(pm, pa, curIndexPos);
                }

                if (pm != null)
                {
                    m = mi.hasNext() ? mi.next() : null;
                }

                if (pa != null)
                {
                    a = ai.hasNext() ? ai.next() : null;
                }

                if (pi != null)
                {
                    entry = (IndexCounter < _indexMembers.Count) ? _indexMembers[IndexCounter++] : null;
                }
            }
        }