java.util.ArrayList.isEmpty()方法的使用及代码示例

x33g5p2x  于2022-01-15 转载在 其他  
字(9.3k)|赞(0)|评价(0)|浏览(166)

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

ArrayList.isEmpty介绍

[英]Returns true if this list contains no elements.
[中]如果此列表不包含任何元素,则返回true。

代码示例

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

private void updateLastReportedPlayingMediaPeriod() {
 if (!mediaPeriodInfoQueue.isEmpty()) {
  lastReportedPlayingMediaPeriod = mediaPeriodInfoQueue.get(0);
 }
}

代码示例来源:origin: lingochamp/FileDownloader

@Override
public void taskWorkFine(BaseDownloadTask.IRunningTask task) {
  if (!mWaitingList.isEmpty()) {
    synchronized (mWaitingList) {
      mWaitingList.remove(task);
    }
  }
}

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

/**
 * Returns the {@link MediaPeriodInfo} of the media period at the end of the queue which is
 * currently loading or will be the next one loading. May be null, if no media period is active
 * yet.
 */
public @Nullable MediaPeriodInfo getLoadingMediaPeriod() {
 return mediaPeriodInfoQueue.isEmpty()
   ? null
   : mediaPeriodInfoQueue.get(mediaPeriodInfoQueue.size() - 1);
}

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

public SaslClient createSaslClient(final String[] mechanisms, final String authorizationId, final String protocol, final String serverName, final Map<String, ?> props, final CallbackHandler cbh) throws SaslException {
  return delegate.createSaslClient(mechanisms, authorizationId, protocol, serverName, props, callbacks -> {
    ArrayList<Callback> list = new ArrayList<>(Arrays.asList(callbacks));
    final Iterator<Callback> iterator = list.iterator();
    while (iterator.hasNext()) {
      Callback callback = iterator.next();
      if (callback instanceof ChannelBindingCallback) {
        ((ChannelBindingCallback) callback).setBindingType(bindingType);
        ((ChannelBindingCallback) callback).setBindingData(bindingData);
        iterator.remove();
      }
    }
    if (!list.isEmpty()) {
      cbh.handle(list.toArray(new Callback[list.size()]));
    }
  });
}

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

@Override
public void onPositionDiscontinuity(@Player.DiscontinuityReason int reason) {
 discontinuityReasons.add(reason);
 int currentIndex = player.getCurrentPeriodIndex();
 if (reason == Player.DISCONTINUITY_REASON_PERIOD_TRANSITION
   || periodIndices.isEmpty()
   || periodIndices.get(periodIndices.size() - 1) != currentIndex) {
  // Ignore seek or internal discontinuities within a period.
  periodIndices.add(currentIndex);
 }
}

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

public void recover(ConnectionContext context, Topic topic, SubscriptionRecovery sub) throws Exception {
  // Re-dispatch the messages from the buffer.
  ArrayList<TimestampWrapper> copy = new ArrayList<TimestampWrapper>(buffer);
  if (!copy.isEmpty()) {
    for (Iterator<TimestampWrapper> iter = copy.iterator(); iter.hasNext();) {
      TimestampWrapper timestampWrapper = iter.next();
      MessageReference message = timestampWrapper.message;
      sub.addRecoveredMessage(context, message);
    }
  }
}

代码示例来源:origin: pentaho/pentaho-kettle

public static String[] getNodeElements( Node node ) {
 ArrayList<String> elements = new ArrayList<String>(); // List of String
 NodeList nodeList = node.getChildNodes();
 if ( nodeList == null ) {
  return null;
 }
 for ( int i = 0; i < nodeList.getLength(); i++ ) {
  String nodeName = nodeList.item( i ).getNodeName();
  if ( elements.indexOf( nodeName ) < 0 ) {
   elements.add( nodeName );
  }
 }
 if ( elements.isEmpty() ) {
  return null;
 }
 return elements.toArray( new String[ elements.size() ] );
}

代码示例来源:origin: andkulikov/Transitions-Everywhere

/**
 * Ends all pending and ongoing transitions on the specified scene root.
 *
 * @param sceneRoot The root of the View hierarchy to end transitions on.
 */
public static void endTransitions(final @NonNull ViewGroup sceneRoot) {
  sPendingTransitions.remove(sceneRoot);
  final ArrayList<Transition> runningTransitions = getRunningTransitions(sceneRoot);
  if (!runningTransitions.isEmpty()) {
    // Make a copy in case this is called by an onTransitionEnd listener
    ArrayList<Transition> copy = new ArrayList(runningTransitions);
    for (int i = copy.size() - 1; i >= 0; i--) {
      final Transition transition = copy.get(i);
      transition.forceToEnd(sceneRoot);
    }
  }
}

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

@Override
public List<byte[]> getStripeBoundaries() {
 if (this.state.stripeFiles.isEmpty()) {
  return Collections.emptyList();
 }
 ArrayList<byte[]> result = new ArrayList<>(this.state.stripeEndRows.length + 2);
 result.add(OPEN_KEY);
 Collections.addAll(result, this.state.stripeEndRows);
 result.add(OPEN_KEY);
 return result;
}

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

@Override
protected void verifyResultsIdealCircumstances(ListSink sink) {
  ArrayList<Integer> list = new ArrayList<>();
  for (int x = 1; x <= 60; x++) {
    list.add(x);
  }
  for (Integer i : sink.values) {
    list.remove(i);
  }
  Assert.assertTrue("The following ID's where not found in the result list: " + list.toString(), list.isEmpty());
  Assert.assertTrue("The sink emitted to many values: " + (sink.values.size() - 60), sink.values.size() == 60);
}

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

/**
 * @apilevel internal
 */
