java.util.Deque.forEach()方法的使用及代码示例

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

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

Deque.forEach介绍

暂无

代码示例

代码示例来源:origin: OryxProject/oryx

@Override
public void run() {
 triggered = true;
 synchronized (closeAtShutdown) {
  closeAtShutdown.forEach(IOUtils::closeQuietly);
 }
}

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

/**
 * Store un-initialized variables in a temporary stack for future use.
 */
private void storePrevScopeUninitializedVariableData() {
  final ScopeData scopeData = scopeStack.peek();
  final Deque<DetailAST> prevScopeUninitializedVariableData =
      new ArrayDeque<>();
  scopeData.uninitializedVariables.forEach(prevScopeUninitializedVariableData::push);
  prevScopeUninitializedVariables.push(prevScopeUninitializedVariableData);
}

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

/**
 * Update current scope data uninitialized variable according to the whole scope data.
 * @param prevScopeUninitializedVariableData variable for previous stack of uninitialized
 *     variables
 * @noinspection MethodParameterNamingConvention
 */
private void updateAllUninitializedVariables(
    Deque<DetailAST> prevScopeUninitializedVariableData) {
  // Check for only previous scope
  updateUninitializedVariables(prevScopeUninitializedVariableData);
  // Check for rest of the scope
  prevScopeUninitializedVariables.forEach(this::updateUninitializedVariables);
}

代码示例来源:origin: MovingBlocks/Terasology

@Override
public void clear() {
  overlays.values().forEach(ControlWidget::onClosed);
  overlays.clear();
  hudScreenLayer.clear();
  screens.forEach(ControlWidget::onClosed);
  screens.clear();
  screenLookup.clear();
  focus = null;
  forceReleaseMouse = false;
}

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

public void startProcessor(String processor){
  getEventProcessor(processor).start();
  this.startHandlers.forEach(consumer -> consumer.accept(processor));
}

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

public void pauseProcessor(String processor){
  getEventProcessor(processor).shutDown();
  this.pauseHandlers.forEach(consumer -> consumer.accept(processor));
}

代码示例来源:origin: jooby-project/jooby

@Override
public List<String> params(final String name) {
 Builder<String> builder = ImmutableList.builder();
 // query params
 Deque<String> query = exchange.getQueryParameters().get(name);
 if (query != null) {
  query.forEach(builder::add);
 }
 // form params
 Optional.ofNullable(parseForm().get(name)).ifPresent(values -> values.forEach(value -> {
  if (!value.isFile()) {
   builder.add(value.getValue());
  }
 }));
 return builder.build();
}

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

@Override
public void visitToken(DetailAST ast) {
  final int tokenType = ast.getType();
  if (tokenType == TokenTypes.CLASS_DEF
    || tokenType == TokenTypes.METHOD_DEF
    || tokenType == TokenTypes.CTOR_DEF
    || tokenType == TokenTypes.STATIC_INIT
    || tokenType == TokenTypes.INSTANCE_INIT) {
    //add a counter for this class/method
    counters.push(new Counter());
  }
  //check if token is countable
  if (isCountable(ast)) {
    //increment the stacked counters
    counters.forEach(Counter::increment);
  }
}

代码示例来源:origin: jooby-project/jooby

@Override
public List<NativeUpload> files(final String name) {
 Builder<NativeUpload> builder = ImmutableList.builder();
 Deque<FormValue> values = parseForm().get(name);
 if (values != null) {
  values.forEach(value -> {
   if (value.isFile()) {
    builder.add(new UndertowUpload(value));
   }
  });
 }
 return builder.build();
}

代码示例来源:origin: MovingBlocks/Terasology

@Override
public void invalidate() {
  assetManager.getLoadedAssets(UIElement.class).forEach(UIElement::dispose);
  boolean hudVisible = isHUDVisible();
  if (hudVisible) {
    setHUDVisible(false);
  }
  Deque<ResourceUrn> reverseUrns = new LinkedList<>();
  Map<UIScreenLayer, ResourceUrn> inverseLookup = screenLookup.inverse();
  for (UIScreenLayer screen : screens) {
    screen.onClosed();
    reverseUrns.addFirst(inverseLookup.get(screen));
  }
  screens.clear();
  screenLookup.clear();
  reverseUrns.forEach(this::pushScreen);
  if (hudVisible) {
    setHUDVisible(true);
  }
}
@Override

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

/**
 * Verifies that concurrent sensor add, remove, updates and read don't result
 * in errors or deadlock.
 */
