Java Code Examples for java.util.BitSet#set()

The following examples show how to use java.util.BitSet#set() . 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: ConfigurationService.java    From xio with Apache License 2.0 6 votes vote down vote up
@Override
public void write(org.apache.thrift.protocol.TProtocol prot, addHttp1Rule_args struct)
    throws org.apache.thrift.TException {
  TTupleProtocol oprot = (TTupleProtocol) prot;
  BitSet optionals = new BitSet();
  if (struct.isSetHttp1Rule()) {
    optionals.set(0);
  }
  if (struct.isSetRuleType()) {
    optionals.set(1);
  }
  oprot.writeBitSet(optionals, 2);
  if (struct.isSetHttp1Rule()) {
    struct.http1Rule.write(oprot);
  }
  if (struct.isSetRuleType()) {
    oprot.writeI32(struct.ruleType.getValue());
  }
}
 
Example 2
Source File: OriginalMapFileContent.java    From settlers-remake with MIT License 6 votes vote down vote up
public void calculateBlockedPartitions() {
	MilliStopWatch watch = new MilliStopWatch();

	BitSet notBlockedSet = new BitSet(dataCount);

	for (int pos = 0; pos < dataCount; pos++) {
		notBlockedSet.set(pos, !landscapeType[pos].isBlocking);
	}

	PartitionCalculatorAlgorithm partitionCalculator = new PartitionCalculatorAlgorithm(0, 0, widthHeight, widthHeight, notBlockedSet,
			IBlockingProvider.DEFAULT_IMPLEMENTATION);
	partitionCalculator.calculatePartitions();

	for (short y = 0; y < widthHeight; y++) {
		for (short x = 0; x < widthHeight; x++) {
			blockedPartitions[x + widthHeight * y] = partitionCalculator.getPartitionAt(x, y);
		}
	}

	watch.stop("Calculating partitions needed");
	System.out.println("found " + partitionCalculator.getNumberOfPartitions() + " partitions.");
}
 
Example 3
Source File: QidResponse.java    From DDMQ with Apache License 2.0 6 votes vote down vote up
@Override
public void write(org.apache.thrift.protocol.TProtocol prot, QidResponse struct) throws org.apache.thrift.TException {
  TTupleProtocol oprot = (TTupleProtocol) prot;
  oprot.writeString(struct.topic);
  oprot.writeString(struct.qid);
  {
    oprot.writeI32(struct.messages.size());
    for (Message _iter58 : struct.messages)
    {
      _iter58.write(oprot);
    }
  }
  BitSet optionals = new BitSet();
  if (struct.isSetNextRequestOffset()) {
    optionals.set(0);
  }
  oprot.writeBitSet(optionals, 1);
  if (struct.isSetNextRequestOffset()) {
    oprot.writeI64(struct.nextRequestOffset);
  }
}
 
Example 4
Source File: SsaMethod.java    From java-n-IDE-for-Android with Apache License 2.0 5 votes vote down vote up
/**
 * Walks the basic block tree in depth-first order, calling the visitor
 * method once for every block. This depth-first walk may be run forward
 * from the method entry point or backwards from the method exit points.
 *
 * @param reverse true if this should walk backwards from the exit points
 * @param v {@code non-null;} callback interface. {@code parent} is set
 * unless this is the root node
 */
public void forEachBlockDepthFirst(boolean reverse,
        SsaBasicBlock.Visitor v) {
    BitSet visited = new BitSet(blocks.size());

    // We push the parent first, then the child on the stack.
    Stack<SsaBasicBlock> stack = new Stack<SsaBasicBlock>();

    SsaBasicBlock rootBlock = reverse ? getExitBlock() : getEntryBlock();

    if (rootBlock == null) {
        // in the case there's no exit block
        return;
    }

    stack.add(null);    // Start with null parent.
    stack.add(rootBlock);

    while (stack.size() > 0) {
        SsaBasicBlock cur = stack.pop();
        SsaBasicBlock parent = stack.pop();

        if (!visited.get(cur.getIndex())) {
            BitSet children
                = reverse ? cur.getPredecessors() : cur.getSuccessors();
            for (int i = children.nextSetBit(0); i >= 0
                    ; i = children.nextSetBit(i + 1)) {
                stack.add(cur);
                stack.add(blocks.get(i));
            }
            visited.set(cur.getIndex());
            v.visitBlock(cur, parent);
        }
    }
}
 
