Antlr4.Runtime.Misc.IntervalSet.Contains C# (CSharp) Method

Contains() public method

public Contains ( int el ) : bool
el int
return bool
        public virtual bool Contains(int el)
        {
            int n = intervals.Count;
            for (int i = 0; i < n; i++)
            {
                Interval I = intervals[i];
                int a = I.a;
                int b = I.b;
                if (el < a)
                {
                    break;
                }
                // list is sorted and el is before this interval; not here
                if (el >= a && el <= b)
                {
                    return true;
                }
            }
            // found in this interval
            return false;
        }

Usage Example

 protected override void ConsumeUntil(Parser recognizer, IntervalSet set)
 {
     //System.out.println("consumeUntil("+set.toString(getTokenNames())+")");
     int ttype = recognizer.InputStream.La(1);
     while (ttype != TokenConstants.Eof && ttype != CaretToken.CaretTokenType && !set.Contains(ttype))
     {
         //System.out.println("consume during recover LA(1)="+getTokenNames()[input.LA(1)]);
         recognizer.InputStream.Consume();
         //recognizer.consume();
         ttype = recognizer.InputStream.La(1);
     }
 }
All Usage Examples Of Antlr4.Runtime.Misc.IntervalSet::Contains