java.util.BitSet.set()方法的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(7.6k)|赞(0)|评价(0)|浏览(250)

本文整理了Java中java.util.BitSet.set()方法的一些代码示例,展示了BitSet.set()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。BitSet.set()方法的具体详情如下:
包路径:java.util.BitSet
类名称:BitSet
方法名:set

BitSet.set介绍

[英]Sets the bit at index index to true.
[中]将索引处的位设置为true。

代码示例

代码示例来源:origin: netty/netty

  1. public void setCleanerFlag(int index) {
  2. if (cleanerFlags == null) {
  3. cleanerFlags = new BitSet();
  4. }
  5. cleanerFlags.set(index);
  6. }
  7. }

代码示例来源:origin: jenkinsci/jenkins

  1. public ArgumentListBuilder prepend(String... args) {
  2. // left-shift the mask
  3. BitSet nm = new BitSet(this.args.size()+args.length);
  4. for(int i=0; i<this.args.size(); i++)
  5. nm.set(i+args.length, mask.get(i));
  6. mask = nm;
  7. this.args.addAll(0, Arrays.asList(args));
  8. return this;
  9. }

代码示例来源:origin: jenkinsci/jenkins

  1. /**
  2. * Optionally hide this part of the command line from being printed to the log.
  3. * @param a a command argument
  4. * @param mask true to suppress in output, false to print normally
  5. * @return this
  6. * @see hudson.Launcher.ProcStarter#masks(boolean[])
  7. * @see Launcher#maskedPrintCommandLine(List, boolean[], FilePath)
  8. * @since 1.378
  9. */
  10. public ArgumentListBuilder add(String a, boolean mask) {
  11. if(a!=null) {
  12. if(mask) {
  13. this.mask.set(args.size());
  14. }
  15. args.add(a);
  16. }
  17. return this;
  18. }

代码示例来源:origin: apache/zeppelin

  1. @Override
  2. public void write(org.apache.thrift.protocol.TProtocol prot, getProgress_result struct) throws org.apache.thrift.TException {
  3. TTupleProtocol oprot = (TTupleProtocol) prot;
  4. BitSet optionals = new BitSet();
  5. if (struct.isSetSuccess()) {
  6. optionals.set(0);
  7. }
  8. oprot.writeBitSet(optionals, 1);
  9. if (struct.isSetSuccess()) {
  10. oprot.writeI32(struct.success);
  11. }
  12. }

代码示例来源:origin: skylot/jadx

  1. public static BitSet blocksToBitSet(MethodNode mth, List<BlockNode> blocks) {
  2. BitSet bs = new BitSet(mth.getBasicBlocks().size());
  3. for (BlockNode block : blocks) {
  4. bs.set(block.getId());
  5. }
  6. return bs;
  7. }

代码示例来源:origin: spring-projects/spring-framework

  1. private void setMonths(BitSet bits, String value) {
  2. int max = 12;
  3. value = replaceOrdinals(value, "FOO,JAN,FEB,MAR,APR,MAY,JUN,JUL,AUG,SEP,OCT,NOV,DEC");
  4. BitSet months = new BitSet(13);
  5. // Months start with 1 in Cron and 0 in Calendar, so push the values first into a longer bit set
  6. setNumberHits(months, value, 1, max + 1);
  7. // ... and then rotate it to the front of the months
  8. for (int i = 1; i <= max; i++) {
  9. if (months.get(i)) {
  10. bits.set(i - 1);
  11. }
  12. }
  13. }

代码示例来源:origin: apache/zookeeper

  1. public synchronized boolean add(Integer elementBit) {
  2. if (elementBit == null || elementBits.get(elementBit)) {
  3. return false;
  4. }
  5. if (cache.size() < cacheSize) {
  6. cache.add(elementBit);
  7. }
  8. elementBits.set(elementBit);
  9. elementCount++;
  10. return true;
  11. }