private boolean isDUafterReachedFinallyBlocks_compute(Variable v) {
 if(!isDUbefore(v) && finallyList().isEmpty())
  return false;
 for(Iterator iter = finallyList().iterator(); iter.hasNext(); ) {
  FinallyHost f = (FinallyHost)iter.next();
  if(!f.isDUafterFinally(v))
   return false;
 }
 return true;
}
protected java.util.Map isDAafterReachedFinallyBlocks_Variable_values;

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

public GradientPanel (GradientColorValue value, String name, String description, boolean hideGradientEditor) {
  super(value, name, description);
  this.value = value;
  initializeComponents();
  if (hideGradientEditor) {
    gradientEditor.setVisible(false);
  }
  gradientEditor.percentages.clear();
  for (float percent : value.getTimeline())
    gradientEditor.percentages.add(percent);
  gradientEditor.colors.clear();
  float[] colors = value.getColors();
  for (int i = 0; i < colors.length;) {
    float r = colors[i++];
    float g = colors[i++];
    float b = colors[i++];
    gradientEditor.colors.add(new Color(r, g, b));
  }
  if (gradientEditor.colors.isEmpty() || gradientEditor.percentages.isEmpty()) {
    gradientEditor.percentages.clear();
    gradientEditor.percentages.add(0f);
    gradientEditor.percentages.add(1f);
    gradientEditor.colors.clear();
    gradientEditor.colors.add(Color.white);
  }
  setColor(gradientEditor.colors.get(0));
}

代码示例来源:origin: btraceio/btrace

void popEnableBit() {
    if (enabledBits.isEmpty()) {
      System.err.println("WARNING: mismatched #ifdef/endif pairs");
      return;
    }
    enabledBits.remove(enabledBits.size() - 1);
    --debugPrintIndentLevel;
    //debugPrint(false, "POP_ENABLED, NOW: " + enabled());
  }
}

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

/**
 * @apilevel internal
 */
private boolean inSynchronizedBlock_compute() {  return !finallyList().isEmpty() && finallyList().iterator().next() instanceof SynchronizedStmt;  }
/**

代码示例来源:origin: crazycodeboy/TakePhoto

@Override
public void compress() {
  if (images == null || images.isEmpty()) {
    listener.onCompressFailed(images, " images is null");
    return;
  }
  for (TImage image : images) {
    if (image == null) {
      listener.onCompressFailed(images, " There are pictures of compress  is null.");
      return;
    }
    files.add(new File(image.getOriginalPath()));
  }
  if (images.size() == 1) {
    compressOne();
  } else {
    compressMulti();
  }
}

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

private static InterceptorList ofList(final ArrayList<EJBClientInterceptorInformation> value) {
  if (value.isEmpty()) {
    return EMPTY;
  } else if (value.size() == 1) {
    return value.get(0).getSingletonList();
  } else {
    return new InterceptorList(value.toArray(EJBClientInterceptorInformation.NO_INTERCEPTORS));
  }
}

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

/**
 * Add a named argument.
 * @param name the name of the argument.
 * @param parse an optional function to transform the string to something else. If null a NOOP is used.
 * @param assoc an association command to decide what to do if the argument appears multiple times.  If null INTO_LIST is used.
 * @return a builder to be used to continue creating the command line.
 */
public CLIBuilder arg(String name, Parse parse, Assoc assoc) {
  if (!optionalArgs.isEmpty()) {
    throw new IllegalStateException("Cannot have a required argument after adding in an optional argument");
  }
  args.add(new Arg(name, parse, assoc));
  return this;
}

代码示例来源:origin: go-lang-plugin-org/go-lang-idea-plugin

@NotNull
 @Override
 public AnAction[] getChildren(@Nullable AnActionEvent e) {
  if (e == null) {
   return AnAction.EMPTY_ARRAY;
  }
  Project project = e.getProject();
  Editor editor = e.getData(CommonDataKeys.EDITOR);
  if (project == null || editor == null) return AnAction.EMPTY_ARRAY;
  PsiFile file = PsiUtilBase.getPsiFileInEditor(editor, project);

  ArrayList<AnAction> children = ContainerUtil.newArrayList();
  for (GoTestFramework framework : GoTestFramework.all()) {
   if (framework.isAvailableOnFile(file)) {
    children.addAll(framework.getGenerateMethodActions());
   }
  }
  return !children.isEmpty() ? children.toArray(new AnAction[children.size()]) : AnAction.EMPTY_ARRAY;
 }
}

代码示例来源:origin: eclipse-vertx/vert.x

if (!extensionHandshakers.isEmpty()) {
 p.addBefore("handler", "websocketsExtensionsHandler", new WebSocketClientExtensionHandler(
  extensionHandshakers.toArray(new WebSocketClientExtensionHandshaker[extensionHandshakers.size()])));
handshaker = WebSocketClientHandshakerFactory.newHandshaker(wsuri, version, subProtocols, !extensionHandshakers.isEmpty(),
                              nettyHeaders, maxWebSocketFrameSize,!options.isSendUnmaskedFrames(),false);

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

/**
 * Updates the queue with a released media period. Returns whether the media period was still in
 * the queue.
 */
public boolean onMediaPeriodReleased(MediaPeriodId mediaPeriodId) {
 MediaPeriodInfo mediaPeriodInfo = mediaPeriodIdToInfo.remove(mediaPeriodId);
 if (mediaPeriodInfo == null) {
  // The media period has already been removed from the queue in resetForNewMediaSource().
  return false;
 }
 mediaPeriodInfoQueue.remove(mediaPeriodInfo);
 if (readingMediaPeriod != null && mediaPeriodId.equals(readingMediaPeriod.mediaPeriodId)) {
  readingMediaPeriod = mediaPeriodInfoQueue.isEmpty() ? null : mediaPeriodInfoQueue.get(0);
 }
 return true;
}

相关文章