java.util.BitSet#intersects ( )源码实例Demo

下面列出了java.util.BitSet#intersects ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

private List<BitSet> findLHS(Set<BitSet> Li, CMAX_SET correctSet) {

        List<BitSet> lhs_i = new LinkedList<BitSet>();
        for (BitSet l : Li) {
            boolean isLHS = true;
            for (BitSet x : correctSet.getCombinations()) {
                if (!l.intersects(x)) {
                    isLHS = false;
                    break;
                }
            }
            if (isLHS) {
                lhs_i.add(l);
            }
        }
        return lhs_i;
    }
 
源代码2 项目: cpsolver   文件: MaxHolesFlexibleConstraint.java
public void weaken(Assignment<Lecture, Placement> assignment, Placement value) {
    if (!isHard()) return;
    for (int dayCode : Constants.DAY_CODES) {
        if ((value.getTimeLocation().getDayCode() & dayCode) == 0) continue; // ignore other days
        for (BitSet week : getWeeks()) {
            if (week != null && !week.intersects(value.getTimeLocation().getWeekCode())) continue; // ignore other weeks
            int penalty = countHoles(assignment, dayCode, null, value, null, week);
            if (penalty > iMaxHolesOnADay) {
                Map<BitSet, Integer> holes = iMaxHoles.get(dayCode);
                if (holes == null) {
                    holes = new HashMap<BitSet, Integer>();
                    iMaxHoles.put(dayCode, holes);
                }
                Integer oldPenalty = holes.get(week);
                if (oldPenalty != null && oldPenalty >= penalty) continue;
                holes.put(week, penalty);
            }
        }
    }
}
 
源代码3 项目: metanome-algorithms   文件: FindCoversGenerator.java
private boolean covers(BitSet obs, List<DifferenceSet> originalDiffSet) {

        for (DifferenceSet diff : originalDiffSet) {

        	if (!obs.intersects(diff.getAttributes())) {
                return false;
            }
        }

        return true;
    }
 
源代码4 项目: fitnotifications   文件: IdentifierInfo.java
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;
}
 
源代码5 项目: cpsolver   文件: MaxHolesFlexibleConstraint.java
@Override
public void computeConflicts(Assignment<Lecture, Placement> assignment, Placement value, Set<Placement> conflicts) {
    if (!isHard()) return;
    
    MaxHolesFlexibleConstraintContext context = (MaxHolesFlexibleConstraintContext)getContext(assignment);
    
    // constraint is checked for every day in week
    for (int dayCode : Constants.DAY_CODES) {
        if ((value.getTimeLocation().getDayCode() & dayCode) == 0) continue; // ignore other days
        // constraint is checked for every week in semester (or for the whole semester)
        for (BitSet week : getWeeks()) {
            if (week != null && !week.intersects(value.getTimeLocation().getWeekCode())) continue; // ignore other weeks
            // check penalty
            int penalty = countHoles(assignment, dayCode, conflicts, value, null, week);
            while (penalty > context.getMaxHoles(dayCode, week)) {
                // too many holes -> identify adepts for unassignment
                List<Placement> adepts = new ArrayList<Placement>();
                for (Placement placement: getRelevantPlacements(assignment, dayCode, conflicts, value, null, week)) {
                    if (placement.equals(value)) continue; // skip given value
                    // check if removing placement would improve the penalty
                    HashMap<Lecture, Placement> assignments = new HashMap<Lecture, Placement>(); assignments.put(placement.variable(), null);
                    int newPenalty = countHoles(assignment, dayCode, conflicts, value, assignments, week);
                    if (newPenalty <= penalty)
                        adepts.add(placement);
                }
                
                // no adepts -> fail
                if (adepts.isEmpty()) {
                    conflicts.add(value); return;
                }
                
                // pick one randomly
                conflicts.add(ToolBox.random(adepts));
                penalty = countHoles(assignment, dayCode, conflicts, value, null, week);
            }
        }
    }
}
 
源代码6 项目: jadx   文件: RegionMaker.java
@Nullable
private BlockNode searchFallThroughCase(BlockNode successor, BlockNode out, BitSet caseBlocks) {
	BitSet df = successor.getDomFrontier();
	if (df.intersects(caseBlocks)) {
		return getOneIntersectionBlock(out, caseBlocks, df);
	}
	Set<BlockNode> allPathsBlocks = BlockUtils.getAllPathsBlocks(successor, out);
	Map<BlockNode, BitSet> bitSetMap = BlockUtils.calcPartialPostDominance(mth, allPathsBlocks, out);
	BitSet pdoms = bitSetMap.get(successor);
	if (pdoms != null && pdoms.intersects(caseBlocks)) {
		return getOneIntersectionBlock(out, caseBlocks, pdoms);
	}
	return null;
}
 
源代码7 项目: tez   文件: DagAwareYarnTaskScheduler.java
@GuardedBy("this")
@Nullable
private Collection<ContainerId> maybePreempt(Resource freeResources) {
  if (preemptionPercentage == 0 || numHeartbeats - lastPreemptionHeartbeat < numHeartbeatsBetweenPreemptions) {
    return null;
  }
  if (!requestTracker.isPreemptionDeadlineExpired() && requestTracker.fitsHighestPriorityRequest(freeResources)) {
    if (numHeartbeats % 50 == 1) {
      LOG.info("Highest priority request fits in free resources {}", freeResources);
    }
    return null;
  }

  int numIdleContainers = idleTracker.getNumContainers();
  if (numIdleContainers > 0) {
    if (numHeartbeats % 50 == 1) {
      LOG.info("Avoiding preemption since there are {} idle containers", numIdleContainers);
    }
    return null;
  }

  BitSet blocked = requestTracker.createVertexBlockedSet();
  if (!blocked.intersects(assignedVertices)) {
    if (numHeartbeats % 50 == 1) {
      LOG.info("Avoiding preemption since there are no descendants of the highest priority requests running");
    }
    return null;
  }

  Resource preemptLeft = requestTracker.getAmountToPreempt(preemptionPercentage);
  if (!resourceCalculator.anyAvailable(preemptLeft)) {
    if (numHeartbeats % 50 == 1) {
      LOG.info("Avoiding preemption since amount to preempt is {}", preemptLeft);
    }
    return null;
  }

  PriorityQueue<HeldContainer> candidates = new PriorityQueue<>(11, PREEMPT_ORDER_COMPARATOR);
  blocked.and(assignedVertices);
  for (int i = blocked.nextSetBit(0); i >= 0; i = blocked.nextSetBit(i + 1)) {
    Collection<HeldContainer> containers = vertexAssignments.get(i);
    if (containers != null) {
      candidates.addAll(containers);
    } else {
      LOG.error("Vertex {} in assignedVertices but no assignments?", i);
    }
  }

  ArrayList<ContainerId> preemptedContainers = new ArrayList<>();
  HeldContainer hc;
  while ((hc = candidates.poll()) != null) {
    LOG.info("Preempting container {} currently allocated to task {}", hc.getId(), hc.getAssignedTask());
    preemptedContainers.add(hc.getId());
    resourceCalculator.deductFrom(preemptLeft, hc.getCapability());
    if (!resourceCalculator.anyAvailable(preemptLeft)) {
      break;
    }
  }

  return preemptedContainers;
}