/** Returns whether this Aspect would accept the given set. */ public boolean isInterested(BitSet componentBits) { // Check if the entity possesses ALL of the components defined in the aspect. if (!allSet.isEmpty()) { for (int i = allSet.nextSetBit(0); i >= 0; i = allSet.nextSetBit(i + 1)) { if (!componentBits.get(i)) { return false; } } } // If we are STILL interested, // Check if the entity possesses ANY of the exclusion components, if it does then the system is // not interested. if (!exclusionSet.isEmpty() && exclusionSet.intersects(componentBits)) { return false; } // If we are STILL interested, // Check if the entity possesses ANY of the components in the oneSet. If so, the system is // interested. if (!oneSet.isEmpty() && !oneSet.intersects(componentBits)) { return false; } return true; }
/** * Find the "tightest" restriction level that the identifier satisfies. * * @return the restriction level. * @internal * @deprecated This API is ICU internal only. */ @Deprecated public RestrictionLevel getRestrictionLevel() { if (!identifierProfile.containsAll(identifier) || getNumerics().size() > 1) { return RestrictionLevel.UNRESTRICTIVE; } if (ASCII.containsAll(identifier)) { return RestrictionLevel.ASCII; } // This is a bit tricky. We look at a number of factors. // The number of scripts in the text. // Plus 1 if there is some commonality among the alternates (eg [Arab Thaa]; [Arab Syrc]) // Plus number of alternates otherwise (this only works because we only test cardinality up to // 2.) // Note: the requiredScripts set omits COMMON and INHERITED; they are taken out at the // time it is created, in setIdentifier(). final int cardinalityPlus = requiredScripts.cardinality() + (commonAmongAlternates.cardinality() == 0 ? scriptSetSet.size() : 1); if (cardinalityPlus < 2) { return RestrictionLevel.SINGLE_SCRIPT_RESTRICTIVE; } if (containsWithAlternates(JAPANESE, requiredScripts) || containsWithAlternates(CHINESE, requiredScripts) || containsWithAlternates(KOREAN, requiredScripts)) { return RestrictionLevel.HIGHLY_RESTRICTIVE; } if (cardinalityPlus == 2 && requiredScripts.get(UScript.LATIN) && !requiredScripts.intersects(CONFUSABLE_WITH_LATIN)) { return RestrictionLevel.MODERATELY_RESTRICTIVE; } return RestrictionLevel.MINIMALLY_RESTRICTIVE; }
/** Splits a condition into conjunctions that do or do not intersect with a given bit set. */ static void split( RexNode condition, BitSet bitSet, List<RexNode> intersecting, List<RexNode> nonIntersecting) { for (RexNode node : RelOptUtil.conjunctions(condition)) { BitSet inputBitSet = RelOptUtil.InputFinder.bits(node); if (bitSet.intersects(inputBitSet)) { intersecting.add(node); } else { nonIntersecting.add(node); } } }
private boolean containsWithAlternates(BitSet container, BitSet containee) { if (!contains(container, containee)) { return false; } for (BitSet alternatives : scriptSetSet) { if (!container.intersects(alternatives)) { return false; } } return true; }
@Override protected final void check(Entity e) { if (dummy) { return; } boolean contains = e.getSystemBits().get(this.getSystemIndex()); boolean interested = true; // possibly interested, let's try to prove it wrong. BitSet componentBits = e.getComponentBits(); // Check if the entity possesses ALL of the components defined in the aspect. if (!allSet.isEmpty()) { for (int i = allSet.nextSetBit(0); i >= 0; i = allSet.nextSetBit(i + 1)) { if (!componentBits.get(i)) { interested = false; break; } } } // Check if the entity possesses ANY of the exclusion components, if it does then the system is // not interested. if (!exclusionSet.isEmpty() && interested) { interested = !exclusionSet.intersects(componentBits); } // Check if the entity possesses ANY of the components in the oneSet. If so, the system is // interested. if (!oneSet.isEmpty()) { interested = oneSet.intersects(componentBits); } if (interested && !contains) { insertToSystem(e); } else if (!interested && contains) { removeFromSystem(e); } }
public boolean viable(List<BitSet> subSet) { for (int i = 0; i < subSet.size(); i++) { BitSet setI = subSet.get(i); for (int j = i + 1; j < subSet.size(); j++) { BitSet setJ = subSet.get(j); if (setI.intersects(setJ)) { continue; } else { return false; } } } return true; }
/** * looks for methods that contain array load opcodes * * @param method the context object of the current method * @return if the class loads array contents */ private boolean prescreen(Method method) { BitSet bytecodeSet = getClassContext().getBytecodeSet(method); return (bytecodeSet != null) && bytecodeSet.intersects(arrayLoadOps); }
/** * Set an identifier to analyze. Afterwards, call methods like getScripts() * * @param identifier the identifier to analyze * @return self * @internal * @deprecated This API is ICU internal only. */ @Deprecated public IdentifierInfo setIdentifier(String identifier) { this.identifier = identifier; clear(); BitSet scriptsForCP = new BitSet(); int cp; for (int i = 0; i < identifier.length(); i += Character.charCount(i)) { cp = Character.codePointAt(identifier, i); // Store a representative character for each kind of decimal digit if (UCharacter.getType(cp) == UCharacterCategory.DECIMAL_DIGIT_NUMBER) { // Just store the zero character as a representative for comparison. Unicode guarantees it // is cp - value numerics.add(cp - UCharacter.getNumericValue(cp)); } UScript.getScriptExtensions(cp, scriptsForCP); scriptsForCP.clear(UScript.COMMON); scriptsForCP.clear(UScript.INHERITED); // if (temp.cardinality() == 0) { // // HACK for older version of ICU // requiredScripts.set(UScript.getScript(cp)); // } else switch (scriptsForCP.cardinality()) { case 0: break; case 1: // Single script, record it. requiredScripts.or(scriptsForCP); break; default: if (!requiredScripts.intersects(scriptsForCP) && scriptSetSet.add(scriptsForCP)) { scriptsForCP = new BitSet(); } break; } } // Now make a final pass through to remove alternates that came before singles. // [Kana], [Kana Hira] => [Kana] // This is relatively infrequent, so doesn't have to be optimized. // We also compute any commonalities among the alternates. if (scriptSetSet.size() > 0) { commonAmongAlternates.set(0, UScript.CODE_LIMIT); for (Iterator<BitSet> it = scriptSetSet.iterator(); it.hasNext(); ) { final BitSet next = it.next(); // [Kana], [Kana Hira] => [Kana] if (requiredScripts.intersects(next)) { it.remove(); } else { // [[Arab Syrc Thaa]; [Arab Syrc]] => [[Arab Syrc]] commonAmongAlternates.and(next); // get the intersection. for (BitSet other : scriptSetSet) { if (next != other && contains(next, other)) { it.remove(); break; } } } } } if (scriptSetSet.size() == 0) { commonAmongAlternates.clear(); } return this; }
/** true if weeks overlap */ public boolean shareWeeks(BitSet weekCode) { return iWeekCode.intersects(weekCode); }
/** true if weeks overlap */ public boolean shareWeeks(TimeLocation anotherLocation) { return iWeekCode.intersects(anotherLocation.iWeekCode); }