java.util.SortedSet.remove()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(9.9k)|赞(0)|评价(0)|浏览(171)

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

SortedSet.remove介绍

暂无

代码示例

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

public DayOfWeek(String value) {
  super(value);
  for (Integer dayOfWeek : this.absoluteValues) {
    if (dayOfWeek == 7) {
      this.absoluteValues.remove(dayOfWeek);
      this.absoluteValues.add(new Integer(0));
    }
  }
  if (OFFSET != 0) {
    for (Integer dayOfWeek : this.absoluteValues) {
      this.offsetAdjustedDaysOfWeek.add(dayOfWeek - OFFSET);
    }
  } else {
    this.offsetAdjustedDaysOfWeek = this.absoluteValues;
  }
}

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

/**
 * Split a given {@link Segment} n-times in round robin fashion.
 * <br/>
 *
 * @param segment       The {@link Segment} to split.
 * @param numberOfTimes The number of times to split it.
 * @return a collection of {@link Segment}'s.
 */
public static List<Segment> splitBalanced(Segment segment, int numberOfTimes) {
  final SortedSet<Segment> toBeSplit = new TreeSet<>(Comparator.comparing(Segment::getMask)
                                 .thenComparing(Segment::getSegmentId));
  toBeSplit.add(segment);
  for (int i = 0; i < numberOfTimes; i++) {
    final Segment workingSegment = toBeSplit.first();
    toBeSplit.remove(workingSegment);
    toBeSplit.addAll(Arrays.asList(workingSegment.split()));
  }
  ArrayList<Segment> result = new ArrayList<>(toBeSplit);
  result.sort(Comparator.comparing(Segment::getSegmentId));
  return result;
}

代码示例来源:origin: linkedin/cruise-control

/**
 * If the swap was successful, update the (1) replicas of the source broker (2) replicas of the candidate broker, and
 * (3) the priority queue of candidate brokers to swap replicas with.
 *
 * @param swappedInReplica the replica swapped in to the source broker from the candidate broker, null otherwise.
 * @param swappedOutReplica the replica swapped out from the source broker to candidate broker, null otherwise.
 * @param sourceReplicas replicas of the source broker before the swap.
 * @param candidateReplicasToSwapWith replicas of the candidate broker before the swap.
 * @param candidateBrokerPQ a priority queue of candidate brokers to swap replicas with (priority: by broker utilization)
 * @param cb the candidate broker to swap with.
 */
private void swapUpdate(Replica swappedInReplica,
            Replica swappedOutReplica,
            SortedSet<Replica> sourceReplicas,
            SortedSet<Replica> candidateReplicasToSwapWith,
            PriorityQueue<CandidateBroker> candidateBrokerPQ,
            CandidateBroker cb) {
 if (swappedInReplica != null) {
  // Update the list of replicas in source broker after the swap operations.
  sourceReplicas.remove(swappedOutReplica);
  sourceReplicas.add(swappedInReplica);
  candidateReplicasToSwapWith.remove(swappedInReplica);
  candidateReplicasToSwapWith.add(swappedOutReplica);
  // The broker is still considered as an eligible candidate replica, because the swap was successful -- i.e. there
  // might be other potential candidate replicas on it to swap with.
  candidateBrokerPQ.add(cb);
 }
}

代码示例来源:origin: google/guava

void ensureNotDirectlyModifiable(SortedSet<Integer> unmod) {
 try {
  unmod.add(4);
  fail("UnsupportedOperationException expected");
 } catch (UnsupportedOperationException expected) {
 }
 try {
  unmod.remove(4);
  fail("UnsupportedOperationException expected");
 } catch (UnsupportedOperationException expected) {
 }
 try {
  unmod.addAll(Collections.singleton(4));
  fail("UnsupportedOperationException expected");
 } catch (UnsupportedOperationException expected) {
 }
 try {
  Iterator<Integer> iterator = unmod.iterator();
  iterator.next();
  iterator.remove();
  fail("UnsupportedOperationException expected");
 } catch (UnsupportedOperationException expected) {
 }
}

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

