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


Java BitSet.andNot方法代码示例

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


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

示例1: simpleExample

import java.util.BitSet; //导入方法依赖的package包/类
/**
 * 简单使用示例
 */
public static void simpleExample() {
	String names[] = { "Java", "Source", "and", "Support" };
	BitSet bits = new BitSet();
	for (int i = 0, n = names.length; i < n; i++) {
		if ((names[i].length() % 2) == 0) {
			bits.set(i);
		}
	}

	System.out.println(bits);
	System.out.println("Size : " + bits.size());
	System.out.println("Length: " + bits.length());
	for (int i = 0, n = names.length; i < n; i++) {
		if (!bits.get(i)) {
			System.out.println(names[i] + " is odd");
		}
	}
	BitSet bites = new BitSet();
	bites.set(0);
	bites.set(1);
	bites.set(2);
	bites.set(3);
	bites.andNot(bits);
	System.out.println(bites);
}
 
开发者ID:juebanlin,项目名称:util4j,代码行数:29,代码来源:BitSetDemo.java

示例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();

}
 
开发者ID:ampool,项目名称:monarch,代码行数:24,代码来源:RegionVersionHolderJUnitTest.java

示例3: computeInstantaneousRandomizedResponse

import java.util.BitSet; //导入方法依赖的package包/类
/**
 * Returns the instantaneous randomized response for the given bits.
 *
 * <p>The instantaneous response is NOT memoized -- it is sampled randomly on
 * every invocation.
 */
private BitSet computeInstantaneousRandomizedResponse(BitSet bits) {
  // Ensures that the input only has bits set in the lowest
  BitSet masked = new BitSet();
  masked.or(bits);
  masked.andNot(inputMask);
  checkArgument(masked.isEmpty(), "Input bits had bits set past Encoder's numBits limit.");

  if (probabilityP == 0.0 && probabilityQ == 1.0) {
    return bits;
  }

  BitSet response = new BitSet(numBits);
  for (int i = 0; i < numBits; i++) {
    boolean bit = bits.get(i);
    double probability = bit ? probabilityQ : probabilityP;
    boolean responseBit = random.nextFloat() < probability;
    response.set(i, responseBit);
  }
  return response;
}
 
开发者ID:cleaninsights,项目名称:cleaninsights-android-sdk,代码行数:27,代码来源:Encoder.java

示例4: depthFirstSearch

import java.util.BitSet; //导入方法依赖的package包/类
/**
 * This depth first search method searches in the inverse workflow graph
 * for all edges with a path without a post dominator.
 * 
 * @param current The current edge id.
 * @param pdom The (bit) set of post dominators.
 * @param waitingArea The (bit) set of the current waiting area.
 */
private void depthFirstSearch(int current, BitSet pdom, BitSet waitingArea) {
	// The current edge is part of the waiting area.
	waitingArea.set(current);
	// Look at the predecessor edges.
	Edge cur = edges.get(current);
	
	// Get a copy of the predecessors of the current edge
	BitSet predCopy = (BitSet) incoming[cur.src.getId()].clone();
	
	// Remove all edges within the waiting area
	predCopy.andNot(waitingArea);
	// Remove all edges which post dominates the outgoing edge
	predCopy.andNot(pdom);
	
	// Visit each other 
	for (int pred = predCopy.nextSetBit(0); 
			 pred >= 0; 
			 pred = predCopy.nextSetBit(pred + 1)) {
		depthFirstSearch(pred, pdom, waitingArea);
	}
}
 
开发者ID:guybrushPrince,项目名称:mojo.core,代码行数:30,代码来源:WaitingAreaAnalysis.java

示例5: 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;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:8,代码来源:Operations.java

示例6: 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;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:8,代码来源:Operations.java

示例7: updateLiveness