Example 5
Source File: RowMutation.java    From incubator-retired-blur with Apache License 2.0 5 votes vote down vote up
@Override
public void write(org.apache.blur.thirdparty.thrift_0_9_0.protocol.TProtocol prot, RowMutation struct) throws org.apache.blur.thirdparty.thrift_0_9_0.TException {
  TTupleProtocol oprot = (TTupleProtocol) prot;
  BitSet optionals = new BitSet();
  if (struct.isSetTable()) {
    optionals.set(0);
  }
  if (struct.isSetRowId()) {
    optionals.set(1);
  }
  if (struct.isSetRowMutationType()) {
    optionals.set(2);
  }
  if (struct.isSetRecordMutations()) {
    optionals.set(3);
  }
  oprot.writeBitSet(optionals, 4);
  if (struct.isSetTable()) {
    oprot.writeString(struct.table);
  }
  if (struct.isSetRowId()) {
    oprot.writeString(struct.rowId);
  }
  if (struct.isSetRowMutationType()) {
    oprot.writeI32(struct.rowMutationType.getValue());
  }
  if (struct.isSetRecordMutations()) {
    {
      oprot.writeI32(struct.recordMutations.size());
      for (RecordMutation _iter122 : struct.recordMutations)
      {
        _iter122.write(oprot);
      }
    }
  }
}
 
Example 6
Source File: FSA.java    From morfologik-stemming with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/** Private recursion. */
private void visitInPreOrder(StateVisitor v, int node, BitSet visited) {
  if (visited.get(node)) {
    return;
  }
  visited.set(node);

  if (v.accept(node)) {
    for (int arc = getFirstArc(node); arc != 0; arc = getNextArc(arc)) {
      if (!isArcTerminal(arc)) {
        visitInPreOrder(v, getEndNode(arc), visited);
      }
    }
  }
}
 
Example 7
Source File: FetchResult.java    From incubator-retired-blur with Apache License 2.0 5 votes vote down vote up
@Override
public void write(org.apache.blur.thirdparty.thrift_0_9_0.protocol.TProtocol prot, FetchResult struct) throws org.apache.blur.thirdparty.thrift_0_9_0.TException {
  TTupleProtocol oprot = (TTupleProtocol) prot;
  BitSet optionals = new BitSet();
  if (struct.isSetExists()) {
    optionals.set(0);
  }
  if (struct.isSetDeleted()) {
    optionals.set(1);
  }
  if (struct.isSetTable()) {
    optionals.set(2);
  }
  if (struct.isSetRowResult()) {
    optionals.set(3);
  }
  if (struct.isSetRecordResult()) {
    optionals.set(4);
  }
  oprot.writeBitSet(optionals, 5);
  if (struct.isSetExists()) {
    oprot.writeBool(struct.exists);
  }
  if (struct.isSetDeleted()) {
    oprot.writeBool(struct.deleted);
  }
  if (struct.isSetTable()) {
    oprot.writeString(struct.table);
  }
  if (struct.isSetRowResult()) {
    struct.rowResult.write(oprot);
  }
  if (struct.isSetRecordResult()) {
    struct.recordResult.write(oprot);
  }
}
 
Example 8
Source File: ComponentFilter.java    From swing_library with MIT License 5 votes vote down vote up
@Override
public BitSet highlight(String filterText, String value) {
	BitSet ret = new BitSet(value.length());
	if (filterText != null && !filterText.isEmpty()) {
		if (!caseSensitive) {
			filterText = filterText.toLowerCase();
			value = value.toLowerCase();
		}
		if (accepts(filterText, value))
			ret.set(value.length() - filterText.length(), value.length());
	}
	return ret;
}
 
Example 9
Source File: IntSetTestUtility.java    From bytebuffer-collections with Apache License 2.0 5 votes vote down vote up
public static final BitSet createSimpleBitSet(Set<Integer> setBits){
  BitSet retval = new BitSet();
  for(int i : setBits){
    retval.set(i);
  }
  return retval;
}
 
Example 10
Source File: Form22s.java    From java-n-IDE-for-Android with Apache License 2.0 5 votes vote down vote up
/** {@inheritDoc} */
@Override
public BitSet compatibleRegs(DalvInsn insn) {
    RegisterSpecList regs = insn.getRegisters();
    BitSet bits = new BitSet(2);

    bits.set(0, unsignedFitsInNibble(regs.get(0).getReg()));
    bits.set(1, unsignedFitsInNibble(regs.get(1).getReg()));
    return bits;
}
 