@Test
public void testConcurrentReadUpdate() throws Exception {
  final Random random = new Random();
  final Deque<Sensor> sensors = new ConcurrentLinkedDeque<>();
  metrics = new Metrics(new MockTime(10));
  SensorCreator sensorCreator = new SensorCreator(metrics);
  final AtomicBoolean alive = new AtomicBoolean(true);
  executorService = Executors.newSingleThreadExecutor();
  executorService.submit(new ConcurrentMetricOperation(alive, "record",
    () -> sensors.forEach(sensor -> sensor.record(random.nextInt(10000)))));
  for (int i = 0; i < 10000; i++) {
    if (sensors.size() > 5) {
      Sensor sensor = random.nextBoolean() ? sensors.removeFirst() : sensors.removeLast();
      metrics.removeSensor(sensor.name());
    }
    StatType statType = StatType.forId(random.nextInt(StatType.values().length));
    sensors.add(sensorCreator.createSensor(statType, i));
    for (Sensor sensor : sensors) {
      for (KafkaMetric metric : sensor.metrics()) {
        assertNotNull("Invalid metric value", metric.metricValue());
      }
    }
  }
  alive.set(false);
}

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

() -> sensors.forEach(sensor -> sensor.record(random.nextInt(10000)))));
Future<?> readFuture = executorService.submit(new ConcurrentMetricOperation(alive, "read",
  () -> sensors.forEach(sensor -> sensor.metrics().forEach(metric ->
    assertNotNull("Invalid metric value", metric.metricValue())))));
Future<?> reportFuture = executorService.submit(new ConcurrentMetricOperation(alive, "report",

代码示例来源:origin: com.cloudera.oryx/oryx-common

@Override
public void run() {
 triggered = true;
 synchronized (closeAtShutdown) {
  closeAtShutdown.forEach(IOUtils::closeQuietly);
 }
}

代码示例来源:origin: io.github.j8spec/j8spec

private static List<Hook> asHooks(Deque<List<Hook>> hookQueue) {
  List<Hook> result = new LinkedList<>();
  hookQueue.forEach(result::addAll);
  return result;
}

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

public synchronized void addConsumer(Consumer<Event> eventConsumer) {
  events.forEach(eventConsumer);
  consumers.add(eventConsumer);
}

代码示例来源:origin: org.codehaus.sonar-plugins.css/css-checks

private void increaseAndCheckNestedLevel(Tree tree) {
 if (stack.size() == max) {
  PreciseIssue issue = addPreciseIssue(tree, String.format("Refactor this code to not nest more than %s rulesets.", max));
  stack.forEach(t -> issue.secondary(t, "+1"));
 }
 stack.push(tree);
}

代码示例来源:origin: org.codehaus.sonar-plugins.css/css-checks

private void increaseAndCheckNestedLevel(Tree tree) {
 if (stack.size() == max) {
  PreciseIssue issue = addPreciseIssue(tree, String.format("Refactor this code to not nest more than %s rulesets.", max));
  stack.forEach(t -> issue.secondary(t, "+1"));
 }
 stack.push(tree);
}

代码示例来源:origin: SonarSource/sonar-php

private void leaveFunction(FunctionTree tree) {
  Deque<SyntaxToken> thisFunctionReturns = returnStatementCounter.pop();
  if (thisFunctionReturns.size() > max) {
   String message = String.format(MESSAGE, thisFunctionReturns.size(), max);
   PreciseIssue issue = context().newIssue(this, tree.functionToken(), message);
   thisFunctionReturns.forEach(returnToken -> issue.secondary(returnToken, null));
  }
 }
}

代码示例来源:origin: zeebe-io/zeebe

public ActorFuture<Void> onChannelClosed(TransportChannel channel) {
 return actor.call(
   () -> {
    final ChannelWriteQueue sendQueue = channelMap.remove(channel.getStreamId());
    if (sendQueue != null) {
     channelList.remove(sendQueue);
     // re-submit pending requests so that they can be retried
     sendQueue.pendingWrites.forEach(Batch::onChannelClosed);
    }
   });
}

代码示例来源:origin: SonarSource/sonar-php

private void enterFunction(FunctionTree tree) {
 nestedStack.push(tree.functionToken());
 if (nestedStack.size() == max + 1) {
  PreciseIssue issue = context().newIssue(this, tree.functionToken(), String.format(MESSAGE, max));
  nestedStack.forEach(secondary -> issue.secondary(secondary, "Nesting +1"));
 }
}

相关文章