/**Is this contained within a? */ public boolean subset(BitSet a) { if (a == null || !(a instanceof BitSet)) return false; return this.and(a).equals(this); }
/** Add a bitset to the list of bitsets to be generated. * if the bitset is already in the list, ignore the request. * Always adds the bitset to the end of the list, so the * caller can rely on the position of bitsets in the list. * The returned position can be used to format the bitset * name, since it is invariant. * @param p Bit set to mark for code generation * @param forParser true if the bitset is used for the parser, false for the lexer * @return The position of the bitset in the list. */ protected int markBitsetForGen(BitSet p) { // Is the bitset (or an identical one) already marked for gen? for (int i = 0; i < bitsetsUsed.size(); i++) { BitSet set = (BitSet)bitsetsUsed.elementAt(i); if (p.equals(set)) { // Use the identical one already stored return i; } } // Add the new bitset bitsetsUsed.appendElement(p.clone()); return bitsetsUsed.size() - 1; }