import java.util.BitSet; //导入方法依赖的package包/类
@Override
protected void updateLiveness(int blockID) {
    BitSet liveIn = localsLiveIn[blockID];
    liveIn.clear();
    liveIn.or(localsLiveOut[blockID]);
    liveIn.andNot(localsLiveKill[blockID]);
    liveIn.or(localsLiveGen[blockID]);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:9,代码来源:LargeLocalLiveness.java

示例8: depthFirstSearch

import java.util.BitSet; //导入方法依赖的package包/类
/**
 * Performs a depth first search on the `allowed` edges.
 * @param current The current edge.
 * @param allowed The allowed edges.
 * @param visited The already visited edges.
 */
private void depthFirstSearch(
		int current, 
		BitSet allowed, 
		BitSet visited) {
	edgesVisited++;
	visited.set(current);
	Edge e = this.edges.get(current);
	BitSet succ = (BitSet) this.outgoing[e.tgt.getId()].clone();
	succ.andNot(visited);
	succ.and(allowed);
	for (int s = succ.nextSetBit(0); s >= 0; s = succ.nextSetBit(s + 1)) {
		depthFirstSearch(s, allowed, visited);
	}
}
 
开发者ID:guybrushPrince,项目名称:mojo.core,代码行数:21,代码来源:AbundanceAnalysis.java

示例9: inverseDepthFirstSearch

import java.util.BitSet; //导入方法依赖的package包/类
/**
 * Searches all edges with currently a path to the edge.
 * 
 * @param current
 *            The current edge id.
 * @param last
 *            The last edge id (the outgoing edge of join).
 * @param notAllowed
 *            Removed edges.
 * @param visited
 *            The already visited edges.
 */
private void inverseDepthFirstSearch(int current, int last, BitSet allowed, BitSet visited) {
	// The current edge is visited
	visited.set(current);

	// An edge is visited
	edgesVisited++;

	// If we reach the outgoing edge (last) of the join
	// node, then we not visited the other edges since
	// we are in a deliver graph.
	if (current != last) {

		// Determine the edge
		Edge curEdge = edges.get(current);

		// Get the predecessors of the current edge
		BitSet predCopy = (BitSet) incoming[curEdge.src.getId()].clone();

		// Eliminate visited and not allowed edges
		predCopy.and(allowed);
		predCopy.andNot(visited);

		// Visited the rest predecessors
		for (int p = predCopy.nextSetBit(0); p >= 0; p = predCopy.nextSetBit(p + 1)) {
			inverseDepthFirstSearch(p, last, allowed, visited);
		}
	}
}
 
开发者ID:guybrushPrince,项目名称:mojo.core,代码行数:41,代码来源:DeadlockAnalysis.java

示例10: getPathsToJoin

import java.util.BitSet; //导入方法依赖的package包/类
/**
 * Determine the paths to the join from the edges which reaches the start or
 * outgoing edge of the join without passing a appr. exec. edge
 * 
 * @param current
 *            The current edge on path
 * @param incoming
 *            The incoming edge of the join node to reach.
 * @param visited
 *            The visited edges.
 * @param splits
 *            The split and or-splits reached.
 */
private void getPathsToJoin(int current, int incoming, BitSet visited, List<WGNode> splits) {

	// An edge is visited
	edgesVisited++;

	if (current != incoming) {

		// Get the current edge
		Edge curEdge = edges.get(current);

		// Get the successors of the current edge
		BitSet succCopy = (BitSet) outgoing[curEdge.tgt.getId()].clone();

		// Remove already visited edges
		succCopy.andNot(visited);

		for (int s = succCopy.nextSetBit(0); s >= 0; s = succCopy.nextSetBit(s + 1)) {
			// Get the successor edge
			Edge succ = edges.get(s);

			// Add the source if it is a (or-)split
			if (succ.src.getType() == Type.SPLIT || succ.src.getType() == Type.OR_FORK) {

				splits.add(succ.src);
			}

			// If the successor has a path to the incoming edge,
			// then visit it.
			if (succ.deadlockInformation.get(incoming)) {
				// The successor edge is visited
				visited.set(s);

				getPathsToJoin(s, incoming, visited, splits);
			}
		}
	}
}
 
开发者ID:guybrushPrince,项目名称:mojo.core,代码行数:51,代码来源:DeadlockAnalysis.java

示例11: postDepthFirstSearch

import java.util.BitSet; //导入方法依赖的package包/类
/**
 * Perform a simple depth first search to produce the post reverse post
 * order.
 * 
 * @param e
 *            The current edge of the search.
 * @param visited
 *            The visited edges.
 */
private void postDepthFirstSearch(Edge e, BitSet visited) {
	// An edge is visited
	edgesVisited++;

	visited.set(e.id);
	BitSet in = (BitSet) (incoming[e.src.getId()]).clone();
	in.andNot(visited);
	for (int i = in.nextSetBit(0); i >= 0; i = in.nextSetBit(i + 1)) {
		postDepthFirstSearch(edges.get(i), visited);
	}
	e.postPostOrderNumber = postReversePostOrder.size();
	postReversePostOrder.addFirst(e);
}
 
开发者ID:guybrushPrince,项目名称:mojo.core,代码行数:23,代码来源:PostDominatorEdgeAnalysis.java

示例12: depthFirstSearch

import java.util.BitSet; //导入方法依赖的package包/类
/**
 * Perform a simple depth first search to produce the reverse post order.
 * 
 * @param e
 *            The current edge of the search.
 * @param visited
 *            The visited edges.
 */
private void depthFirstSearch(Edge e, BitSet visited) {
	// A edge is visited
	edgesVisited++;

	visited.set(e.id);
	BitSet out = (BitSet) (outgoing[e.tgt.getId()]).clone();
	out.andNot(visited);
	for (int i = out.nextSetBit(0); i >= 0; i = out.nextSetBit(i + 1)) {
		depthFirstSearch(edges.get(i), visited);
	}
	e.postOrderNumber = reversePostOrder.size();
	reversePostOrder.addFirst(e);
}
 
开发者ID:guybrushPrince,项目名称:mojo.core,代码行数:22,代码来源:DominatorEdgeAnalysis.java

示例13: 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();
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:6,代码来源:DefaultMXBeanMappingFactory.java

示例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();
}
 
