本文整理汇总了Java中java.util.BitSet类的典型用法代码示例。如果您正苦于以下问题:Java BitSet类的具体用法?Java BitSet怎么用?Java BitSet使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
BitSet类属于java.util包,在下文中一共展示了BitSet类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: write
import java.util.BitSet; //导入依赖的package包/类
@Override
public void write(org.apache.thrift.protocol.TProtocol prot, scannerOpenWithStop_result struct) throws org.apache.thrift.TException {
TTupleProtocol oprot = (TTupleProtocol) prot;
BitSet optionals = new BitSet();
if (struct.isSetSuccess()) {
optionals.set(0);
}
if (struct.isSetIo()) {
optionals.set(1);
}
oprot.writeBitSet(optionals, 2);
if (struct.isSetSuccess()) {
oprot.writeI32(struct.success);
}
if (struct.isSetIo()) {
struct.io.write(oprot);
}
}
示例2: read
import java.util.BitSet; //导入依赖的package包/类
@Override
public void read(org.apache.thrift.protocol.TProtocol prot, PutRequestMessage struct) throws org.apache.thrift.TException {
TTupleProtocol iprot = (TTupleProtocol) prot;
struct.header = new AsyncMessageHeader();
struct.header.read(iprot);
struct.setHeaderIsSet(true);
struct.storeName = iprot.readString();
struct.setStoreNameIsSet(true);
struct.key = iprot.readBinary();
struct.setKeyIsSet(true);
BitSet incoming = iprot.readBitSet(2);
if (incoming.get(0)) {
struct.versionedValue = new VersionedValue();
struct.versionedValue.read(iprot);
struct.setVersionedValueIsSet(true);
}
if (incoming.get(1)) {
struct.value = iprot.readBinary();
struct.setValueIsSet(true);
}
}
示例3: compatibleRegs
import java.util.BitSet; //导入依赖的package包/类
/** {@inheritDoc} */
@Override
public BitSet compatibleRegs(DalvInsn insn) {
RegisterSpecList regs = insn.getRegisters();
int sz = regs.size();
BitSet bits = new BitSet(sz);
boolean compat = unsignedFitsInByte(regs.get(0).getReg());
if (sz == 1) {
bits.set(0, compat);
} else {
if (regs.get(0).getReg() == regs.get(1).getReg()) {
bits.set(0, compat);
bits.set(1, compat);
}
}
return bits;
}
示例4: a
import java.util.BitSet; //导入依赖的package包/类
public void a(cy cyVar, au auVar) throws cf {
de deVar = (de) cyVar;
deVar.a(auVar.a);
deVar.a(auVar.b);
deVar.a(auVar.c.size());
for (Entry entry : auVar.c.entrySet()) {
deVar.a((String) entry.getKey());
deVar.a((String) entry.getValue());
}
BitSet bitSet = new BitSet();
if (auVar.p()) {
bitSet.set(0);
}
if (auVar.s()) {
bitSet.set(1);
}
deVar.a(bitSet, 2);
if (auVar.p()) {
deVar.a(auVar.d);
}
if (auVar.s()) {
deVar.a(auVar.e);
}
}
示例5: indexOfFirstNotInSet
import java.util.BitSet; //导入依赖的package包/类
private static int indexOfFirstNotInSet(String s, BitSet set,
int fromIndex) {
final int slen = s.length();
int i = fromIndex;
while (true) {
if (i >= slen)
break;
char c = s.charAt(i);
if (c >= 128)
break; // not ASCII
if (!set.get(c))
break;
i++;
}
return i;
}
示例6: parseToken
import java.util.BitSet; //导入依赖的package包/类
/**
* Extracts from the sequence of chars a token terminated with any of the given delimiters
* discarding semantically insignificant whitespace characters.
*
* @param buf buffer with the sequence of chars to be parsed
* @param cursor defines the bounds and current position of the buffer
* @param delimiters set of delimiting characters. Can be {@code null} if the token
* is not delimited by any character.
*/
public String parseToken(final ru.radiomayak.http.util.CharArrayBuffer buf, final ParserCursor cursor, final BitSet delimiters) {
final StringBuilder dst = new StringBuilder();
boolean whitespace = false;
while (!cursor.atEnd()) {
final char current = buf.charAt(cursor.getPos());
if (delimiters != null && delimiters.get(current)) {
break;
} else if (isWhitespace(current)) {
skipWhiteSpace(buf, cursor);
whitespace = true;
} else {
if (whitespace && dst.length() > 0) {
dst.append(' ');
}
copyContent(buf, cursor, delimiters, dst);
whitespace = false;
}
}
return dst.toString();
}
示例7: a
import java.util.BitSet; //导入依赖的package包/类
public void a(cy cyVar, bq bqVar) throws cf {
de deVar = (de) cyVar;
deVar.a(bqVar.a);
deVar.a(bqVar.b);
deVar.a(bqVar.c);
deVar.a(bqVar.d);
deVar.a(bqVar.e);
deVar.a(bqVar.f);
deVar.a(bqVar.g);
deVar.a(bqVar.h);
deVar.a(bqVar.i);
BitSet bitSet = new BitSet();
if (bqVar.H()) {
bitSet.set(0);
}
deVar.a(bitSet, 1);
if (bqVar.H()) {
deVar.a(bqVar.j);
}
}
示例8: getLiveStatesFromInitial
import java.util.BitSet; //导入依赖的package包/类
/** Returns bitset marking states reachable from the initial state. */
private static BitSet getLiveStatesFromInitial(Automaton a) {
int numStates = a.getNumStates();
BitSet live = new BitSet(numStates);
if (numStates == 0) {
return live;
}
LinkedList<Integer> workList = new LinkedList<>();
live.set(0);
workList.add(0);
Transition t = new Transition();
while (workList.isEmpty() == false) {
int s = workList.removeFirst();
int count = a.initTransition(s, t);
for(int i=0;i<count;i++) {
a.getNextTransition(t);
if (live.get(t.dest) == false) {
live.set(t.dest);
workList.add(t.dest);
}
}
}
return live;
}
示例9: write
import java.util.BitSet; //导入依赖的package包/类
@Override
public void write(org.apache.thrift.protocol.TProtocol prot, TResult struct) throws org.apache.thrift.TException {
TTupleProtocol oprot = (TTupleProtocol) prot;
{
oprot.writeI32(struct.columnValues.size());
for (TColumnValue _iter4 : struct.columnValues)
{
_iter4.write(oprot);
}
}
BitSet optionals = new BitSet();
if (struct.isSetRow()) {
optionals.set(0);
}
oprot.writeBitSet(optionals, 1);
if (struct.isSetRow()) {
oprot.writeBinary(struct.row);
}
}
示例10: getMessageForConsistency
import java.util.BitSet; //导入依赖的package包/类
/**
* Utility in charge of creating the message when the class is not
* consistent within a specific context
*
* @param minBitset
* bitset describing which CIM attributes of this class have
* to be set so that it is consistent within a
* specific subset context
* @return the message explaining what is not consistent
*/
private String getMessageForConsistency(final BitSet minBitset) {
StringBuilder message = new StringBuilder(
"Instance of \"ConnectivityNodeContainer\" of id \"");
message.append(this.getId());
message.append("\" is not consistent in this context:\n");
/*
* XOR and then AND
* The result is :
* "1" : has not been set and need to be
* "0" : has been set or is not mandatory
*/
BitSet isNotSet = new BitSet(minBitset.length());
isNotSet.or(minBitset);
// we create a copy of minBitset
isNotSet.xor(this.currentBitset);
isNotSet.and(minBitset);
if (isNotSet.get(0)) {
message.append("\t\"TopologicalNode\" needs to be set\n");
}
return message.toString();
}
示例11: NetworkGraph
import java.util.BitSet; //导入依赖的package包/类
/**
* The constructor.
*
* @param graph
* The workflow graph.
* @param nodeMap
* The map of nodes.
* @param information
* The information for analysis.
*/
public NetworkGraph(WorkflowGraph graph, WGNode[] nodeMap, AnalysisInformation information) {
super(graph, nodeMap, information);
this.edges = new NetworkEdge[graph.getEdges().size()];
this.replaced = new BitSet(this.edges.length);
int max = 0;
BitSet forkSet = (BitSet) graph.getForkSet().clone();
forkSet.or(graph.getOrForkSet());
BitSet[] outgoing = graph.getOutgoingEdges();
// Determine the maximum number of outgoing edges of forks
for (int f = forkSet.nextSetBit(0); f >= 0; f = forkSet.nextSetBit(f + 1)) {
max = Math.max(outgoing[f].cardinality(), max);
}
this.maxAdditionalEdges = edges.length + max * 2;
this.tmpEdges = new NetworkEdge[maxAdditionalEdges];
int maxAdditionalNodes = nodeMap.length + max + 1;
this.incoming = new BitSet[maxAdditionalNodes];
this.outgoing = new BitSet[maxAdditionalNodes];
this.capacities = new BitSet(maxAdditionalEdges);
this.currentFlow = new BitSet(maxAdditionalEdges);
initialize();
}
示例12: read
import java.util.BitSet; //导入依赖的package包/类
@Override
public void read(org.apache.thrift.protocol.TProtocol prot, ProcessData struct) throws TException {
TTupleProtocol iprot = (TTupleProtocol) prot;
BitSet incoming = iprot.readBitSet(4);
if (incoming.get(0)) {
struct.type = iprot.readI32();
struct.setTypeIsSet(true);
}
if (incoming.get(1)) {
struct.crcCode = iprot.readI32();
struct.setCrcCodeIsSet(true);
}
if (incoming.get(2)) {
struct.length = iprot.readI32();
struct.setLengthIsSet(true);
}
if (incoming.get(3)) {
struct.sessionId = iprot.readI64();
struct.setSessionIdIsSet(true);
}
}
示例13: 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);
}
示例14: read
import java.util.BitSet; //导入依赖的package包/类
@Override
public void read(org.apache.thrift.protocol.TProtocol prot, HelloMessage struct) throws org.apache.thrift.TException {
TTupleProtocol iprot = (TTupleProtocol) prot;
struct.header = new AsyncMessageHeader();
struct.header.read(iprot);
struct.setHeaderIsSet(true);
BitSet incoming = iprot.readBitSet(3);
if (incoming.get(0)) {
struct.nodeId = iprot.readI16();
struct.setNodeIdIsSet(true);
}
if (incoming.get(1)) {
struct.authScheme = AuthScheme.findByValue(iprot.readI32());
struct.setAuthSchemeIsSet(true);
}
if (incoming.get(2)) {
struct.authChallengeResponse = new AuthChallengeResponse();
struct.authChallengeResponse.read(iprot);
struct.setAuthChallengeResponseIsSet(true);
}
}
示例15: changePositon2
import java.util.BitSet; //导入依赖的package包/类
@Test
public void changePositon2(){
BitSet bitm =new BitSet(16);
bitm.set(6);
bitm.set(5);
System.out.println(bitm);
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);
System.out.println(bitm.size());
System.out.println(bitm);
}