@Override
 public void onFailure() {
  // If the bucket creation failed, we need to undo the changes
  // we made to the model
  attemptedBucketCreations.add(move);
  // remove the bucket from lowRedundancyBuckets before mutating the state
  lowRedundancyBuckets.remove(bucket);
  bucket.removeMember(targetMember);
  if (bucket.getRedundancy() < requiredRedundancy) {
   lowRedundancyBuckets.add(bucket);
  }
  resetAverages();
 }
});

代码示例来源:origin: Sable/soot

queue.add(o);
queue.remove(m);
S newSummary = newInitialSummary();
S oldSummary = data.get(m);

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

private void markReadyToDeliverV2(MessageID messageID, long finalSequenceNumber) {
  MessageInfo messageInfo = messageCache.remove(messageID);
  if (messageInfo == null) {
    throw new IllegalStateException("Message ID not found in to deliver list. this can't happen. " +
        "Message ID is " + messageID);
  }
  boolean needsUpdatePosition = messageInfo.isUpdatePositionNeeded(finalSequenceNumber);
  synchronized (deliverySet) {
    sequenceNumberManager.update(finalSequenceNumber);
    if (needsUpdatePosition) {
      deliverySet.remove(messageInfo);
      messageInfo.updateAndMarkReadyToDeliver(finalSequenceNumber);
      deliverySet.add(messageInfo);
    } else {
      messageInfo.updateAndMarkReadyToDeliver(finalSequenceNumber);
    }
    notifyIfNeeded();
  }
}

代码示例来源:origin: linkedin/cruise-control

