本文整理了Java中java.util.LinkedList.poll()
方法的一些代码示例,展示了LinkedList.poll()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。LinkedList.poll()
方法的具体详情如下:
包路径:java.util.LinkedList
类名称:LinkedList
方法名:poll
[英]Retrieves and removes the head (first element) of this list.
[中]检索并删除此列表的标题(第一个元素)。
代码示例来源:origin: nutzam/nutz
public char poll() {
char x = (char) cursor;
try {
if(cache.isEmpty()){
cursor = reader.read();
} else {
cursor = cache.poll();
}
} catch (IOException e) {
log.debug("read error", e);
}
return x;
}
代码示例来源:origin: alibaba/canal
public void prepare() throws InterruptedException {
for (int i = this.currentSize; i < batchFileSize && !binlogList.isEmpty(); i++) {
BinlogFile binlogFile = null;
while (!binlogList.isEmpty()) {
binlogFile = binlogList.poll();
if (!binlogFile.getHostInstanceID().equalsIgnoreCase(hostId)) {
continue;
}
break;
}
if (binlogFile == null) {
break;
}
this.downloadQueue.put(binlogFile);
this.lastDownload = "mysql-bin." + binlogFile.getFileName();
this.currentSize++;
}
}
代码示例来源:origin: goldmansachs/gs-collections
private static List<Class<?>> getInterfaces(Class<?> testClass)
{
LinkedList<Class<?>> queue = new LinkedList<Class<?>>();
queue.add(testClass);
Set<Class<?>> visited = new HashSet<Class<?>>();
visited.add(testClass);
List<Class<?>> results = new ArrayList<Class<?>>();
while (!queue.isEmpty())
{
Class<?> anInterface = queue.poll();
results.add(anInterface);
Class<?>[] parentInterfaces = anInterface.getInterfaces();
for (Class<?> parentInterface : parentInterfaces)
{
if (!visited.contains(parentInterface))
{
visited.add(parentInterface);
queue.add(parentInterface);
}
}
}
return results;
}
}
代码示例来源:origin: apache/hive
public ASTNode depthFirstSearch(ASTNode ast, int token) {
searchQueue.clear();
searchQueue.add(ast);
while (!searchQueue.isEmpty()) {
ASTNode next = searchQueue.poll();
if (next.getType() == token) return next;
for (int j = 0; j < next.getChildCount(); ++j) {
searchQueue.add((ASTNode) next.getChild(j));
}
}
return null;
}
代码示例来源:origin: eclipse/eclipse-collections
private static List<Class<?>> getInterfaces(Class<?> testClass)
{
LinkedList<Class<?>> queue = new LinkedList<>();
queue.add(testClass);
Set<Class<?>> visited = new HashSet<>();
visited.add(testClass);
List<Class<?>> results = new ArrayList<>();
while (!queue.isEmpty())
{
Class<?> anInterface = queue.poll();
results.add(anInterface);
Class<?>[] parentInterfaces = anInterface.getInterfaces();
for (Class<?> parentInterface : parentInterfaces)
{
if (!visited.contains(parentInterface))
{
visited.add(parentInterface);
queue.add(parentInterface);
}
}
}
return results;
}
}
代码示例来源:origin: apache/hive
public ASTNode simpleBreadthFirstSearchAny(ASTNode ast, int... tokens) {
searchQueue.clear();
searchQueue.add(ast);
while (!searchQueue.isEmpty()) {
ASTNode next = searchQueue.poll();
for (int i = 0; i < tokens.length; ++i) {
if (next.getType() == tokens[i]) return next;
}
for (int i = 0; i < next.getChildCount(); ++i) {
searchQueue.add((ASTNode) next.getChild(i));
}
}
return null;
}
代码示例来源:origin: apache/incubator-gobblin
/**
* Get the ancestors of a given set of {@link DagNode}s in the {@link Dag}.
* @param dagNodes set of nodes in the {@link Dag}.
* @return the union of all ancestors of dagNodes in the dag.
*/
private Set<DagNode<T>> getAncestorNodes(Set<DagNode<T>> dagNodes) {
Set<DagNode<T>> ancestorNodes = new HashSet<>();
for (DagNode<T> dagNode : dagNodes) {
LinkedList<DagNode<T>> nodesToExpand = Lists.newLinkedList(this.getParents(dagNode));
while (!nodesToExpand.isEmpty()) {
DagNode<T> nextNode = nodesToExpand.poll();
ancestorNodes.add(nextNode);
nodesToExpand.addAll(this.getParents(nextNode));
}
}
return ancestorNodes;
}
代码示例来源:origin: FudanNLP/fnlp
public static void main(String args[]) throws IOException{
FileGroupReader fgr = new FileGroupReader("F:\\媒体 学习\\研一(下)\\cc");
EntityGroup eg=null;Instance in = null;int i = 0;int j = 0;
while(!fgr.list.isEmpty())
{ in= fgr.list.poll();eg=(EntityGroup) in.getData();
if(in.getTarget().toString().equals("1")){i++;
}
else
j++;
}
System.out.print(i);
System.out.print("\n");
System.out.print(j);
}
}
代码示例来源:origin: apache/drill
public ASTNode depthFirstSearch(ASTNode ast, int token) {
searchQueue.clear();
searchQueue.add(ast);
while (!searchQueue.isEmpty()) {
ASTNode next = searchQueue.poll();
if (next.getType() == token) return next;
for (int j = 0; j < next.getChildCount(); ++j) {
searchQueue.add((ASTNode) next.getChild(j));
}
}
return null;
}
代码示例来源:origin: stanfordnlp/CoreNLP
g.hasTwin = true;
goldMentionHeadPositions.get(g.headIndex).remove(g);
if(goldMentionHeadPositions.get(g.headIndex).isEmpty()) {
goldMentionHeadPositions.remove(g.headIndex);
Mention g = goldMentionHeadPositions.get(r.headIndex).poll();
r.mentionID = g.mentionID;
r.hasTwin = true;
g.hasTwin = true;
if(goldMentionHeadPositions.get(g.headIndex).isEmpty()) {
goldMentionHeadPositions.remove(g.headIndex);
代码示例来源:origin: aws/aws-sdk-java
/**
* Attempts to satisfy some or all of the already-issued futures from the local buffer. If the
* buffer is empty or there are no futures, this method won't do anything.
*/
private void satisfyFuturesFromBuffer() {
synchronized (futures) {
synchronized (finishedTasks) {
// attempt to satisfy futures until we run out of either futures or
// finished tasks
while ((!futures.isEmpty()) && (!finishedTasks.isEmpty())) {
// Remove any expired tasks before attempting to fufill the future
pruneExpiredTasks();
// Fufill the future from a non expired task if there is one. There is still a
// slight chance that the first task could have expired between the time we
// pruned and the time we fufill the future
if (!finishedTasks.isEmpty()) {
fufillFuture(futures.poll());
}
}
}
}
}
代码示例来源:origin: stanfordnlp/CoreNLP
g.twinless = false;
goldMentionHeadPositions.get(g.headIndex).remove(g);
if(goldMentionHeadPositions.get(g.headIndex).isEmpty()) {
goldMentionHeadPositions.remove(g.headIndex);
Mention g = goldMentionHeadPositions.get(r.headIndex).poll();
r.mentionID = g.mentionID;
r.twinless = false;
g.twinless = false;
if(goldMentionHeadPositions.get(g.headIndex).isEmpty()) {
goldMentionHeadPositions.remove(g.headIndex);
代码示例来源:origin: apache/hive
private void setUpAcls(String path) throws Exception {
List<ACL> acls = createSecureAcls();
LinkedList<String> paths = new LinkedList<>();
paths.add(path);
while (!paths.isEmpty()) {
String currentPath = paths.poll();
List<String> children = zooKeeperClient.getChildren().forPath(currentPath);
if (children != null) {
for (String child : children) {
paths.add(currentPath + "/" + child);
}
}
zooKeeperClient.setACL().withACL(acls).forPath(currentPath);
}
}
代码示例来源:origin: apache/drill
public ASTNode simpleBreadthFirstSearchAny(ASTNode ast, int... tokens) {
searchQueue.clear();
searchQueue.add(ast);
while (!searchQueue.isEmpty()) {
ASTNode next = searchQueue.poll();
for (int i = 0; i < tokens.length; ++i) {
if (next.getType() == tokens[i]) return next;
}
for (int i = 0; i < next.getChildCount(); ++i) {
searchQueue.add((ASTNode) next.getChild(i));
}
}
return null;
}
代码示例来源:origin: apache/hive
if (!asyncRequests.isEmpty()) {
if (!session.tryUse(false)) {
return true; // Session has expired and will be returned to us later.
future = asyncRequests.poll();
代码示例来源:origin: neo4j/neo4j
if ( currentLayer.isEmpty() )
if ( nextLayer.isEmpty() )
++depth;
Node node = currentLayer.poll();
代码示例来源:origin: nutzam/nutz
if(opts.isEmpty()){
opts.addFirst(current);
return;
while(!opts.isEmpty() && !(opts.peek() instanceof LBracketOpt)){
rpn.add(opts.poll());
opts.poll();
return;
if(!opts.isEmpty() && opts.peek().fetchPriority() > current.fetchPriority()){
opts.addFirst(current);
return;
rpn.add(opts.poll());
break;
rpn.add(opts.poll());
代码示例来源:origin: oracle/opengrok
/**
* Decomposes the provided {@code query} into terms with the exception of {@link PhraseQuery}. Is useful when
* determining which terms should not be suggested. {@link PhraseQuery} is exempted because not suggesting some
* term which were contained in it is invalid.
* @param query query to decompose
* @return terms that were in the {@code query}
*/
public static List<Term> intoTermsExceptPhraseQuery(final Query query) {
if (query == null) {
return Collections.emptyList();
}
List<Term> terms = new LinkedList<>();
LinkedList<Query> queue = new LinkedList<>();
queue.add(query);
while (!queue.isEmpty()) {
Query q = queue.poll();
if (q instanceof BooleanQuery) {
for (BooleanClause bc : ((BooleanQuery) q).clauses()) {
queue.add(bc.getQuery());
}
} else if (q instanceof TermQuery) {
terms.add(((TermQuery) q).getTerm());
}
}
return terms;
}
代码示例来源:origin: oracle/opengrok
/**
* Decomposes the provided {@code query} into terms.
* @param query query to decompose
* @return terms that were in the {@code query}
*/
public static List<Term> intoTerms(final Query query) {
if (query == null) {
return Collections.emptyList();
}
List<Term> terms = new LinkedList<>();
LinkedList<Query> queue = new LinkedList<>();
queue.add(query);
while (!queue.isEmpty()) {
Query q = queue.poll();
if (q instanceof BooleanQuery) {
for (BooleanClause bc : ((BooleanQuery) q).clauses()) {
queue.add(bc.getQuery());
}
} else if (q instanceof TermQuery) {
terms.add(((TermQuery) q).getTerm());
} else if (q instanceof PhraseQuery) {
terms.addAll(Arrays.asList(((PhraseQuery) q).getTerms()));
}
}
return terms;
}
代码示例来源:origin: apache/hive
while (!directories.isEmpty()) {
Path dir = directories.poll();
FileStatus[] contents = fileSystem.listStatus(dir);
if (contents == null) {
内容来源于网络,如有侵权,请联系作者删除!