开发者ID:ampool,项目名称:monarch,代码行数:6,代码来源:OpenTypeConverter.java

示例15: bitSetTests

import java.util.BitSet; //导入方法依赖的package包/类
@Test
public void bitSetTests() {
  BitSet set = new BitSet(10);
  set.set(0, 5);
  set.set(7);
  System.out.println("MTableStorageFormatterTest.bitSetTests :: " + "len: " + set.length()
      + " card " + set.cardinality());

  set.set(0, 10);
  for (int i = 0; i < 10; i++) {
    System.out.println("MTableStorageFormatterTest.bitSetTests :: " + "Bit is set at ? " + i
        + " : " + set.get(i));
  }
  System.out.println("-------------------------------------------------------------------------");
  BitSet newSet = new BitSet(2);
  newSet.set(2);
  newSet.set(7);

  for (int i = 0; i < 10; i++) {
    System.out.println("MTableStorageFormatterTest.bitSetTests :: " + "Bit is set at ? " + i
        + " : " + newSet.get(i));
  }

  set.andNot(newSet);

  System.out.println("-------------------------------------------------------------------------");

  for (int i = 0; i < 10; i++) {
    System.out.println("MTableStorageFormatterTest.bitSetTests :: " + "Bit is set at ? " + i
        + " : " + set.get(i));
  }

  BitSet bits = new BitSet(3);
  bits.set(0);
  bits.set(1);
  bits.set(2);

  System.out.println("MTableStorageFormatterTest.bitSetTests :: 2395" + "bits " + bits);


}
 
开发者ID:ampool,项目名称:monarch,代码行数:42,代码来源:MTableStorageFormatterTest.java


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