Intersects() public method

public Intersects ( BitSet other ) : bool
other BitSet
return bool
Exemplo n.º 1
0
 private BitSet GetApplicableMinMaxFollowPos(BitSet curpos, BitSet posWithRangeTerminals, BitSet[] minmaxFollowPos)
 {
     if (curpos.Intersects(posWithRangeTerminals))
     {
         BitSet set = new BitSet(this.positions.Count);
         set.Or(curpos);
         set.And(posWithRangeTerminals);
         curpos = curpos.Clone();
         for (int i = set.NextSet(-1); i != -1; i = set.NextSet(i))
         {
             LeafRangeNode particle = this.positions[i].particle as LeafRangeNode;
             curpos.Or(minmaxFollowPos[particle.Pos]);
         }
     }
     return(curpos);
 }
 //For each position, this method calculates the additional follows of any range nodes that need to be added to its followpos
 //((ab?)2-4)c, Followpos of a is b as well as that of node R(2-4) = c
 private BitSet GetApplicableMinMaxFollowPos(BitSet curpos, BitSet posWithRangeTerminals, BitSet[] minmaxFollowPos) {
     if (curpos.Intersects(posWithRangeTerminals)) {
         BitSet newSet = new BitSet(positions.Count); //Doing work again 
         newSet.Or(curpos);
         newSet.And(posWithRangeTerminals);
         curpos = curpos.Clone();
         for (int pos = newSet.NextSet(-1); pos != -1; pos = newSet.NextSet(pos)) {
             LeafRangeNode lrNode = positions[pos].particle as LeafRangeNode;
             curpos.Or(minmaxFollowPos[lrNode.Pos]);
         }
     }
     return curpos;
 }
 private BitSet GetApplicableMinMaxFollowPos(BitSet curpos, BitSet posWithRangeTerminals, BitSet[] minmaxFollowPos)
 {
     if (curpos.Intersects(posWithRangeTerminals))
     {
         BitSet set = new BitSet(this.positions.Count);
         set.Or(curpos);
         set.And(posWithRangeTerminals);
         curpos = curpos.Clone();
         for (int i = set.NextSet(-1); i != -1; i = set.NextSet(i))
         {
             LeafRangeNode particle = this.positions[i].particle as LeafRangeNode;
             curpos.Or(minmaxFollowPos[particle.Pos]);
         }
     }
     return curpos;
 }
        public override object ValidateElement(XmlQualifiedName name, ValidationState context, out int errorCode)
        {
            RangePositionInfo info;

            errorCode = 0;
            int  num  = this.symbols[name];
            bool flag = false;
            List <RangePositionInfo> runningPositions = context.RunningPositions;
            int  numberOfRunningPos = context.CurrentState.NumberOfRunningPos;
            int  count = 0;
            int  index = -1;
            int  num5  = -1;
            bool flag2 = false;

            while (count < numberOfRunningPos)
            {
                info = runningPositions[count];
                BitSet curpos = info.curpos;
                for (int i = curpos.NextSet(-1); i != -1; i = curpos.NextSet(i))
                {
                    if (num == this.positions[i].symbol)
                    {
                        index = i;
                        if (num5 == -1)
                        {
                            num5 = count;
                        }
                        flag2 = true;
                        break;
                    }
                }
                if (flag2 && (this.positions[index].particle is XmlSchemaElement))
                {
                    break;
                }
                count++;
            }
            if ((count == numberOfRunningPos) && (index != -1))
            {
                count = num5;
            }
            if (count < numberOfRunningPos)
            {
                if (count != 0)
                {
                    runningPositions.RemoveRange(0, count);
                }
                numberOfRunningPos -= count;
                count = 0;
                while (count < numberOfRunningPos)
                {
                    info = runningPositions[count];
                    if (info.curpos.Get(index))
                    {
                        info.curpos             = this.followpos[index];
                        runningPositions[count] = info;
                        count++;
                    }
                    else
                    {
                        numberOfRunningPos--;
                        if (numberOfRunningPos > 0)
                        {
                            RangePositionInfo info2 = runningPositions[numberOfRunningPos];
                            runningPositions[numberOfRunningPos] = runningPositions[count];
                            runningPositions[count] = info2;
                        }
                    }
                }
            }
            else
            {
                numberOfRunningPos = 0;
            }
            if (numberOfRunningPos > 0)
            {
                if (numberOfRunningPos >= 0x2710)
                {
                    context.TooComplex  = true;
                    numberOfRunningPos /= 2;
                }
                for (count = numberOfRunningPos - 1; count >= 0; count--)
                {
                    int    num7 = count;
                    BitSet set2 = runningPositions[count].curpos;
                    flag = flag || set2.Get(this.endMarkerPos);
                    while ((numberOfRunningPos < 0x2710) && set2.Intersects(this.positionsWithRangeTerminals))
                    {
                        BitSet set3 = set2.Clone();
                        set3.And(this.positionsWithRangeTerminals);
                        int           num8     = set3.NextSet(-1);
                        LeafRangeNode particle = this.positions[num8].particle as LeafRangeNode;
                        info = runningPositions[num7];
                        if ((numberOfRunningPos + 2) >= runningPositions.Count)
                        {
                            RangePositionInfo item = new RangePositionInfo();
                            runningPositions.Add(item);
                            RangePositionInfo info5 = new RangePositionInfo();
                            runningPositions.Add(info5);
                        }
                        RangePositionInfo info3 = runningPositions[numberOfRunningPos];
                        if (info3.rangeCounters == null)
                        {
                            info3.rangeCounters = new decimal[this.minMaxNodesCount];
                        }
                        Array.Copy(info.rangeCounters, 0, info3.rangeCounters, 0, info.rangeCounters.Length);
                        decimal num9 = info3.rangeCounters[particle.Pos] = decimal.op_Increment(info3.rangeCounters[particle.Pos]);
                        if (num9 == particle.Max)
                        {
                            info3.curpos = this.followpos[num8];
                            info3.rangeCounters[particle.Pos]    = 0M;
                            runningPositions[numberOfRunningPos] = info3;
                            num7 = numberOfRunningPos++;
                        }
                        else
                        {
                            if (num9 < particle.Min)
                            {
                                info3.curpos = particle.NextIteration;
                                runningPositions[numberOfRunningPos] = info3;
                                numberOfRunningPos++;
                                break;
                            }
                            info3.curpos = particle.NextIteration;
                            runningPositions[numberOfRunningPos] = info3;
                            num7  = numberOfRunningPos + 1;
                            info3 = runningPositions[num7];
                            if (info3.rangeCounters == null)
                            {
                                info3.rangeCounters = new decimal[this.minMaxNodesCount];
                            }
                            Array.Copy(info.rangeCounters, 0, info3.rangeCounters, 0, info.rangeCounters.Length);
                            info3.curpos = this.followpos[num8];
                            info3.rangeCounters[particle.Pos] = 0M;
                            runningPositions[num7]            = info3;
                            numberOfRunningPos += 2;
                        }
                        set2 = runningPositions[num7].curpos;
                        flag = flag || set2.Get(this.endMarkerPos);
                    }
                }
                context.HasMatched = flag;
                context.CurrentState.NumberOfRunningPos = numberOfRunningPos;
                return(this.positions[index].particle);
            }
            errorCode = -1;
            context.NeedValidateChildren = false;
            return(null);
        }