Example 11
Source File: Pistachios.java    From Pistachio with Apache License 2.0 5 votes vote down vote up
@Override
public void write(org.apache.thrift.protocol.TProtocol prot, processEvent_result struct) throws org.apache.thrift.TException {
  TTupleProtocol oprot = (TTupleProtocol) prot;
  BitSet optionals = new BitSet();
  if (struct.isSetSuccess()) {
    optionals.set(0);
  }
  oprot.writeBitSet(optionals, 1);
  if (struct.isSetSuccess()) {
    oprot.writeBool(struct.success);
  }
}
 
Example 12
Source File: AbstractSlideExpandableListAdapter.java    From UltimateAndroid with Apache License 2.0 5 votes vote down vote up
/**
 * Utility methods to read and write a bitset from and to a Parcel
 */
private static BitSet readBitSet(Parcel src) {
    BitSet set = new BitSet();
    if (src == null) {
        return set;
    }
    int cardinality = src.readInt();


    for (int i = 0; i < cardinality; i++) {
        set.set(src.readInt());
    }

    return set;
}
 
Example 13
Source File: BINDER.java    From metanome-algorithms with Apache License 2.0 5 votes vote down vote up
private BitSet getActiveAttributeCombinations(BitSet previouslyActiveAttributeCombinations, Map<AttributeCombination, List<AttributeCombination>> naryDep2ref, List<AttributeCombination> attributeCombinations) {
	BitSet activeAttributeCombinations = new BitSet(attributeCombinations.size());
	for (int attribute = previouslyActiveAttributeCombinations.nextSetBit(0); attribute >= 0; attribute = previouslyActiveAttributeCombinations.nextSetBit(attribute + 1)) {
		AttributeCombination attributeCombination = attributeCombinations.get(attribute);
		if (naryDep2ref.containsKey(attributeCombination)) {
			// All attribute combinations referenced by this attribute are active
			for (AttributeCombination refAttributeCombination : naryDep2ref.get(attributeCombination))
				activeAttributeCombinations.set(attributeCombinations.indexOf(refAttributeCombination));
			// This attribute combination is active if it references any other attribute
			if (!naryDep2ref.get(attributeCombination).isEmpty())
				activeAttributeCombinations.set(attribute);
		}
	}
	return activeAttributeCombinations;
}
 
Example 14
Source File: TriangleUtilities.java    From constellation with Apache License 2.0 4 votes vote down vote up
public static Tuple<Float, Float> countTrianglesTriplets(final GraphReadMethods graph) {
    final int vxCount = graph.getVertexCount();
    BitSet[] allNeighbours = new BitSet[vxCount];
    BitSet update = new BitSet(vxCount);
    Float triangles = 0f;
    Float triplets = 0f;

    // initialise variables
    for (int vxPosition = 0; vxPosition < vxCount; vxPosition++) {

        allNeighbours[vxPosition] = new BitSet(vxCount);

        // get the vertex ID at this position
        final int vxId = graph.getVertex(vxPosition);

        // collect neighbours
        BitSet neighbours = new BitSet(vxCount);
        for (int neighbourPosition = 0; neighbourPosition < graph.getVertexNeighbourCount(vxId); neighbourPosition++) {
            final int nxId = graph.getVertexNeighbour(vxId, neighbourPosition);
            final int nxPosition = graph.getVertexPosition(nxId);
            neighbours.set(nxPosition, true);
        }

        //not interested in neighbours to themselves
        neighbours.set(vxPosition, false);

        allNeighbours[vxPosition].or(neighbours);
        update.set(vxPosition, true);
    }

    // checking for triangles
    for (int one = update.nextSetBit(0); one >= 0; one = update.nextSetBit(one + 1)) {
        for (int two = update.nextSetBit(one); two >= one; two = update.nextSetBit(two + 1)) {
            // are these two vertices connected?
            if (allNeighbours[one].get(two) && allNeighbours[two].get(one)) {
                // determine common neighbours between them, each one is a triangle
                BitSet intersection = new BitSet(vxCount);
                intersection.or(allNeighbours[one]);
                intersection.and(allNeighbours[two]);
                for (int three = intersection.nextSetBit(two); three >= two; three = intersection.nextSetBit(three + 1)) {
                    triangles += 1;
                }
                BitSet union = new BitSet(vxCount);
                union.or(allNeighbours[one]);
                union.or(allNeighbours[two]);
                union.set(one, false);
                union.set(two, false);
                for (int three = union.nextSetBit(two); three >= two; three = union.nextSetBit(three + 1)) {
                    triplets += 1;
                }
            }
        }
    }

    return new Tuple<>(triangles, triplets);
}
 