代码示例来源:origin: apache/zeppelin

  1. @Override
  2. public void write(org.apache.thrift.protocol.TProtocol prot, appendOutput_args struct) throws org.apache.thrift.TException {
  3. TTupleProtocol oprot = (TTupleProtocol) prot;
  4. BitSet optionals = new BitSet();
  5. if (struct.isSetEvent()) {
  6. optionals.set(0);
  7. }
  8. oprot.writeBitSet(optionals, 1);
  9. if (struct.isSetEvent()) {
  10. struct.event.write(oprot);
  11. }
  12. }

代码示例来源:origin: alibaba/jstorm

  1. @Override
  2. public void write(org.apache.thrift.protocol.TProtocol prot, removeNimbus_args struct) throws org.apache.thrift.TException {
  3. TTupleProtocol oprot = (TTupleProtocol) prot;
  4. BitSet optionals = new BitSet();
  5. if (struct.isSetNumber()) {
  6. optionals.set(0);
  7. }
  8. oprot.writeBitSet(optionals, 1);
  9. if (struct.isSetNumber()) {
  10. oprot.writeI32(struct.number);
  11. }
  12. }

代码示例来源:origin: skylot/jadx

  1. if (s.getIDom() != block) {
  2. if (domFrontier == null) {
  3. domFrontier = new BitSet(blocks.size());
  4. domFrontier.set(s.getId());
  5. if (blocks.get(p).getIDom() != block) {
  6. if (domFrontier == null) {
  7. domFrontier = new BitSet(blocks.size());
  8. domFrontier.set(p);

代码示例来源:origin: skylot/jadx

  1. private static void placePhi(MethodNode mth, int regNum, LiveVarAnalysis la) {
  2. List<BlockNode> blocks = mth.getBasicBlocks();
  3. int blocksCount = blocks.size();
  4. BitSet hasPhi = new BitSet(blocksCount);
  5. BitSet processed = new BitSet(blocksCount);
  6. Deque<BlockNode> workList = new LinkedList<>();
  7. BitSet assignBlocks = la.getAssignBlocks(regNum);
  8. for (int id = assignBlocks.nextSetBit(0); id >= 0; id = assignBlocks.nextSetBit(id + 1)) {
  9. processed.set(id);
  10. workList.add(blocks.get(id));
  11. }
  12. while (!workList.isEmpty()) {
  13. BlockNode block = workList.pop();
  14. BitSet domFrontier = block.getDomFrontier();
  15. for (int id = domFrontier.nextSetBit(0); id >= 0; id = domFrontier.nextSetBit(id + 1)) {
  16. if (!hasPhi.get(id) && la.isLive(id, regNum)) {
  17. BlockNode df = blocks.get(id);
  18. addPhi(mth, df, regNum);
  19. hasPhi.set(id);
  20. if (!processed.get(id)) {
  21. processed.set(id);
  22. workList.add(df);
  23. }
  24. }
  25. }
  26. }
  27. }

代码示例来源:origin: commons-collections/commons-collections

  1. /**
  2. * Add a Comparator to the end of the chain using the
  3. * given sort order
  4. *
  5. * @param comparator Comparator to add to the end of the chain
  6. * @param reverse false = forward sort order; true = reverse sort order
  7. */
  8. public void addComparator(Comparator comparator, boolean reverse) {
  9. checkLocked();
  10. comparatorChain.add(comparator);
  11. if (reverse == true) {
  12. orderingBits.set(comparatorChain.size() - 1);
  13. }
  14. }

代码示例来源:origin: apache/kylin

  1. @Override
  2. public BitSet copy(final Kryo kryo, final BitSet original) {
  3. final BitSet result = new BitSet();
  4. final int length = original.length();
  5. for (int i = 0; i < length; i++) {
  6. result.set(i, original.get(i));
  7. }
  8. return result;
  9. }

代码示例来源:origin: neo4j/neo4j

  1. private static void addToSeenList( BitSet target, long id, long lastId )
  2. {
  3. int index = toIntExact( id );
  4. if ( target.get( index ) )
  5. {
  6. throw new IllegalStateException( id + " already seen" );
  7. }
  8. if ( id > lastId )
  9. {
  10. throw new IllegalStateException( "Unexpectedly high id " + id + " seen when last id is " + lastId );
  11. }
  12. target.set( index );
  13. }

代码示例来源:origin: redisson/redisson

  1. public void setCleanerFlag(int index) {
  2. if (cleanerFlags == null) {
  3. cleanerFlags = new BitSet();
  4. }
  5. cleanerFlags.set(index);
  6. }
  7. }

代码示例来源:origin: apache/zeppelin

  1. @Override
  2. public void write(org.apache.thrift.protocol.TProtocol prot, updateAllOutput_args struct) throws org.apache.thrift.TException {
  3. TTupleProtocol oprot = (TTupleProtocol) prot;
  4. BitSet optionals = new BitSet();
  5. if (struct.isSetEvent()) {
  6. optionals.set(0);
  7. }
  8. oprot.writeBitSet(optionals, 1);
  9. if (struct.isSetEvent()) {
  10. struct.event.write(oprot);
  11. }
  12. }

代码示例来源:origin: apache/zeppelin

  1. @Override
  2. public void write(org.apache.thrift.protocol.TProtocol prot, getStatus_result struct) throws org.apache.thrift.TException {
  3. TTupleProtocol oprot = (TTupleProtocol) prot;
  4. BitSet optionals = new BitSet();
  5. if (struct.isSetSuccess()) {
  6. optionals.set(0);
  7. }
  8. oprot.writeBitSet(optionals, 1);
  9. if (struct.isSetSuccess()) {
  10. oprot.writeString(struct.success);
  11. }
  12. }

代码示例来源:origin: apache/storm

  1. @Override
  2. public void write(org.apache.storm.thrift.protocol.TProtocol prot, TopologyHistoryInfo struct) throws org.apache.storm.thrift.TException {
  3. org.apache.storm.thrift.protocol.TTupleProtocol oprot = (org.apache.storm.thrift.protocol.TTupleProtocol) prot;
  4. java.util.BitSet optionals = new java.util.BitSet();
  5. if (struct.is_set_topo_ids()) {
  6. optionals.set(0);
  7. }
  8. oprot.writeBitSet(optionals, 1);
  9. if (struct.is_set_topo_ids()) {
  10. {
  11. oprot.writeI32(struct.topo_ids.size());
  12. for (java.lang.String _iter866 : struct.topo_ids)
  13. {
  14. oprot.writeString(_iter866);
  15. }
  16. }
  17. }
  18. }

代码示例来源:origin: skylot/jadx

  1. private static void test(MethodNode mth, int regNum, LiveVarAnalysis la) {
  2. List<BlockNode> blocks = mth.getBasicBlocks();
  3. int blocksCount = blocks.size();
  4. BitSet hasPhi = new BitSet(blocksCount);
  5. BitSet processed = new BitSet(blocksCount);
  6. Deque<BlockNode> workList = new LinkedList<>();
  7. BitSet assignBlocks = la.getAssignBlocks(regNum);
  8. for (int id = assignBlocks.nextSetBit(0); id >= 0; id = assignBlocks.nextSetBit(id + 1)) {
  9. processed.set(id);
  10. workList.add(blocks.get(id));
  11. }
  12. while (!workList.isEmpty()) {
  13. BlockNode block = workList.pop();
  14. BitSet domFrontier = block.getDomFrontier();
  15. for (int id = domFrontier.nextSetBit(0); id >= 0; id = domFrontier.nextSetBit(id + 1)) {
  16. if (!hasPhi.get(id) && la.isLive(id, regNum)) {
  17. BlockNode df = blocks.get(id);
  18. addPhi(df, regNum);
  19. hasPhi.set(id);
  20. if (!processed.get(id)) {
  21. processed.set(id);
  22. workList.add(df);
  23. }
  24. }
  25. }
  26. }
  27. }

代码示例来源:origin: apache/ignite

  1. /**
  2. * @param idx Node index.
  3. * @param res Success flag.
  4. */
  5. private void receivedConnectionStatus(int idx, boolean res) {
  6. assert resCntr.get() < nodes.size();
  7. synchronized (resBitSet) {
  8. resBitSet.set(idx, res);
  9. }
  10. if (resCntr.incrementAndGet() == nodes.size())
  11. onDone(resBitSet);
  12. }

相关文章