candidateBrokers.remove(b);
if (b.replicas().size() < _balanceUpperLimit || _selfHealingDeadBrokersOnly) {
 candidateBrokers.add(b);

代码示例来源:origin: aragozin/jvm-tools

long[] getBiggestObjectsByRetainedSize(int number) {
  SortedSet<RetainedSizeEntry> bigObjects = new TreeSet<RetainedSizeEntry>();
  long[] bigIds = new long[number];
  long min = 0;
  for (long index=0;index<fileSize;index+=ENTRY_SIZE) {
    long id = getID(index);
    if (id != 0) {
      long retainedSize = createEntry(index).getRetainedSize();
      if (bigObjects.size()<number) {
        bigObjects.add(new RetainedSizeEntry(id,retainedSize));
        min = ((RetainedSizeEntry)bigObjects.last()).retainedSize;
      } else if (retainedSize>min) {
        bigObjects.remove(bigObjects.last());
        bigObjects.add(new RetainedSizeEntry(id,retainedSize));
        min = ((RetainedSizeEntry)bigObjects.last()).retainedSize;
      }
    }
  }
  int i = 0;
  Iterator<RetainedSizeEntry> it = bigObjects.iterator();
  while(it.hasNext()) {
    bigIds[i++]=((RetainedSizeEntry)it.next()).instanceId;
  }
  return bigIds;
}

代码示例来源:origin: opentripplanner/OpenTripPlanner

sortedTimetables.remove(old);
sortedTimetables.add(tt);
timetables.put(pattern, sortedTimetables);
dirtyTimetables.add(tt);

代码示例来源:origin: linkedin/cruise-control

_selfHealingEligibleReplicas.addAll(broker.replicas());
 _aliveBrokers.remove(broker);
 _deadBrokers.add(broker);
 break;
case NEW:
 _newBrokers.add(broker);
 _selfHealingEligibleReplicas.removeAll(broker.replicas());
 _aliveBrokers.add(broker);
 _deadBrokers.remove(broker);
 break;
default:

代码示例来源:origin: linkedin/cruise-control

clusterModel.partition(replica.topicPartition()).followerBrokers().forEach(b -> {
 if (candidateBrokers.contains(b)) {
  eligibleBrokers.add(b);
candidateBrokers.remove(b);
if (utilizationPercentage(b, resource()) < _balanceUpperThreshold) {
 candidateBrokers.add(b);

代码示例来源:origin: Alluxio/alluxio

getWorkerInfoList(), jobId, jobConfig, (jobInfo) -> {
 Status status = jobInfo.getStatus();
 mFinishedJobs.remove(jobInfo);
 if (status.isFinished()) {
  mFinishedJobs.add(jobInfo);

代码示例来源:origin: i2p/i2p.i2p

break;
toTry.remove(nInfo);
tried.add(nInfo);
   for (NodeInfo ni : reply) {
     if (! (ni.equals(_myNodeInfo) || (toTry.contains(ni) && tried.contains(ni))))
       toTry.add(ni);

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

public void remoteOverRedundancyBucket(BucketRollup bucket, Member targetMember) {
 Move bestMove = new Move(null, targetMember, bucket);
 Map<String, Long> colocatedRegionSizes = getColocatedRegionSizes(bucket);
 if (!this.operator.removeBucket(targetMember.getMemberId(), bucket.getId(),
   colocatedRegionSizes)) {
  this.attemptedBucketRemoves.add(bestMove);
 } else {
  this.overRedundancyBuckets.remove(bucket);
  bucket.removeMember(targetMember);
  // put the bucket back into the list if we still need to satisfy redundancy for
  // this bucket
  if (bucket.getOnlineRedundancy() > this.requiredRedundancy) {
   this.overRedundancyBuckets.add(bucket);
  }
  resetAverages();
 }
}

代码示例来源:origin: i2p/i2p.i2p

break;
toTry.remove(nInfo);
tried.add(nInfo);
if (_log.shouldLog(Log.DEBUG))
  _log.debug("Try " + i + ": " + nInfo);
     _log.debug("Got pong");
} else if (replyType == REPLY_PEERS) {
   heardFrom.add(waiter.getSentTo());
   if (_log.shouldLog(Log.DEBUG))
     _log.debug("Got peers");
   break;
} else if (replyType == REPLY_NODES) {
   heardFrom.add(waiter.getSentTo());
   List<NodeInfo> reply = (List<NodeInfo>) waiter.getReplyObject();
   if (_log.shouldLog(Log.DEBUG))

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

LOG.debug("Received out of order command which is being buffered for later: " + command);
  commands.add(command);
valid = expectedCounter == command.getCommandId();
if (valid) {
  commands.remove(command);
valid = expectedCounter == command.getCommandId();
if (valid) {
  commands.remove(command);

代码示例来源:origin: google/guava

public void testAsMapSortedReadsThrough() {
 SortedSet<String> strings = new NonNavigableSortedSet();
 Collections.addAll(strings, "one", "two", "three");
 SortedMap<String, Integer> map = Maps.asMap(strings, LENGTH_FUNCTION);
 assertNull(map.comparator());
 assertEquals(ImmutableSortedMap.of("one", 3, "two", 3, "three", 5), map);
 assertNull(map.get("four"));
 strings.add("four");
 assertEquals(ImmutableSortedMap.of("one", 3, "two", 3, "three", 5, "four", 4), map);
 assertEquals(Integer.valueOf(4), map.get("four"));
 SortedMap<String, Integer> headMap = map.headMap("two");
 assertEquals(ImmutableSortedMap.of("four", 4, "one", 3, "three", 5), headMap);
 strings.add("five");
 strings.remove("one");
 assertEquals(ImmutableSortedMap.of("five", 4, "four", 4, "three", 5), headMap);
 assertThat(map.entrySet())
   .containsExactly(
     mapEntry("five", 4), mapEntry("four", 4), mapEntry("three", 5), mapEntry("two", 3))
   .inOrder();
}

代码示例来源:origin: prestodb/presto

try (SetThreadName splitName = new SetThreadName(threadId)) {
  RunningSplitInfo splitInfo = new RunningSplitInfo(ticker.read(), threadId, Thread.currentThread());
  runningSplitInfos.add(splitInfo);
  runningSplits.add(split);
    runningSplitInfos.remove(splitInfo);
    runningSplits.remove(split);

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

writer.close();
logFileRefCountsAll.remove(logFileID);
LOGGER.info("Updated checkpoint for file: " + logFile + " position: "
  + logWriter.position() + " logWriteOrderID: " + logWriteOrderID);
logFileRefCountsActive.add(logFiles.get(index).getLogFileID());

相关文章