Example 15
Source File: DefaultTreeSelectionModel.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Returns true if the paths can be removed without breaking the
 * continuity of the model.
 * This is rather expensive.
 */
protected boolean canPathsBeRemoved(TreePath[] paths) {
    if(rowMapper == null || selection == null ||
       selectionMode == TreeSelectionModel.DISCONTIGUOUS_TREE_SELECTION)
        return true;
    else {
        BitSet               bitSet = new BitSet();
        int                  counter;
        int                  pathCount = paths.length;
        int                  anIndex;
        int                  min = -1;
        int                  validCount = 0;
        TreePath[]           tempPath = new TreePath[1];
        int[]                rows;

        /* Determine the rows for the removed entries. */
        lastPaths.clear();
        for (counter = 0; counter < pathCount; counter++) {
            if (paths[counter] != null) {
                lastPaths.put(paths[counter], Boolean.TRUE);
            }
        }
        for(counter = selection.length - 1; counter >= 0; counter--) {
            if(lastPaths.get(selection[counter]) == null) {
                tempPath[0] = selection[counter];
                rows = rowMapper.getRowsForPaths(tempPath);
                if(rows != null && rows[0] != -1 && !bitSet.get(rows[0])) {
                    validCount++;
                    if(min == -1)
                        min = rows[0];
                    else
                        min = Math.min(min, rows[0]);
                    bitSet.set(rows[0]);
                }
            }
        }
        lastPaths.clear();
        /* Make sure they are contiguous. */
        if(validCount > 1) {
            for(counter = min + validCount - 1; counter >= min;
                counter--)
                if(!bitSet.get(counter))
                    return false;
        }
    }
    return true;
}
 
Example 16
Source File: ClusterDetail.java    From galaxy-sdk-java with Apache License 2.0 4 votes vote down vote up
@Override
public void write(libthrift091.protocol.TProtocol prot, ClusterDetail struct) throws libthrift091.TException {
  TTupleProtocol oprot = (TTupleProtocol) prot;
  oprot.writeString(struct.clusterId);
  oprot.writeString(struct.ownerId);
  BitSet optionals = new BitSet();
  if (struct.isSetName()) {
    optionals.set(0);
  }
  if (struct.isSetRegion()) {
    optionals.set(1);
  }
  if (struct.isSetPurpose()) {
    optionals.set(2);
  }
  if (struct.isSetKeyPair()) {
    optionals.set(3);
  }
  if (struct.isSetAutoTerminate()) {
    optionals.set(4);
  }
  if (struct.isSetTerminationProtected()) {
    optionals.set(5);
  }
  if (struct.isSetInstanceGroups()) {
    optionals.set(6);
  }
  if (struct.isSetMasterPublicDnsName()) {
    optionals.set(7);
  }
  if (struct.isSetMasterPublicIpAddress()) {
    optionals.set(8);
  }
  if (struct.isSetClusterStatus()) {
    optionals.set(9);
  }
  if (struct.isSetSoftConfig()) {
    optionals.set(10);
  }
  oprot.writeBitSet(optionals, 11);
  if (struct.isSetName()) {
    oprot.writeString(struct.name);
  }
  if (struct.isSetRegion()) {
    oprot.writeString(struct.region);
  }
  if (struct.isSetPurpose()) {
    oprot.writeString(struct.purpose);
  }
  if (struct.isSetKeyPair()) {
    oprot.writeString(struct.keyPair);
  }
  if (struct.isSetAutoTerminate()) {
    oprot.writeBool(struct.autoTerminate);
  }
  if (struct.isSetTerminationProtected()) {
    oprot.writeBool(struct.terminationProtected);
  }
  if (struct.isSetInstanceGroups()) {
    {
      oprot.writeI32(struct.instanceGroups.size());
      for (InstanceGroupDetail _iter192 : struct.instanceGroups)
      {
        _iter192.write(oprot);
      }
    }
  }
  if (struct.isSetMasterPublicDnsName()) {
    oprot.writeString(struct.masterPublicDnsName);
  }
  if (struct.isSetMasterPublicIpAddress()) {
    oprot.writeString(struct.masterPublicIpAddress);
  }
  if (struct.isSetClusterStatus()) {
    struct.clusterStatus.write(oprot);
  }
  if (struct.isSetSoftConfig()) {
    struct.softConfig.write(oprot);
  }
}
 
