本文整理了Java中java.util.LinkedList.isEmpty()
方法的一些代码示例,展示了LinkedList.isEmpty()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。LinkedList.isEmpty()
方法的具体详情如下:
包路径:java.util.LinkedList
类名称:LinkedList
方法名:isEmpty
暂无
代码示例来源:origin: spring-projects/spring-framework
@SuppressWarnings("unchecked")
@Nullable
private <T> T getLastBuilder(Class<T> builderClass) {
if (!this.builders.isEmpty()) {
PathComponentBuilder last = this.builders.getLast();
if (builderClass.isInstance(last)) {
return (T) last;
}
}
return null;
}
代码示例来源:origin: jMonkeyEngine/jmonkeyengine
/**
* Retrieves and removes an extracted message from the accumulated buffer
* or returns null if there are no more messages.
*/
public Message getMessage()
{
if( messages.isEmpty() ) {
return null;
}
return messages.removeFirst();
}
代码示例来源:origin: apache/activemq
private final MessageDispatch getFirst() {
if (this.size > 0) {
for (int i = MAX_PRIORITY - 1; i >= 0; i--) {
LinkedList<MessageDispatch> list = lists[i];
if (!list.isEmpty()) {
return list.getFirst();
}
}
}
return null;
}
}
代码示例来源:origin: oracle/opengrok
if (!res.isEmpty()) {
res.removeLast();
res.add(name);
res.add(name);
return res.size() == names.length ? names : res.toArray(new String[res
.size()]);
代码示例来源:origin: apache/zookeeper
/**
* maintains a list of last <i>committedLog</i>
* or so committed requests. This is used for
* fast follower synchronization.
* @param request committed request
*/
public void addCommittedProposal(Request request) {
WriteLock wl = logLock.writeLock();
try {
wl.lock();
if (committedLog.size() > commitLogCount) {
committedLog.removeFirst();
minCommittedLog = committedLog.getFirst().packet.getZxid();
}
if (committedLog.isEmpty()) {
minCommittedLog = request.zxid;
maxCommittedLog = request.zxid;
}
byte[] data = SerializeUtils.serializeRequest(request);
QuorumPacket pp = new QuorumPacket(Leader.PROPOSAL, request.zxid, data, null);
Proposal p = new Proposal();
p.packet = pp;
p.request = request;
committedLog.add(p);
maxCommittedLog = p.packet.getZxid();
} finally {
wl.unlock();
}
}
代码示例来源:origin: apache/kylin
private void buildIndex() {
LinkedList<TreeNode> queue = new LinkedList<>();
queue.add(root);
while (!queue.isEmpty()) {
TreeNode node = queue.removeFirst();
index.put(node.cuboidId, node);
for (TreeNode child : node.children) {
queue.add(child);
}
}
}
代码示例来源:origin: fesh0r/fernflower
private static boolean insertNestedClass(ClassNode root, ClassNode child) {
Set<String> setEnclosing = child.enclosingClasses;
LinkedList<ClassNode> stack = new LinkedList<>();
stack.add(root);
while (!stack.isEmpty()) {
ClassNode node = stack.removeFirst();
if (setEnclosing.contains(node.classStruct.qualifiedName)) {
node.nested.add(child);
child.parent = node;
return true;
}
// note: ordered list
stack.addAll(node.nested);
}
return false;
}
代码示例来源:origin: apache/activemq
public LinkedList<String> getPeerBrokers() {
synchronized (peerBrokers) {
if (peerBrokers.isEmpty()) {
peerBrokers.add(brokerService.getDefaultSocketURIString());
}
return peerBrokers;
}
}
代码示例来源:origin: stanfordnlp/CoreNLP
while (!preTerms.isEmpty() && isPunc(preTerms.getFirst())) {
newChildren.add(preTerms.getFirst());
preTerms.removeFirst();
newChildren.add(newChild);
while (!preTerms.isEmpty() && isPunc(preTerms.getLast())) {
temp.addFirst(preTerms.getLast());
preTerms.removeLast();
while (!newChildren.isEmpty() && isPunc(newChildren.getFirst())) {
newChildren.removeFirst();
while (!newChildren.isEmpty() && isPunc(newChildren.getLast())) {
newChildren.removeLast();
代码示例来源:origin: marytts/marytts
public boolean hasMoreData() {
while (!sources.isEmpty() && !((DoubleDataSource) sources.getFirst()).hasMoreData()) {
sources.removeFirst();
}
if (sources.isEmpty())
return false;
return true;
}
代码示例来源:origin: org.springframework.boot/spring-boot
private static List<Configurations> collate(
List<Configurations> orderedConfigurations) {
LinkedList<Configurations> collated = new LinkedList<>();
for (Configurations item : orderedConfigurations) {
if (collated.isEmpty() || collated.getLast().getClass() != item.getClass()) {
collated.add(item);
}
else {
collated.set(collated.size() - 1, collated.getLast().merge(item));
}
}
return collated;
}
代码示例来源:origin: wiztools/rest-client
@Override
public boolean isOldest() {
if(data.isEmpty()) {
return true;
}
return cursor == (data.size() - 1);
}
代码示例来源:origin: apache/incubator-dubbo
Integer old = index;
if (index == null) {
index = history.size() - 1;
} else {
if (up) {
index = index - 1;
if (index < 0) {
index = history.size() - 1;
if (index > history.size() - 1) {
index = 0;
channel.setAttribute(HISTORY_LIST_KEY, history);
if (history.isEmpty()) {
history.addLast(result);
} else if (!result.equals(history.getLast())) {
history.remove(result);
history.addLast(result);
if (history.size() > 10) {
history.removeFirst();
代码示例来源:origin: Activiti/Activiti
protected void flattenTree() {
flattenedList = new LinkedList<ExecutionTreeNode>();
LinkedList<ExecutionTreeNode> nodesToHandle = new LinkedList<ExecutionTreeNode>();
nodesToHandle.add(rootNode);
while (!nodesToHandle.isEmpty()) {
ExecutionTreeNode currentNode = nodesToHandle.pop();
if (reverseOrder) {
flattenedList.addFirst(currentNode);
} else {
flattenedList.add(currentNode);
}
if (currentNode.getChildren() != null && currentNode.getChildren().size() > 0) {
for (ExecutionTreeNode childNode : currentNode.getChildren()) {
nodesToHandle.add(childNode);
}
}
}
flattenedListIterator = flattenedList.iterator();
}
代码示例来源:origin: gchq/Gaffer
public Builder edge(final Edge edge) {
if (entities.isEmpty()) {
entities.add(new AbstractMap.SimpleEntry<>(edge.getMatchedVertexValue(), Sets.newHashSet()));
} else {
verifyEdge(entities.getLast().getKey(), edge);
}
edges.add(Sets.newHashSet(edge));
entities.add(new AbstractMap.SimpleEntry<>(edge.getAdjacentMatchedVertexValue(), Sets.newHashSet()));
return this;
}
代码示例来源:origin: javamelody/javamelody
public void addErrors(List<CounterError> counterErrorList) {
assert errorCounter;
if (counterErrorList.isEmpty()) {
return;
}
synchronized (errors) {
if (!errors.isEmpty() && errors.get(0).getTime() > counterErrorList.get(0).getTime()) {
// tant que faire se peut on les met à peu près dans l'ordre pour le sort ci après
errors.addAll(0, counterErrorList);
} else {
errors.addAll(counterErrorList);
}
if (errors.size() > 1) {
// "sort" a les mêmes performances sur LinkedList que sur ArrayList car il y a un tableau intermédiaire
// (selon Implementation Patterns, Kent Beck)
Collections.sort(errors, new CounterErrorComparator());
while (errors.size() > MAX_ERRORS_COUNT) {
errors.removeFirst();
}
}
}
}
代码示例来源:origin: naman14/Timber
private void cleanUpHistory() {
if (!mHistoryOfNumbers.isEmpty() && mHistoryOfNumbers.size() >= MAX_HISTORY_SIZE) {
for (int i = 0; i < Math.max(1, MAX_HISTORY_SIZE / 2); i++) {
mPreviousNumbers.remove(mHistoryOfNumbers.removeFirst());
}
}
}
}
代码示例来源:origin: apache/activemq
/**
* Creates a MessageAck for all messages contained in deliveredMessages.
* Caller should hold the lock for deliveredMessages.
*
* @param type Ack-Type (i.e. MessageAck.STANDARD_ACK_TYPE)
* @return <code>null</code> if nothing to ack.
*/
private MessageAck makeAckForAllDeliveredMessages(byte type) {
synchronized (deliveredMessages) {
if (deliveredMessages.isEmpty()) {
return null;
}
MessageDispatch md = deliveredMessages.getFirst();
MessageAck ack = new MessageAck(md, type, deliveredMessages.size());
ack.setFirstMessageId(deliveredMessages.getLast().getMessage().getMessageId());
return ack;
}
}
代码示例来源:origin: oracle/opengrok
while (!stack.isEmpty()) {
Group g = stack.getFirst();
stack.removeFirst();
代码示例来源:origin: KronicDeth/intellij-elixir
@Override
public void run() {
main:
while (!siblingList.isEmpty()) {
final Pair<PsiBuilder.Marker, PsiBuilder.Marker> parenPair = parenList.peek();
final int rating = siblingList.getFirst().second;
int count = 0;
for (Pair<PsiBuilder.Marker, Integer> pair : siblingList) {
if (pair.second != rating || parenPair != null && pair.first == parenPair.second) break main;
if (++count >= MAX_CHILDREN_IN_TREE) {
PsiBuilder.Marker parentMarker = pair.first.precede();
parentMarker.setCustomEdgeTokenBinders(WhitespacesBinders.GREEDY_LEFT_BINDER, null);
while (count-- > 0) {
siblingList.removeFirst();
}
parentMarker.done(chunkType);
siblingList.addFirst(Pair.create(parentMarker, rating + 1));
continue main;
}
}
break;
}
}
};
内容来源于网络,如有侵权,请联系作者删除!