public static BitSet of(int el) { BitSet s = new BitSet(el + 1); s.add(el); return s; }
public virtual BitSet and(BitSet a) { BitSet s = (BitSet) this.Clone(); s.andInPlace(a); return s; }
/*Is this contained within a? */ public virtual bool subset(BitSet a) { if (a == null) //(a == null || !(a is BitSet)) return false; return this.and(a).Equals(this); }
/*Subtract the elements of 'a' from 'this' in-place. * Basically, just turn off all bits of 'this' that are in 'a'. */ public virtual void subtractInPlace(BitSet a) { if (a == null) return ; // for all words of 'a', turn off corresponding bits of 'this' for (int i = 0; i < dataBits.Length && i < a.dataBits.Length; i++) { dataBits[i] &= ~ a.dataBits[i]; } }
/*return this | a in a new set */ public virtual BitSet or(BitSet a) { BitSet s = (BitSet) this.Clone(); s.orInPlace(a); return s; }
public virtual void orInPlace(BitSet a) { // If this is smaller than a, grow this first if (a.dataBits.Length > dataBits.Length) { setSize((int) (a.dataBits.Length)); } int min = (int) (System.Math.Min(dataBits.Length, a.dataBits.Length)); for (int i = min - 1; i >= 0; i--) { dataBits[i] |= a.dataBits[i]; } }
public virtual object Clone() { BitSet s; try { s = new BitSet(); s.dataBits = new long[dataBits.Length]; Array.Copy(dataBits, 0, s.dataBits, 0, dataBits.Length); } catch //(System.Exception e) { throw new System.ApplicationException(); } return s; }
public virtual void andInPlace(BitSet a) { int min = (int) (Math.Min(dataBits.Length, a.dataBits.Length)); for (int i = min - 1; i >= 0; i--) { dataBits[i] &= a.dataBits[i]; } // clear all bits in this not present in a (if this bigger than a). for (int i = min; i < dataBits.Length; i++) { dataBits[i] = 0; } }
public virtual void fireMismatch(int i, BitSet b, string text, int guessing) { MatchEventHandler eventDelegate = (MatchEventHandler)((Parser)source).Events[Parser.MisMatchEventKey]; if (eventDelegate != null) { matchEvent.setValues(MatchEventArgs.BITSET, i, b, text, guessing, false, true); eventDelegate(source, matchEvent); } checkController(); }
public virtual void fireMatch(char c, BitSet b, int guessing) { MatchEventHandler eventDelegate = (MatchEventHandler)((Parser)source).Events[Parser.MatchEventKey]; if (eventDelegate != null) { matchEvent.setValues(MatchEventArgs.CHAR_BITSET, c, b, null, guessing, false, true); eventDelegate(source, matchEvent); } checkController(); }
/// <summary>Make sure current lookahead symbol matches the given set /// Throw an exception upon mismatch, which is catch by either the /// error handler or by the syntactic predicate. /// </summary> public override void match(BitSet b) { string text = LT(1).getText(); int la_1 = LA(1); try { base.match(b); parserEventSupport.fireMatch(la_1, b, text, inputState.guessing); } catch (MismatchedTokenException e) { if (inputState.guessing == 0) parserEventSupport.fireMismatch(la_1, b, text, inputState.guessing); throw e; } }