当前位置: 首页>>代码示例>>Java>>正文


Java BitSet.clear方法代码示例

本文整理汇总了Java中java.util.BitSet.clear方法的典型用法代码示例。如果您正苦于以下问题:Java BitSet.clear方法的具体用法?Java BitSet.clear怎么用?Java BitSet.clear使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.util.BitSet的用法示例。


在下文中一共展示了BitSet.clear方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: main

import java.util.BitSet; //导入方法依赖的package包/类
public static void main(String[] args) {
    String[] malformedIPv4s = {"192.168.1.220..."};
    BitSet expectedExceptions = new BitSet(malformedIPv4s.length);
    expectedExceptions.clear();

    for (int i = 0; i < malformedIPv4s.length; i++) {
        try {
            InetAddress.getAllByName(malformedIPv4s[i]);
        } catch (UnknownHostException e) {
            expectedExceptions.set(i);
        }
    }

    for (int i = 0; i < malformedIPv4s.length; i++) {
        if (!expectedExceptions.get(i)) {
            System.out.println("getAllByName(\"" + malformedIPv4s[i] + "\") should throw exception.");
        }
    }

    if (expectedExceptions.cardinality() != malformedIPv4s.length) {
        throw new RuntimeException("Failed: some expected UnknownHostExceptions are not thrown.");
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:24,代码来源:B6296240.java

示例2: testIndexAddDelete

import java.util.BitSet; //导入方法依赖的package包/类
@Test
public void testIndexAddDelete() throws Exception {
    for (int i=0; i< 1000; i++) {
        IndexDocument docwrap = IndexManager.createDocument(Integer.toString(i));
        docwrap.addPair("bin", Integer.toBinaryString(i), true, true);
        docwrap.addPair("oct", Integer.toOctalString(i), true, true);
        index.addDocument(docwrap);
    }
    index.store(true);
    BitSet expected = new BitSet(1000);
    expected.set(0, 1000);
    assertIndex(expected);
    for (int i = 100; i<200; i++) {
        index.removeDocument(Integer.toString(i));
        expected.clear(i);
    }
    index.store(true);
    assertIndex(expected);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:20,代码来源:LuceneIndexTest.java

示例3: visitAndset

import java.util.BitSet; //导入方法依赖的package包/类
private void visitAndset(IRegion root, BitSet live) {
    ((AbstractRegion)root).remove(AFlag.REMOVE_FOR_FLAT);
    if (root.getChildren() != null) {
        List<IRegion> children = root.getChildren();
        for (int i = children.size() - 1; i >= 0; i--) {
            visitAndset(children.get(i), live);
        }
    }

    if (root instanceof Region) {
        InsnNode node = ((Region) root).getInsn();
        Instruction insn = node.getInstruction().getInstruction();
        if (insn != null) {
            if (insn.getOpcode().setsRegister()) {
                int registernum = ((OneRegisterInstruction) insn).getRegisterA();
                live.clear(registernum);
                if (insn.getOpcode().setsWideRegister())
                    live.clear(registernum + 1);
            }
            LiveVarVisitor.setUse(insn, live);
        }
    }
}
 
开发者ID:CvvT,项目名称:andbg,代码行数:24,代码来源:TraceLiveVisitor.java

示例4: primes

import java.util.BitSet; //导入方法依赖的package包/类
public static ArrayList<Integer> primes(int max) {
	if (max < 2) {
		return new ArrayList<Integer>();
	}
	BitSet primeSet = new BitSet(max / 2);
	primeSet.set(1, max / 2);
	int limit = (int) Math.sqrt(max);
	for (int i = 3; i <= limit; i += 2) {
		if (!primeSet.get(i / 2)) {
			continue;
		}
		for (int j = i * i; j < max; j += i * 2) {
			primeSet.clear(j / 2);
		}
	}
	ArrayList<Integer> list = new ArrayList<Integer>();
	list.add(2);
	for (int i = primeSet.nextSetBit(0); i >= 0; i = primeSet.nextSetBit(i + 1)) {
		list.add(i * 2 + 1);
	}
	return list;
}
 
开发者ID:tomerun,项目名称:CompLib,代码行数:23,代码来源:Prime.java

示例5: checkClickAndType

import java.util.BitSet; //导入方法依赖的package包/类
void checkClickAndType(int x, int y, BitSet bits){
    bits.clear(0, 10);

    robot.mouseMove(x, y);
    robot.click();
    robot.dragAndDrop(MouseInfo.getPointerInfo().getLocation(), new Point(x+5, y));
    robot.mouseWheel(1);
    robot.waitForIdle();

    robot.type('a');

    robot.mouseMove(350, 50);
    robot.waitForIdle();

    //robot.delay(20*1000);
    if (!bits.equals(reference)){
        for( int i = 0; i < 11; i++)
            System.err.print(( bits.get(i) ? 1 : 0 ) + ", ");
        System.err.println();
        throw new RuntimeException("Bit mask is not fully set: "+bits);
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:23,代码来源:ShapedTranslucentWindowClick.java

示例6: isFinite

import java.util.BitSet; //导入方法依赖的package包/类
/**
 * Checks whether there is a loop containing state. (This is sufficient since
 * there are never transitions to dead states.)
 */
// TODO: not great that this is recursive... in theory a
// large automata could exceed java's stack
private static boolean isFinite(Transition scratch, Automaton a, int state, BitSet path, BitSet visited) {
  path.set(state);
  int numTransitions = a.initTransition(state, scratch);
  for(int t=0;t<numTransitions;t++) {
    a.getTransition(state, t, scratch);
    if (path.get(scratch.dest) || (!visited.get(scratch.dest) && !isFinite(scratch, a, scratch.dest, path, visited))) {
      return false;
    }
  }
  path.clear(state);
  visited.set(state);
  return true;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:20,代码来源:Operations.java

示例7: resolveDataFlow0

import java.util.BitSet; //导入方法依赖的package包/类
protected void resolveDataFlow0(MoveResolver moveResolver, BitSet blockCompleted) {
    BitSet alreadyResolved = new BitSet(allocator.blockCount());
    for (AbstractBlockBase<?> fromBlock : allocator.sortedBlocks()) {
        if (!blockCompleted.get(fromBlock.getLinearScanNumber())) {
            alreadyResolved.clear();
            alreadyResolved.or(blockCompleted);

            for (AbstractBlockBase<?> toBlock : fromBlock.getSuccessors()) {

                /*
                 * Check for duplicate edges between the same blocks (can happen with switch
                 * blocks).
                 */
                if (!alreadyResolved.get(toBlock.getLinearScanNumber())) {
                    DebugContext debug = allocator.getDebug();
                    if (debug.isLogEnabled()) {
                        debug.log("processing edge between B%d and B%d", fromBlock.getId(), toBlock.getId());
                    }

                    alreadyResolved.set(toBlock.getLinearScanNumber());

                    // collect all intervals that have been split between
                    // fromBlock and toBlock
                    resolveCollectMappings(fromBlock, toBlock, null, moveResolver);
                    if (moveResolver.hasMappings()) {
                        resolveFindInsertPos(fromBlock, toBlock, moveResolver);
                        moveResolver.resolveAndAppendMoves();
                    }
                }
            }
        }
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:34,代码来源:LinearScanResolveDataFlowPhase.java

示例8: setUp

import java.util.BitSet; //导入方法依赖的package包/类
@BeforeExperiment
protected void setUp() {
  BitSet bitSet = new BitSet();
  for (int i = 0; i < OLD_WHITESPACE_TABLE.length(); i++) {
    bitSet.set(OLD_WHITESPACE_TABLE.charAt(i));
  }
  bitSet.clear(0);
  bitSet.clear(1);
  matcher = useNew ? CharMatcher.whitespace() : OLD_WHITESPACE;
  teststring = newTestString(new Random(1), bitSet, percentMatching);
}
 
开发者ID:paul-hammant,项目名称:googles-monorepo-demo,代码行数:12,代码来源:WhitespaceMatcherBenchmark.java

示例9: addPathToLinearScanOrder

import java.util.BitSet; //导入方法依赖的package包/类
/**
 * Add a linear path to the linear scan order greedily following the most likely successor.
 */
private static <T extends AbstractBlockBase<T>> T addPathToLinearScanOrder(T block, List<T> order, PriorityQueue<T> worklist, BitSet visitedBlocks) {
    block.setLinearScanNumber(order.size());
    order.add(block);
    T mostLikelySuccessor = findAndMarkMostLikelySuccessor(block, visitedBlocks);
    enqueueSuccessors(block, worklist, visitedBlocks);
    if (mostLikelySuccessor != null) {
        if (!mostLikelySuccessor.isLoopHeader() && mostLikelySuccessor.getPredecessorCount() > 1) {
            // We are at a merge. Check probabilities of predecessors that are not yet
            // scheduled.
            double unscheduledSum = 0.0;
            for (T pred : mostLikelySuccessor.getPredecessors()) {
                if (pred.getLinearScanNumber() == -1) {
                    unscheduledSum += pred.probability();
                }
            }

            if (unscheduledSum > block.probability() / PENALTY_VERSUS_UNSCHEDULED) {
                // Add this merge only after at least one additional predecessor gets scheduled.
                visitedBlocks.clear(mostLikelySuccessor.getId());
                return null;
            }
        }
        return mostLikelySuccessor;
    }
    return null;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:30,代码来源:ComputeBlockOrder.java

示例10: deleteRelation

import java.util.BitSet; //导入方法依赖的package包/类
/**
 * Deletes the specified relation.
 * 
 * @param relation the relation to be deleted.
 * @return <code>true</code> if the given relation was deleted, or
 *         <code>false</code> if it was not found.
 */
public boolean deleteRelation(Relation relation) {

  // don't do anything if this relation isn't part of this set
  if(!indexById.containsValue(relation)) return false;

  // find all relations which include the annotation and remove them
  for(Relation r : getReferencing(relation.getId())) {
    deleteRelation(r);
  }

  // delete this relation from the type index
  indexByType.get(relation.getType()).clear(relation.getId());

  // delete this relation from the ID index
  indexById.remove(relation.getId());

  // delete from the member index
  for(int memeberPos = 0; memeberPos < relation.getMembers().length; memeberPos++) {
    int member = relation.getMembers()[memeberPos];

    Map<Integer, BitSet> indexByMember = indexesByMember.get(memeberPos);
    BitSet sameMember = indexByMember.get(member);
    sameMember.clear(relation.getId());
  }

  // notify anyone who cares enough to listen that we have deleted a
  // relation
  fireRelationRemoved(new RelationSetEvent(this,
          RelationSetEvent.RELATION_REMOVED, relation));
  return true;

}
 
开发者ID:GateNLP,项目名称:gate-core,代码行数:40,代码来源:RelationSet.java

示例11: start

import java.util.BitSet; //导入方法依赖的package包/类
/**
 * Initializes the collating state if it hasn't been already.
 */
private void start() {
    if (values == null) {
        values = new ArrayList<E>(iterators.size());
        valueSet = new BitSet(iterators.size());
        for (int i = 0; i < iterators.size(); i++) {
            values.add(null);
            valueSet.clear(i);
        }
    }
}
 
开发者ID:funkemunky,项目名称:HCFCore,代码行数:14,代码来源:CollatingIterator.java

示例12: processDef

import java.util.BitSet; //导入方法依赖的package包/类
private void processDef(final BitSet liveGen, LIRInstruction op, Value operand) {
    if (isVariable(operand)) {
        recordVariable(op, asVariable(operand));
        int operandNum = operandNumber(operand);
        if (operands[operandNum] == null) {
            operands[operandNum] = operand;
        }
        liveGen.clear(operandNum);
        DebugContext debug = lir.getDebug();
        if (debug.isLogEnabled()) {
            debug.log(LOG_LEVEL, "liveKill for operand %d(%s)", operandNum, operand);
        }
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:15,代码来源:GlobalLivenessAnalysisPhase.java

示例13: remove

import java.util.BitSet; //导入方法依赖的package包/类
void remove(NavigableSet<Integer> set, int element, BitSet bs) {
    if (set.remove(element))
        bs.clear(element);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:5,代码来源:ConcurrentSkipListSetTest.java

示例14: postDominanceAnalysis

import java.util.BitSet; //导入方法依赖的package包/类
/**
 * Performs the post dominance analysis (finds the post-dominance tree).
 */
private void postDominanceAnalysis() {
	// Some help sets
	BitSet defined = new BitSet(edges.size());
	BitSet out = new BitSet(edges.size());

	// Get the end edge
	Edge endEdge = edges
			.get(incoming[graph.getEnd().getId()].nextSetBit(0));
	endEdge.postDominatorList.add(endEdge);
	defined.set(endEdge.id);
	postReversePostOrder.removeFirst();

	boolean stable;
	do {
		stable = true;
		for (Edge e : postReversePostOrder) {
			// An edge is visited
			edgesVisited++;

			out.clear();
			out.or(outgoing[e.tgt.getId()]);
			out.and(defined);

			int j = out.nextSetBit(0);
			if (j >= 0) {
				Edge idom = edges.get(j);
				for (j = out.nextSetBit(j + 1); j >= 0; j = out
						.nextSetBit(j + 1)) {
					// An edge is visited
					edgesVisited++;

					idom = intersect(edges.get(j), idom);
				}
				if (!defined.get(e.id)) {
					defined.set(e.id);
					e.postDominatorList.addLast(idom);
					stable = false;
				} else {
					Edge idomOld = e.postDominatorList.getLast();
					if (idomOld.postPostOrderNumber != idom.postPostOrderNumber) {
						e.postDominatorList.addLast(idom);
						stable = false;
					}
				}
			}
		}
	} while (!stable);
}
 
开发者ID:guybrushPrince,项目名称:mojo.core,代码行数:52,代码来源:PostDominatorEdgeAnalysis.java

示例15: hasGapsToFix

import java.util.BitSet; //导入方法依赖的package包/类
/**
 * Checks for gaps if we've reached to the top of the list.
 * <p>
 * Intermediate gaps created by full span items are tracked via mLaidOutInvalidFullSpan field.
 */
View hasGapsToFix() {
    int startChildIndex = 0;
    int endChildIndex = getChildCount() - 1;
    BitSet mSpansToCheck = new BitSet(mSpanCount);
    mSpansToCheck.set(0, mSpanCount, true);

    final int firstChildIndex, childLimit;
    final int preferredSpanDir = mOrientation == VERTICAL && isLayoutRTL() ? 1 : -1;

    if (mShouldReverseLayout) {
        firstChildIndex = endChildIndex;
        childLimit = startChildIndex - 1;
    } else {
        firstChildIndex = startChildIndex;
        childLimit = endChildIndex + 1;
    }
    final int nextChildDiff = firstChildIndex < childLimit ? 1 : -1;
    for (int i = firstChildIndex; i != childLimit; i += nextChildDiff) {
        View child = getChildAt(i);
        LayoutParams lp = (LayoutParams) child.getLayoutParams();
        if (mSpansToCheck.get(lp.mSpan.mIndex)) {
            if (checkSpanForGap(lp.mSpan)) {
                return child;
            }
            mSpansToCheck.clear(lp.mSpan.mIndex);
        }
        if (lp.mFullSpan) {
            continue; // quick reject
        }

        if (i + nextChildDiff != childLimit) {
            View nextChild = getChildAt(i + nextChildDiff);
            boolean compareSpans = false;
            if (mShouldReverseLayout) {
                // ensure child's end is below nextChild's end
                int myEnd = mPrimaryOrientation.getDecoratedEnd(child);
                int nextEnd = mPrimaryOrientation.getDecoratedEnd(nextChild);
                if (myEnd < nextEnd) {
                    return child;//i should have a better position
                } else if (myEnd == nextEnd) {
                    compareSpans = true;
                }
            } else {
                int myStart = mPrimaryOrientation.getDecoratedStart(child);
                int nextStart = mPrimaryOrientation.getDecoratedStart(nextChild);
                if (myStart > nextStart) {
                    return child;//i should have a better position
                } else if (myStart == nextStart) {
                    compareSpans = true;
                }
            }
            if (compareSpans) {
                // equal, check span indices.
                LayoutParams nextLp = (LayoutParams) nextChild.getLayoutParams();
                if (lp.mSpan.mIndex - nextLp.mSpan.mIndex < 0 != preferredSpanDir < 0) {
                    return child;
                }
            }
        }
    }
    // everything looks good
    return null;
}
 
开发者ID:MLNO,项目名称:airgram,代码行数:69,代码来源:StaggeredGridLayoutManager.java


注:本文中的java.util.BitSet.clear方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。