Example 17
Source File: ResourceAllocationIndexPlugin.java    From constellation with Apache License 2.0 4 votes vote down vote up
@Override
public void edit(final GraphWriteMethods graph, final PluginInteraction interaction, final PluginParameters parameters) throws InterruptedException, PluginException {
    final boolean includeConnectionsIn = parameters.getBooleanValue(INCLUDE_CONNECTIONS_IN_PARAMETER_ID);
    final boolean includeConnectionsOut = parameters.getBooleanValue(INCLUDE_CONNECTIONS_OUT_PARAMETER_ID);
    final boolean treatUndirectedBidirectional = parameters.getBooleanValue(TREAT_UNDIRECTED_BIDIRECTIONAL_PARAMETER_ID);
    final int minCommonFeatures = parameters.getParameters().get(MINIMUM_COMMON_FEATURES_PARAMETER_ID).getIntegerValue();
    final boolean selectedOnly = parameters.getBooleanValue(SELECTED_ONLY_PARAMETER_ID);
    final boolean community = parameters.getBooleanValue(COMMUNITY_PARAMETER_ID);

    final int vertexSelectedAttributeId = VisualConcept.VertexAttribute.SELECTED.get(graph);

    // map each vertex to its neighbour count
    final int vertexCount = graph.getVertexCount();
    final BitSet[] neighbours = new BitSet[vertexCount];
    final BitSet update = new BitSet(vertexCount);
    final BitSet selected = new BitSet(vertexCount);
    for (int vertexPosition = 0; vertexPosition < vertexCount; vertexPosition++) {
        final int vertexId = graph.getVertex(vertexPosition);
        neighbours[vertexPosition] = new BitSet(vertexCount);
        for (int vertexNeighbourPosition = 0; vertexNeighbourPosition < graph.getVertexNeighbourCount(vertexId); vertexNeighbourPosition++) {
            final int neighbourId = graph.getVertexNeighbour(vertexId, vertexNeighbourPosition);
            final int neighbourPosition = graph.getVertexPosition(neighbourId);

            if (vertexPosition == neighbourPosition) {
                continue;
            }

            final int linkId = graph.getLink(vertexId, neighbourId);
            for (int linkEdgePosition = 0; linkEdgePosition < graph.getLinkEdgeCount(linkId); linkEdgePosition++) {
                final int edgeId = graph.getLinkEdge(linkId, linkEdgePosition);
                final int edgeDirection = graph.getEdgeDirection(edgeId);
                final boolean isRequestedDirection = (treatUndirectedBidirectional && edgeDirection == GraphConstants.UNDIRECTED
                        || includeConnectionsIn && graph.getEdgeDestinationVertex(edgeId) == neighbourId
                        || includeConnectionsOut && graph.getEdgeSourceVertex(edgeId) == neighbourId);
                if (isRequestedDirection) {
                    if (!SimilarityUtilities.checkEdgeTypes(graph, edgeId)) {
                        continue;
                    }
                    neighbours[vertexPosition].set(neighbourPosition, true);
                    update.set(vertexPosition, true);
                }
            }
        }
        final boolean vertexSelected = graph.getBooleanValue(vertexSelectedAttributeId, vertexId);
        selected.set(vertexPosition, vertexSelected);
    }

    // calculate resource allocation index for every pair of vertices on the graph
    final Map<Tuple<Integer, Integer>, Float> raiScores = new HashMap<>();
    for (int vertexOnePosition = update.nextSetBit(0); vertexOnePosition >= 0; vertexOnePosition = update.nextSetBit(vertexOnePosition + 1)) {
        for (int vertexTwoPosition = update.nextSetBit(0); vertexTwoPosition >= 0; vertexTwoPosition = update.nextSetBit(vertexTwoPosition + 1)) {
            if (!selectedOnly || (selected.get(vertexOnePosition) || selected.get(vertexTwoPosition))) {
                if (vertexOnePosition >= vertexTwoPosition) {
                    continue;
                }

                if (community && (!selected.get(vertexOnePosition) || !selected.get(vertexTwoPosition))) {
                    continue;
                }

                final BitSet intersection = (BitSet) neighbours[vertexOnePosition].clone();
                intersection.and(neighbours[vertexTwoPosition]);
                intersection.set(vertexOnePosition, false);
                intersection.set(vertexTwoPosition, false);

                if (intersection.cardinality() < minCommonFeatures) {
                    continue;
                }

                final int vertexOneId = graph.getVertex(vertexOnePosition);
                final int vertexTwoId = graph.getVertex(vertexTwoPosition);
                float sum = 0f;
                for (int commonNeighbour = intersection.nextSetBit(0); commonNeighbour >= 0; commonNeighbour = intersection.nextSetBit(commonNeighbour + 1)) {
                    sum += (1f / graph.getVertexNeighbourCount(graph.getVertex(commonNeighbour)));
                }

                raiScores.put(Tuple.create(vertexOneId, vertexTwoId), sum);
            }
        }
    }

    // update the graph with resource allocation index values
    SimilarityUtilities.addScoresToGraph(graph, raiScores, RESOURCE_ALLOCATION_INDEX_ATTRIBUTE);
    // complete with schema
    PluginExecution.withPlugin(VisualSchemaPluginRegistry.COMPLETE_SCHEMA).executeNow(graph);
}
 
