本文整理汇总了Java中java.util.BitSet.isEmpty方法的典型用法代码示例。如果您正苦于以下问题:Java BitSet.isEmpty方法的具体用法?Java BitSet.isEmpty怎么用?Java BitSet.isEmpty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.util.BitSet
的用法示例。
在下文中一共展示了BitSet.isEmpty方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: firstDate
import java.util.BitSet; //导入方法依赖的package包/类
protected static Date firstDate(DatePattern dp, int dayCode) {
if (dp == null) return null;
BitSet weekCode = dp.getPatternBitSet();
if (weekCode.isEmpty()) return null;
Calendar cal = Calendar.getInstance(Locale.US); cal.setLenient(true);
Date dpFirstDate = DateUtils.getDate(1, dp.getSession().getPatternStartMonth(), dp.getSession().getSessionStartYear());
cal.setTime(dpFirstDate);
int idx = weekCode.nextSetBit(0);
cal.add(Calendar.DAY_OF_YEAR, idx);
while (idx < weekCode.size()) {
if (weekCode.get(idx)) {
int dow = cal.get(Calendar.DAY_OF_WEEK);
switch (dow) {
case Calendar.MONDAY:
if ((dayCode & DayCode.MON.getCode()) != 0) return cal.getTime();
break;
case Calendar.TUESDAY:
if ((dayCode & DayCode.TUE.getCode()) != 0) return cal.getTime();
break;
case Calendar.WEDNESDAY:
if ((dayCode & DayCode.WED.getCode()) != 0) return cal.getTime();
break;
case Calendar.THURSDAY:
if ((dayCode & DayCode.THU.getCode()) != 0) return cal.getTime();
break;
case Calendar.FRIDAY:
if ((dayCode & DayCode.FRI.getCode()) != 0) return cal.getTime();
break;
case Calendar.SATURDAY:
if ((dayCode & DayCode.SAT.getCode()) != 0) return cal.getTime();
break;
case Calendar.SUNDAY:
if ((dayCode & DayCode.SUN.getCode()) != 0) return cal.getTime();
break;
}
}
cal.add(Calendar.DAY_OF_YEAR, 1); idx++;
}
return null;
}
示例2: dominates
import java.util.BitSet; //导入方法依赖的package包/类
/**
* Return true if bs1 dominates bs2 - meaning that at least all of the bits set in bs2 are set in
* bs1.
*
* @param bs1
* @param bs2
* @return
*/
private boolean dominates(BitSet bs1, BitSet bs2) {
// bs1 dominates bs2 if it has set at least all of the bits in bs1.
BitSet copy = new BitSet();
// Make copy a copy of bit set 2
copy.or(bs2);
// Clear all of the bits in copy that are set in bit set 1
copy.andNot(bs1);
// If all of the bits have been cleared in copy, that means
// bit set 1 had at least all of the bits set that were set in
// bs2
return copy.isEmpty();
}
示例3: intersection
import java.util.BitSet; //导入方法依赖的package包/类
/**
* Calculates the intersection of a set of lists containing relation
* IDs
*
* @param indexLists the list to be intersected.
* @return the list of relations contained in all the supplied index
* lists.
*/
protected Collection<Relation> intersection(BitSet... indexLists) {
Set<Relation> res = new HashSet<Relation>();
BitSet relIds = new BitSet(maxID + 1);
relIds.set(0, maxID + 1);
boolean found = false;
for(BitSet aList : indexLists) {
if(aList != null) {
found = true;
relIds.and(aList);
// if there is no intersection then return the empty list
if(relIds.isEmpty()) return res;
}
}
if(!found) return res;
for(int relIdx = 0; relIdx < (maxID + 1); relIdx++) {
if(relIds.get(relIdx)) {
res.add(indexById.get(relIdx));
}
}
return res;
}
示例4: hasDeadStatesFromInitial
import java.util.BitSet; //导入方法依赖的package包/类
/** Returns true if there are dead states reachable from an initial state. */
public static boolean hasDeadStatesFromInitial(Automaton a) {
BitSet reachableFromInitial = getLiveStatesFromInitial(a);
BitSet reachableFromAccept = getLiveStatesToAccept(a);
reachableFromInitial.andNot(reachableFromAccept);
return reachableFromInitial.isEmpty() == false;
}
示例5: hasDeadStatesToAccept
import java.util.BitSet; //导入方法依赖的package包/类
/** Returns true if there are dead states that reach an accept state. */
public static boolean hasDeadStatesToAccept(Automaton a) {
BitSet reachableFromInitial = getLiveStatesFromInitial(a);
BitSet reachableFromAccept = getLiveStatesToAccept(a);
reachableFromAccept.andNot(reachableFromInitial);
return reachableFromAccept.isEmpty() == false;
}
示例6: updatePredecessors
import java.util.BitSet; //导入方法依赖的package包/类
protected void updatePredecessors() {
TIntObjectIterator<BitSet> iterator = nodeToSplit.getValue().predecessors.iterator();
Node<ValueNode> parent = nodeToSplit.getParent();
BitSet letterToDeleted = new BitSet();
while(iterator.hasNext()) {
iterator.advance();
int letter = iterator.key();
BitSet statePrevs = iterator.value();
BitSet stateLeft = (BitSet) statePrevs.clone();
for(int stateNr = statePrevs.nextSetBit(0)
; stateNr >= 0
; stateNr = statePrevs.nextSetBit(stateNr + 1)) {
ValueNode statePrev = states.get(stateNr);
Node<ValueNode> nodeOther = sift(statePrev.label.append(letter), parent);
if (nodeOther != nodeToSplit) {
updateTransition(stateNr, letter, nodeOther.getValue().id);
stateLeft.clear(stateNr);
}
}
if(stateLeft.isEmpty()) {
letterToDeleted.set(letter);
}else {
iterator.setValue(stateLeft);
}
}
for(int letter = letterToDeleted.nextSetBit(0)
; letter >= 0
; letter = letterToDeleted.nextSetBit(letter + 1)) {
nodeToSplit.getValue().predecessors.remove(letter);
}
}
示例7: create_actions
import java.util.BitSet; //导入方法依赖的package包/类
protected static BitSet create_actions(BitSet actions)
{
BitSet b;
b = actions == null ? new BitSet() : (BitSet) actions.clone();
if (b.isEmpty())
{
b.set(PRINT_STATISTICS);
}
return b;
}
示例8: setPostRegisterTypeAndPropagateChanges
import java.util.BitSet; //导入方法依赖的package包/类
private void setPostRegisterTypeAndPropagateChanges(@Nonnull AnalyzedInstruction analyzedInstruction,
int registerNumber, @Nonnull RegisterType registerType) {
BitSet changedInstructions = new BitSet(analyzedInstructions.size());
if (!analyzedInstruction.setPostRegisterType(registerNumber, registerType)) {
return;
}
propagateRegisterToSuccessors(analyzedInstruction, registerNumber, changedInstructions);
//Using a for loop inside the while loop optimizes for the common case of the successors of an instruction
//occurring after the instruction. Any successors that occur prior to the instruction will be picked up on
//the next iteration of the while loop.
//This could also be done recursively, but in large methods it would likely cause very deep recursion,
//which requires the user to specify a larger stack size. This isn't really a problem, but it is slightly
//annoying.
while (!changedInstructions.isEmpty()) {
for (int instructionIndex=changedInstructions.nextSetBit(0);
instructionIndex>=0;
instructionIndex=changedInstructions.nextSetBit(instructionIndex+1)) {
changedInstructions.clear(instructionIndex);
propagateRegisterToSuccessors(analyzedInstructions.valueAt(instructionIndex), registerNumber,
changedInstructions);
}
}
if (registerType.category == RegisterType.LONG_LO) {
checkWidePair(registerNumber, analyzedInstruction);
setPostRegisterTypeAndPropagateChanges(analyzedInstruction, registerNumber+1, RegisterType.LONG_HI_TYPE);
} else if (registerType.category == RegisterType.DOUBLE_LO) {
checkWidePair(registerNumber, analyzedInstruction);
setPostRegisterTypeAndPropagateChanges(analyzedInstruction, registerNumber+1, RegisterType.DOUBLE_HI_TYPE);
}
}
示例9: SynopsisHashMapAllDump
import java.util.BitSet; //导入方法依赖的package包/类
/**
* Hot word attenuation in hot words
*/
public void SynopsisHashMapAllDump(DumpRemoveHandler dumpRemoveHandler) {
int dumpsize = (int) (1 / Threshold_p);
dumpKeyCount++;
if (dumpKeyCount == dumpsize) {
//dump all key
Iterator<Map.Entry<String, BitSet>> iterator = predictHotKeyMap.newEntryIterator();
while (iterator.hasNext()){
Map.Entry<String, BitSet> next = iterator.next();
BitSet bitm = next.getValue();
String key = next.getKey();
if(key!=null){
long[] lo = bitm.toLongArray();
if(lo.length > 0){
for(int j=0;j<lo.length - 1;j++){
lo[j] = lo[j] >>> 1;
lo[j] = lo[j] | (lo[j+1] << 63);
}
lo[lo.length-1] = lo[lo.length-1] >>> 1;
}
bitm = BitSet.valueOf(lo);
if (bitm.isEmpty()) {
iterator.remove();
dumpRemoveHandler.dumpRemove(key);
}else
next.setValue(bitm);
}
}
dumpKeyCount = 0;
}
}
示例10: SynopsisHashMapRandomDump
import java.util.BitSet; //导入方法依赖的package包/类
/**
* New Words in Hot Words Random Dump
*/
public void SynopsisHashMapRandomDump(DumpRemoveHandler dumpRemoveHandler) {
int size=predictHotKeyMap.size;
long startTimeSystemTime=System.currentTimeMillis();
Iterator<Map.Entry<String, BitSet>> iterator = predictHotKeyMap.newEntryIterator();
while (iterator.hasNext()){
Map.Entry<String, BitSet> next = iterator.next();
if (random.nextDouble()> Threshold_p){
continue;
}
BitSet bitm = next.getValue();
String key = next.getKey();
if(key!=null){
long[] lo = bitm.toLongArray();
if(lo.length > 0){
for(int j=0;j<lo.length - 1;j++){
lo[j] = lo[j] >>> 1;
lo[j] = lo[j] | (lo[j+1] << 63);
}
lo[lo.length-1] = lo[lo.length-1] >>> 1;
}
bitm = BitSet.valueOf(lo);
if (bitm.isEmpty()) {
iterator.remove();
dumpRemoveHandler.dumpRemove(key);
}else
next.setValue(bitm);
}
}
}
示例11: fixedParamsAt
import java.util.BitSet; //导入方法依赖的package包/类
/**
* @see #getFixedParams()
*/
private EconomicSet<ParameterNode> fixedParamsAt(BitSet freshlyInstantiatedArguments) {
if (freshlyInstantiatedArguments == null || freshlyInstantiatedArguments.isEmpty()) {
return EconomicSet.create(Equivalence.IDENTITY);
}
EconomicSet<ParameterNode> result = EconomicSet.create(Equivalence.IDENTITY);
for (ParameterNode p : graph.getNodes(ParameterNode.TYPE)) {
if (freshlyInstantiatedArguments.get(p.index())) {
result.add(p);
}
}
return result;
}
示例12: maxFlowAnalysis
import java.util.BitSet; //导入方法依赖的package包/类
/**
* Determine the max flow and therefore the paths.
*
* @return a list of paths
*/
public List<BitSet> maxFlowAnalysis() {
// Create a list of paths.
List<BitSet> paths = new ArrayList<BitSet>();
BitSet path;
do {
// Determine a new path.
path = determinePath();
if (path != null) {
// Take a look if there is an intersection
// with another path. Then we have to delete
// the old one.
for (int i = 0; i < paths.size(); i++) {
BitSet oldPath = (BitSet) paths.get(i).clone();
oldPath.and(path);
if (!oldPath.isEmpty()) {
// Two paths are not disjoint
// Eliminate the old one
paths.remove(i);
i--;
}
}
paths.add(path);
}
} while (path != null);
return paths;
}
示例13: lastDate
import java.util.BitSet; //导入方法依赖的package包/类
protected static Date lastDate(DatePattern dp, int dayCode) {
if (dp == null) return null;
BitSet weekCode = dp.getPatternBitSet();
if (weekCode.isEmpty()) return null;
Calendar cal = Calendar.getInstance(Locale.US); cal.setLenient(true);
Date dpFirstDate = DateUtils.getDate(1, dp.getSession().getPatternStartMonth(), dp.getSession().getSessionStartYear());
cal.setTime(dpFirstDate);
int idx = weekCode.length() - 1;
cal.add(Calendar.DAY_OF_YEAR, idx);
Date last = null;
while (idx >= 0 && last == null) {
if (weekCode.get(idx)) {
int dow = cal.get(Calendar.DAY_OF_WEEK);
switch (dow) {
case Calendar.MONDAY:
if ((dayCode & DayCode.MON.getCode()) != 0) return cal.getTime();
break;
case Calendar.TUESDAY:
if ((dayCode & DayCode.TUE.getCode()) != 0) return cal.getTime();
break;
case Calendar.WEDNESDAY:
if ((dayCode & DayCode.WED.getCode()) != 0) return cal.getTime();
break;
case Calendar.THURSDAY:
if ((dayCode & DayCode.THU.getCode()) != 0) return cal.getTime();
break;
case Calendar.FRIDAY:
if ((dayCode & DayCode.FRI.getCode()) != 0) return cal.getTime();
break;
case Calendar.SATURDAY:
if ((dayCode & DayCode.SAT.getCode()) != 0) return cal.getTime();
break;
case Calendar.SUNDAY:
if ((dayCode & DayCode.SUN.getCode()) != 0) return cal.getTime();
break;
}
}
cal.add(Calendar.DAY_OF_YEAR, -1); idx--;
}
return null;
}
示例14: subset
import java.util.BitSet; //导入方法依赖的package包/类
private static boolean subset(BitSet sub, BitSet sup) {
BitSet subcopy = (BitSet) sub.clone();
subcopy.andNot(sup);
return subcopy.isEmpty();
}
示例15: subset
import java.util.BitSet; //导入方法依赖的package包/类
private static boolean subset(BitSet sub, BitSet sup) {
BitSet subcopy = (BitSet) sub.clone();
subcopy.andNot(sup);
return subcopy.isEmpty();
}