@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); } }
@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); } }
/** {@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; }
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); } }
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; }
/** * 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(); }
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); } }
/** 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; }
@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); } }
/** * 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(); }
/** * 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(); }
@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); } }
@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); }
@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); } }
@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); }
public static BitSet primes(int max) { BitSet primeSet = new BitSet(max + 1); if (max < 2) { return primeSet; } int limit = (int) Math.sqrt(max + 1); primeSet.set(2); for (int i = 3; i < max + 1; i += 2) { primeSet.set(i); } for (int i = 3; i <= limit; i += 2) { if (!primeSet.get(i)) { continue; } for (int j = i * i; j < max; j += i) { primeSet.clear(j); } } return primeSet; }
/** * 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(); }
private boolean writeRegisterInfo(IndentingWriter writer, BitSet registers) throws IOException { int registerNum = registers.nextSetBit(0); if (registerNum < 0) { return false; } writer.write('#'); for (; registerNum >= 0; registerNum = registers.nextSetBit(registerNum + 1)) { RegisterType registerType = analyzedInstruction.getPostInstructionRegisterType(registerNum); registerFormatter.writeTo(writer, registerNum); writer.write('='); registerType.writeTo(writer); writer.write(';'); } return true; }
@Override public void read(org.apache.thrift.protocol.TProtocol prot, instructionInvokeAsync_args struct) throws org.apache.thrift.TException { TTupleProtocol iprot = (TTupleProtocol) prot; BitSet incoming = iprot.readBitSet(1); if (incoming.get(0)) { { org.apache.thrift.protocol.TList _list5 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, iprot.readI32()); struct.insList = new ArrayList<Instruct>(_list5.size); Instruct _elem6; for (int _i7 = 0; _i7 < _list5.size; ++_i7) { _elem6 = new Instruct(); _elem6.read(iprot); struct.insList.add(_elem6); } } struct.setInsListIsSet(true); } }
public void localizePriceModel(DataService ds, Product product, Organization customer, VOPriceModelLocalization localizationOriginal, VOPriceModelLocalization localizationToBeUpdate) { ArgumentValidator.notNull("localizationToBeUpdate", localizationToBeUpdate); ArgumentValidator.notNull("localizationOriginal", localizationOriginal); Map<String, LocalizedAuditLogEntryParameters> mapToBeUpdate = prepareLocalizationMap(localizationToBeUpdate); Map<String, LocalizedAuditLogEntryParameters> mapOriginal = prepareLocalizationMap(localizationOriginal); Map<String, BitSet> localizationMap = collectLocalizationStates( mapToBeUpdate, mapOriginal); for (String locale : localizationMap.keySet()) { boolean descriptionLocalized = isDescriptionLocalized( localizationMap, locale); boolean licenseLocalized = isLicenseLocalized(localizationMap, locale); addLogEntryForAuditLogData(ds, product, customer, locale, descriptionLocalized, licenseLocalized); } }
/** * Submaps of submaps subdivide correctly */ public void testRecursiveSubMaps() throws Exception { int mapSize = expensiveTests ? 1000 : 100; Class cl = ConcurrentSkipListMap.class; NavigableMap<Integer, Integer> map = newMap(cl); bs = new BitSet(mapSize); populate(map, mapSize); check(map, 0, mapSize - 1, true); check(map.descendingMap(), 0, mapSize - 1, false); mutateMap(map, 0, mapSize - 1); check(map, 0, mapSize - 1, true); check(map.descendingMap(), 0, mapSize - 1, false); bashSubMap(map.subMap(0, true, mapSize, false), 0, mapSize - 1, true); }
/** * 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 \"ThermalGeneratingUnit\" 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\"FossilFuels\" needs to be set\n"); } return message.toString(); }
/** * Constructor of the class HydroGeneratingUnit */ protected HydroGeneratingUnit() { super.subset = Subset.Equipment; this.minBitsets.put(Subset.StateVariables, new BitSet(0)); this.minBitsets.put(Subset.Topology, new BitSet(0)); BitSet classBitset = new BitSet(0); this.minBitsets.put(Subset.Equipment, classBitset); }
public boolean isProtoIdInSmallPatchedDex(String oldDexSign, int indexInPatchedDex) { BitSet indices = (BitSet) this.oldDexSignToProtoIdIndicesInSmallPatch.get(oldDexSign); if (indices == null) { return false; } return indices.get(indexInPatchedDex); }
/** * Constructor of the class RegulatingControl */ protected RegulatingControl() { super.subset = Subset.Equipment; this.minBitsets.put(Subset.StateVariables, new BitSet(7)); this.minBitsets.put(Subset.Topology, new BitSet(7)); BitSet classBitset = new BitSet(7); classBitset.set(1); classBitset.set(3); classBitset.set(4); classBitset.set(5); classBitset.set(6); this.minBitsets.put(Subset.Equipment, classBitset); }
/** * Constructor of the class GeographicalRegion */ protected GeographicalRegion() { super.subset = Subset.Equipment; this.minBitsets.put(Subset.StateVariables, new BitSet(1)); this.minBitsets.put(Subset.Topology, new BitSet(1)); BitSet classBitset = new BitSet(1); this.minBitsets.put(Subset.Equipment, classBitset); }
public MethodWriter(int access, Method method, ClassVisitor cw, BitSet statements, CompilerSettings settings) { super(Opcodes.ASM5, cw.visitMethod(access, method.getName(), method.getDescriptor(), null, null), access, method.getName(), method.getDescriptor()); this.statements = statements; this.settings = settings; }
@Override public void write(org.apache.thrift.protocol.TProtocol prot, fetchResults_args struct) throws org.apache.thrift.TException { TTupleProtocol oprot = (TTupleProtocol) prot; BitSet optionals = new BitSet(); if (struct.isSetReq()) { optionals.set(0); } oprot.writeBitSet(optionals, 1); if (struct.isSetReq()) { struct.req.write(oprot); } }
public static BitSet INIT_BITSET(final int ... b) { final BitSet bitset = new BitSet(); for (final int aB : b) { bitset.set(aB); } return bitset; }
/** * Encodes an array of bytes into an array of URL safe 7-bit characters. Unsafe characters are escaped. * * @param urlsafe * bitset of characters deemed URL safe * @param bytes * array of bytes to convert to URL safe characters * @return array of bytes containing URL safe characters */ public static final byte[] encodeUrl(BitSet urlsafe, final byte[] bytes) { if (bytes == null) { return null; } if (urlsafe == null) { urlsafe = WWW_FORM_URL; } final ByteArrayOutputStream buffer = new ByteArrayOutputStream(); for (final byte c : bytes) { int b = c; if (b < 0) { b = 256 + b; } if (urlsafe.get(b)) { if (b == ' ') { b = '+'; } buffer.write(b); } else { buffer.write(ESCAPE_CHAR); final char hex1 = Character.toUpperCase(Character.forDigit((b >> 4) & 0xF, RADIX)); final char hex2 = Character.toUpperCase(Character.forDigit(b & 0xF, RADIX)); buffer.write(hex1); buffer.write(hex2); } } return buffer.toByteArray(); }
@Override public void reportAmbiguity(@NotNull Parser recognizer, @NotNull DFA dfa, int startIndex, int stopIndex, boolean exact, @Nullable BitSet ambigAlts, @NotNull ATNConfigSet configs) { }
@Override public void write(org.apache.thrift.protocol.TProtocol prot, getWorkersStatus_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.writeString(struct.success); } }
@Override public void write(org.apache.thrift.protocol.TProtocol prot, sayHello_args struct) throws org.apache.thrift.TException { TTupleProtocol oprot = (TTupleProtocol) prot; BitSet optionals = new BitSet(); if (struct.isSetRequest()) { optionals.set(0); } oprot.writeBitSet(optionals, 1); if (struct.isSetRequest()) { struct.request.write(oprot); } }
@Override public void read(org.apache.thrift.protocol.TProtocol prot, VersionedValue struct) throws org.apache.thrift.TException { TTupleProtocol iprot = (TTupleProtocol) prot; struct.version = new VectorClock(); struct.version.read(iprot); struct.setVersionIsSet(true); BitSet incoming = iprot.readBitSet(1); if (incoming.get(0)) { struct.value = iprot.readBinary(); struct.setValueIsSet(true); } }
@Override public void read(org.apache.thrift.protocol.TProtocol prot, cancelOperation_result struct) throws org.apache.thrift.TException { TTupleProtocol iprot = (TTupleProtocol) prot; BitSet incoming = iprot.readBitSet(1); if (incoming.get(0)) { struct.success = new TSCancelOperationResp(); struct.success.read(iprot); struct.setSuccessIsSet(true); } }
public FLG(int version, Bits... bits) { this.bitSet = new BitSet(8); this.version = version; if (bits != null) { for (Bits bit : bits) { bitSet.set(bit.position); } } validate(); }
/** * Utility to check whether this class is consistent in a "merged" context * * @return a ConsistencyCheck instance whose boolean attribute (consistent) * indicates if this class is consistent and whose String attribute * (message) * indicates why this class is not consistent if it is not */ @Override public ConsistencyCheck modelConsistency() { BitSet intersection = new BitSet(this.minBitset.length()); intersection.or(this.minBitset); // we create a copy of minBitSet intersection.and(this.currentBitset); boolean consistent = (this.minBitset.equals(intersection)); StringBuilder message = new StringBuilder(""); if (!consistent) { message.append(getMessageForConsistency(this.minBitset)); } // consistent = (super.modelConsistency().getLeft()) ? (consistent && // (true)):(consistent && (false)) // message += (super.modelConsistency(subset)).getRight(); if (super.modelConsistency().isConsistent()) { consistent = consistent && (true); message.append((super.modelConsistency()).getMessage()); } else { consistent = consistent && (false); message.append((super.modelConsistency()).getMessage()); } return new ConsistencyCheck(consistent, message.toString()); }
public boolean isTypeListInSmallPatchedDex(String oldDexSign, int indexInPatchedDex) { BitSet indices = (BitSet) this.oldDexSignToTypeListIndicesInSmallPatch.get(oldDexSign); if (indices == null) { return false; } return indices.get(indexInPatchedDex); }
@Override public void write(org.apache.thrift.protocol.TProtocol prot, append_args struct) throws org.apache.thrift.TException { TTupleProtocol oprot = (TTupleProtocol) prot; BitSet optionals = new BitSet(); if (struct.isSetAppend()) { optionals.set(0); } oprot.writeBitSet(optionals, 1); if (struct.isSetAppend()) { struct.append.write(oprot); } }