Example 18
Source File: Validator.java    From metanome-algorithms with Apache License 2.0 4 votes vote down vote up
public ValidationResult call() throws Exception {
	ValidationResult result = new ValidationResult();
	
	FDTreeElement element = this.elementLhsPair.getElement();
	BitSet lhs = this.elementLhsPair.getLhs();
	BitSet rhs = element.getFds();
	
	int rhsSize = rhs.cardinality();
	if (rhsSize == 0)
		return result;
	result.validations = result.validations + rhsSize;
	
	if (Validator.this.level == 0) {
		// Check if rhs is unique
		for (int rhsAttr = rhs.nextSetBit(0); rhsAttr >= 0; rhsAttr = rhs.nextSetBit(rhsAttr + 1)) {
			if (!Validator.this.plis.get(rhsAttr).isConstant(Validator.this.numRecords)) {
				element.removeFd(rhsAttr);
				result.invalidFDs.add(new FD(lhs, rhsAttr));
			}
			result.intersections++;
		}
	}
	else if (Validator.this.level == 1) {
		// Check if lhs from plis refines rhs
		int lhsAttribute = lhs.nextSetBit(0);
		for (int rhsAttr = rhs.nextSetBit(0); rhsAttr >= 0; rhsAttr = rhs.nextSetBit(rhsAttr + 1)) {
			if (!Validator.this.plis.get(lhsAttribute).refines(Validator.this.compressedRecords, rhsAttr)) {
				element.removeFd(rhsAttr);
				result.invalidFDs.add(new FD(lhs, rhsAttr));
			}
			result.intersections++;
		}
	}
	else {
		// Check if lhs from plis plus remaining inverted plis refines rhs
		int firstLhsAttr = lhs.nextSetBit(0);
		
		lhs.clear(firstLhsAttr);
		BitSet validRhs = Validator.this.plis.get(firstLhsAttr).refines(Validator.this.compressedRecords, lhs, rhs, result.comparisonSuggestions);
		lhs.set(firstLhsAttr);
		
		result.intersections++;
		
		rhs.andNot(validRhs); // Now contains all invalid FDs
		element.setFds(validRhs); // Sets the valid FDs in the FD tree
		
		for (int rhsAttr = rhs.nextSetBit(0); rhsAttr >= 0; rhsAttr = rhs.nextSetBit(rhsAttr + 1))
			result.invalidFDs.add(new FD(lhs, rhsAttr));
	}
	return result;
}
 
Example 19
Source File: SsaBasicBlock.java    From javaide with GNU General Public License v3.0 3 votes vote down vote up
/**
 * Sets the register as used in a bitset, taking into account its
 * category/width.
 *
 * @param regsUsed set, indexed by register number
 * @param rs register to mark as used
 */
private static void setRegsUsed (BitSet regsUsed, RegisterSpec rs) {
    regsUsed.set(rs.getReg());
    if (rs.getCategory() > 1) {
        regsUsed.set(rs.getReg() + 1);
    }
}
 
Example 20
Source File: Coverage.java    From joshua with Apache License 2.0 3 votes vote down vote up
/**
 * Tests whether a new range is compatible with the current coverage vector. It must be after
 * the first uncovered word, obviously, and must not conflict with spans after the first
 * uncovered word.
 * 
 * @param begin the begin index (absolute)
 * @param end the end index (absolute)
 * @return true if the span is compatible with the coverage vector
 */
public boolean compatible(int begin, int end) {
  if (begin >= firstZero) {
    BitSet pattern = new BitSet();
    pattern.set(begin - firstZero, end - firstZero);
    return ! bits.intersects(pattern);
  }
  return false;
}