Java Code Examples for java.util.BitSet#equals()
The following examples show how to use
java.util.BitSet#equals() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FDTreeElement.java From metanome-algorithms with Apache License 2.0 | 6 votes |
protected void filterGeneralizations(BitSet lhs, int rhs, int currentLhsAttr, BitSet currentLhs) { if (currentLhs.equals(lhs)) return; this.rhsFds.clear(rhs); // Is the dependency already read and we have not yet found a generalization? if (currentLhsAttr < 0) return; if (this.children != null) { for (int nextLhsAttr = lhs.nextSetBit(currentLhsAttr); nextLhsAttr >= 0; nextLhsAttr = lhs.nextSetBit(nextLhsAttr + 1)) { if ((this.children[nextLhsAttr] != null) && (this.children[nextLhsAttr].hasRhsAttribute(rhs))) { currentLhs.set(nextLhsAttr); this.children[nextLhsAttr].filterGeneralizations(lhs, rhs, lhs.nextSetBit(nextLhsAttr + 1), currentLhs); currentLhs.clear(nextLhsAttr); } } } }
Example 2
Source File: OzoneAclUtil.java From hadoop-ozone with Apache License 2.0 | 6 votes |
/** * Add an OzoneAcl to existing list of OzoneAcls. * @param existingAcls * @param acl * @return true if current OzoneAcls are changed, false otherwise. */ public static boolean addAcl(List<OzoneAcl> existingAcls, OzoneAcl acl) { if (existingAcls == null || acl == null) { return false; } for (OzoneAcl a: existingAcls) { if (a.getName().equals(acl.getName()) && a.getType().equals(acl.getType()) && a.getAclScope().equals(acl.getAclScope())) { BitSet current = a.getAclBitSet(); BitSet original = (BitSet) current.clone(); current.or(acl.getAclBitSet()); if (current.equals(original)) { return false; } return true; } } existingAcls.add(acl); return true; }
Example 3
Source File: OzoneAclUtil.java From hadoop-ozone with Apache License 2.0 | 6 votes |
/** * remove OzoneAcl from existing list of OzoneAcls. * @param existingAcls * @param acl * @return true if current OzoneAcls are changed, false otherwise. */ public static boolean removeAcl(List<OzoneAcl> existingAcls, OzoneAcl acl) { if (existingAcls == null || existingAcls.isEmpty() || acl == null) { return false; } for (OzoneAcl a: existingAcls) { if (a.getName().equals(acl.getName()) && a.getType().equals(acl.getType()) && a.getAclScope().equals(acl.getAclScope())) { BitSet current = a.getAclBitSet(); BitSet original = (BitSet) current.clone(); current.andNot(acl.getAclBitSet()); if (current.equals(original)) { return false; } if (current.isEmpty()) { existingAcls.remove(a); } return true; } } return false; }
Example 4
Source File: FingerprintSubset.java From ReactionDecoder with GNU Lesser General Public License v3.0 | 6 votes |
/** * Determine if this set is an (improper) superset of another. * * @param source the set we are testing for. * @param destination the set we are testing against. * @return source is a superset of destination, yes then return true else * false * @throws CDKException */ public static boolean isSuperSet(BitSet source, BitSet destination) throws CDKException { boolean flag = false; if (source.cardinality() >= destination.cardinality()) { not_null(source); /* make a copy of the source set */ BitSet copy_other = (BitSet) source.clone(); /* and or in */ copy_other.and(destination); /* if it hasn't changed, we were a subset */ flag = copy_other.equals(destination); // flag = copy_other.equals(destination); } return flag; }
Example 5
Source File: TestOzoneAclUtil.java From hadoop-ozone with Apache License 2.0 | 5 votes |
private boolean verifyAclAdded(List<OzoneAcl> acls, OzoneAcl newAcl) { for (OzoneAcl acl : acls) { if (acl.getName().equals(newAcl.getName()) && acl.getType().equals(newAcl.getType()) && acl.getAclScope().equals(newAcl.getAclScope())) { BitSet temp = (BitSet) acl.getAclBitSet().clone(); temp.and(newAcl.getAclBitSet()); return temp.equals(newAcl.getAclBitSet()); } } return false; }
Example 6
Source File: Selection.java From gcs with Mozilla Public License 2.0 | 5 votes |
private void applySelectionChange(BitSet newSel) { if (!newSel.equals(mSelection)) { selectionAboutToChange(); mSelection = newSel; selectionDidChange(); } }
Example 7
Source File: DOMOutputCapsule.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 5 votes |
public void write(BitSet value, String name, BitSet defVal) throws IOException { if (value == null || value.equals(defVal)) { return; } StringBuilder buf = new StringBuilder(); for (int i = value.nextSetBit(0); i >= 0; i = value.nextSetBit(i + 1)) { buf.append(i); buf.append(" "); } buf.setLength(Math.max(0, buf.length() - 1)); currentElement.setAttribute(name, buf.toString()); }
Example 8
Source File: LiveVarAnalysis.java From Box with Apache License 2.0 | 5 votes |
private void processLiveInfo() { int bbCount = mth.getBasicBlocks().size(); int regsCount = mth.getRegsCount(); BitSet[] liveInBlocks = initBitSetArray(bbCount, regsCount); List<BlockNode> blocks = mth.getBasicBlocks(); int blocksCount = blocks.size(); int iterationsLimit = blocksCount * 10; boolean changed; int k = 0; do { changed = false; for (BlockNode block : blocks) { int blockId = block.getId(); BitSet prevIn = liveInBlocks[blockId]; BitSet newIn = new BitSet(regsCount); for (BlockNode successor : block.getSuccessors()) { newIn.or(liveInBlocks[successor.getId()]); } newIn.andNot(defs[blockId]); newIn.or(uses[blockId]); if (!prevIn.equals(newIn)) { changed = true; liveInBlocks[blockId] = newIn; } } if (k++ > iterationsLimit) { throw new JadxRuntimeException("Live variable analysis reach iterations limit, blocks count: " + blocksCount); } } while (changed); this.liveIn = liveInBlocks; }
Example 9
Source File: Mappings.java From Quicksql with MIT License | 5 votes |
/** * Applies a mapping to a BitSet. * * <p>If the mapping does not affect the bit set, returns the original. * Never changes the original. * * @param mapping Mapping * @param bitSet Bit set * @return Bit set with mapping applied */ public static BitSet apply(Mapping mapping, BitSet bitSet) { final BitSet newBitSet = new BitSet(); for (int source : BitSets.toIter(bitSet)) { final int target = mapping.getTarget(source); newBitSet.set(target); } if (newBitSet.equals(bitSet)) { return bitSet; } return newBitSet; }
Example 10
Source File: Mappings.java From Bats with Apache License 2.0 | 5 votes |
/** * Applies a mapping to a BitSet. * * <p>If the mapping does not affect the bit set, returns the original. * Never changes the original. * * @param mapping Mapping * @param bitSet Bit set * @return Bit set with mapping applied */ public static BitSet apply(Mapping mapping, BitSet bitSet) { final BitSet newBitSet = new BitSet(); for (int source : BitSets.toIter(bitSet)) { final int target = mapping.getTarget(source); newBitSet.set(target); } if (newBitSet.equals(bitSet)) { return bitSet; } return newBitSet; }
Example 11
Source File: TestOzoneAclUtil.java From hadoop-ozone with Apache License 2.0 | 5 votes |
private boolean verifyAclRemoved(List<OzoneAcl> acls, OzoneAcl removedAcl) { for (OzoneAcl acl : acls) { if (acl.getName().equals(removedAcl.getName()) && acl.getType().equals(removedAcl.getType()) && acl.getAclScope().equals(removedAcl.getAclScope())) { BitSet temp = (BitSet) acl.getAclBitSet().clone(); temp.and(removedAcl.getAclBitSet()); return !temp.equals(removedAcl.getAclBitSet()); } } return true; }
Example 12
Source File: OmOzoneAclMap.java From hadoop-ozone with Apache License 2.0 | 5 votes |
public boolean hasAccess(OzoneAclInfo acl) { if (acl == null) { return false; } BitSet aclBitSet = getAcl(acl.getType(), acl.getName()); if (aclBitSet == null) { return false; } BitSet result = BitSet.valueOf(acl.getRights().toByteArray()); result.and(aclBitSet); return (!result.equals(ZERO_BITSET) || aclBitSet.get(ALL.ordinal())) && !aclBitSet.get(NONE.ordinal()); }
Example 13
Source File: terminal_set.java From translationstudio8 with GNU General Public License v2.0 | 5 votes |
/** Determine if this set intersects another. * @param other the other set in question. */ public boolean intersects(terminal_set other) throws internal_error { not_null(other); /* make a copy of the other set */ BitSet copy = (BitSet)other._elements.clone(); /* xor out our values */ copy.xor(this._elements); /* see if its different */ return !copy.equals(other._elements); }
Example 14
Source File: RepeatingFooterValidator.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 5 votes |
public boolean isRepeatFooterValid( final ReportEvent event, final LayouterLevel[] levels ) { final BitSet bitSet = computeRepeatingFooterValidity( event, levels ); if ( bitSet.equals( lastPrintedRepeatFooterSignature ) ) { return true; } else { this.lastPrintedRepeatFooterSignature.clear(); this.lastPrintedRepeatFooterSignature.or( bitSet ); return false; } }
Example 15
Source File: Mappings.java From calcite with Apache License 2.0 | 5 votes |
/** * Applies a mapping to a BitSet. * * <p>If the mapping does not affect the bit set, returns the original. * Never changes the original. * * @param mapping Mapping * @param bitSet Bit set * @return Bit set with mapping applied */ public static BitSet apply(Mapping mapping, BitSet bitSet) { final BitSet newBitSet = new BitSet(); for (int source : BitSets.toIter(bitSet)) { final int target = mapping.getTarget(source); newBitSet.set(target); } if (newBitSet.equals(bitSet)) { return bitSet; } return newBitSet; }
Example 16
Source File: AbstractDominatorsAnalysis.java From spotbugs with GNU Lesser General Public License v2.1 | 4 votes |
@Override public boolean same(BitSet fact1, BitSet fact2) { return fact1.equals(fact2); }
Example 17
Source File: AbstractBitwiseHierarchyImpl.java From kogito-runtimes with Apache License 2.0 | 4 votes |
public int superset( BitSet n1, BitSet n2 ) { if ( n1.equals( n2 ) ) { return 0; } return supersetOrEqualset(n1, n2) ? 1 : -1; }
Example 18
Source File: SSIConstructionPhase.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
private static void check(AbstractBlockBase<?> block, BitSet liveIn1, BitSet liveIn2) { if (!liveIn1.equals(liveIn2)) { throw JVMCIError.shouldNotReachHere(String.format("%s LiveSet differ: %s vs %s", block, liveIn1, liveIn2)); } }
Example 19
Source File: GenericBitSet.java From maple-ir with GNU General Public License v3.0 | 4 votes |
public boolean containsAll(GenericBitSet<N> other) { BitSet temp = (BitSet) other.bitset.clone(); // if contains all, set.bitset will be a subset of our bitset temp.and(bitset); return temp.equals(other.bitset); }
Example 20
Source File: CDKRGraph.java From ReactionDecoder with GNU Lesser General Public License v3.0 | 4 votes |
/** * Checks if a potential solution is a real one (not included in a previous * solution) and add this solution to the solution list in case of success. * * @param traversed new potential solution */ private void solution(BitSet traversed) throws CDKException { boolean included = false; BitSet projG1 = projectG1(traversed); BitSet projG2 = projectG2(traversed); // the solution must follows the search constrains // (must contain the mandatory elements in G1 an G2) if (isContainedIn(getSourceBitSet(), projG1) && isContainedIn(getTargetBitSet(), projG2)) { // the solution should not be included in a previous solution // at the CDKRGraph level. So we check against all previous solution // On the other hand if a previous solution is included in the // new one, the previous solution is removed. for (Iterator<BitSet> i = getSolutionList().listIterator(); i.hasNext() && !included;) { BitSet sol = i.next(); if (!sol.equals(traversed)) { // if we asked to save all 'mappings' then keep this mapping if (isFindAllMap() && (projG1.equals(projectG1(sol)) || projG2.equals(projectG2(sol)))) { // do nothing } // if the new solution is included mark maxIterator as included else if (isContainedIn(projG1, projectG1(sol)) || isContainedIn(projG2, projectG2(sol))) { included = true; } // if the previous solution is contained in the new one, remove the previous solution else if (isContainedIn(projectG1(sol), projG1) || isContainedIn(projectG2(sol), projG2)) { i.remove(); } } else { // solution already exists included = true; } } if (included == false) { // if maxIterator is really a new solution add maxIterator to the // list of current solution getSolutionList().add(traversed); } if (!isFindAllStructure()) { // if we need only one solution // stop the search process // (e.g. substructure search) this.stop = true; } } }