Exemplo n.º 1
0
 protected override UpInfo <TItem> AfterVisitingSuccessors(bool visitSuccessors, TItem tail,
                                                           Stack <TDependency> currentPath, int expectedPathMatchIndex, UpInfo <TItem> upSum)
 {
     if (visitSuccessors)
     {
         // We visit the children - tail was therefore definitely not in _onPath - so we can safely remove it!
         var key = new ItemAndInt(tail, expectedPathMatchIndex);
         _onPath.Remove(key);
     }
     return(upSum);
 }
 public override bool Equals(object obj)
 {
     if (obj is ItemAndInt)
     {
         ItemAndInt other = (ItemAndInt)obj;
         return(Equals(other._item, _item) && other._int == _int);
     }
     else
     {
         return(false);
     }
 }
Exemplo n.º 3
0
            protected override UpInfo <TItem> BeforePopDependency(Stack <TDependency> currentPath, int expectedPathMatchIndex,
                                                                  AbstractPathMatch <TDependency, TItem> pathMatchOrNull, bool isEnd,
                                                                  Ignore here, UpInfo <TItem> upSum, UpInfo <TItem> childUp)
            {
                upSum.UnionWith(childUp);

                TDependency top          = currentPath.Peek();
                var         key          = new ItemAndInt(top.UsedItem, expectedPathMatchIndex);
                bool        isEndOfCycle = _onPath.Contains(key);

                if (isEnd || isEndOfCycle)
                {
                    upSum.Add(top.UsedItem);
                }
                return(upSum);
            }
Exemplo n.º 4
0
            protected override List <PathNode <TItem, TDependency> > BeforePopDependency(Stack <TDependency> currentPath, int expectedPathMatchIndex,
                                                                                         AbstractPathMatch <TDependency, TItem> pathMatchOrNull, bool isEnd,
                                                                                         HereInfo here, List <PathNode <TItem, TDependency> > upSum, List <PathNode <TItem, TDependency> > childUp)
            {
                TDependency top          = currentPath.Peek();
                var         key          = new ItemAndInt(top.UsedItem, expectedPathMatchIndex);
                bool        isEndOfCycle = _onPath.Contains(key);

                if (isEnd || isEndOfCycle || childUp.Any(p => p.LeadsToEndNodes))
                {
                    PathNode <TItem, TDependency> n = new PathNode <TItem, TDependency>(top, isEnd,
                                                                                        isEndOfCycle, here.DependencyMatchedByCountMatch, here.UsedItemMatchedByCountMatch, childUp);
                    if (isEnd || isEndOfCycle)
                    {
                        _nodesWithEndFlag++;
                    }
                    upSum.Add(n);
                }
                return(upSum);
            }
Exemplo n.º 5
0
            protected override bool ShouldVisitSuccessors(TItem tail, Stack <TDependency> currentPath, int expectedPathMatchIndex, out List <PathNode <TItem, TDependency> > initUpSum)
            {
                initUpSum = new List <PathNode <TItem, TDependency> >();
                var onPathItem = new ItemAndInt(tail, expectedPathMatchIndex);

                if (currentPath.Count == 0)
                {
                    // Behind head
                    _onPath.Add(onPathItem);
                    return(true);
                }
                else if (currentPath.Count >= _maxPathLength)
                {
                    // We have reached the checking limit - no further graph traversal
                    return(false);
                }
                else
                {
                    // Check for loop
                    bool tailNewOnPath = _onPath.Add(onPathItem);
                    return(tailNewOnPath);
                }
            }