本文整理了Java中java.util.Deque.removeFirst()
方法的一些代码示例,展示了Deque.removeFirst()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Deque.removeFirst()
方法的具体详情如下:
包路径:java.util.Deque
类名称:Deque
方法名:removeFirst
[英]Retrieves and removes the first element of this deque. This method differs from #pollFirst only in that it throws an exception if this deque is empty.
[中]检索并删除此数据块的第一个元素。此方法与#pollFirst的不同之处在于,如果此deque为空,则会引发异常。
代码示例来源:origin: square/okhttp
@Override public List<Cookie> loadForRequest(HttpUrl url) {
if (requestCookies.isEmpty()) return Collections.emptyList();
return requestCookies.removeFirst();
}
}
代码示例来源:origin: google/guava
create().equals(new ArrayDeque<>(ImmutableList.of("foo")));
create().hashCode();
create().isEmpty();
create().iterator();
create().remove("foo");
create().offerFirst("e");
create().offerLast("e");
create().removeFirst();
create().removeLast();
create().pollFirst();
代码示例来源:origin: prestodb/presto
@Override
public Page getOutput()
{
if (!outputPages.isEmpty()) {
return outputPages.removeFirst();
}
return null;
}
代码示例来源:origin: google/guava
private @Nullable Iterator<? extends Iterator<? extends T>> getTopMetaIterator() {
while (topMetaIterator == null || !topMetaIterator.hasNext()) {
if (metaIterators != null && !metaIterators.isEmpty()) {
topMetaIterator = metaIterators.removeFirst();
} else {
return null;
}
}
return topMetaIterator;
}
代码示例来源:origin: twosigma/beakerx
/**
* Remove all the characters observed.
*/
public void reset() {
while (!prevTwoChars.isEmpty()) {
prevTwoChars.removeFirst();
}
}
}
代码示例来源:origin: prestodb/presto
@NullableDecl
private Iterator<? extends Iterator<? extends T>> getTopMetaIterator() {
while (topMetaIterator == null || !topMetaIterator.hasNext()) {
if (metaIterators != null && !metaIterators.isEmpty()) {
topMetaIterator = metaIterators.removeFirst();
} else {
return null;
}
}
return topMetaIterator;
}
代码示例来源:origin: google/j2objc
@NullableDecl
private Iterator<? extends Iterator<? extends T>> getTopMetaIterator() {
while (topMetaIterator == null || !topMetaIterator.hasNext()) {
if (metaIterators != null && !metaIterators.isEmpty()) {
topMetaIterator = metaIterators.removeFirst();
} else {
return null;
}
}
return topMetaIterator;
}
代码示例来源:origin: google/guava
/**
* Closes all {@code Closeable} instances that have been added to this {@code Closer}. If an
* exception was thrown in the try block and passed to one of the {@code exceptionThrown} methods,
* any exceptions thrown when attempting to close a closeable will be suppressed. Otherwise, the
* <i>first</i> exception to be thrown from an attempt to close a closeable will be thrown and any
* additional exceptions that are thrown after that will be suppressed.
*/
@Override
public void close() throws IOException {
Throwable throwable = thrown;
// close closeables in LIFO order
while (!stack.isEmpty()) {
Closeable closeable = stack.removeFirst();
try {
closeable.close();
} catch (Throwable e) {
if (throwable == null) {
throwable = e;
} else {
suppressor.suppress(closeable, throwable, e);
}
}
}
if (thrown == null && throwable != null) {
Throwables.propagateIfPossible(throwable, IOException.class);
throw new AssertionError(throwable); // not possible
}
}
代码示例来源:origin: prestodb/presto
@Override
public void close()
throws Exception
{
Throwable rootCause = null;
while (!stack.isEmpty()) {
AutoCloseable closeable = stack.removeFirst();
try {
closeable.close();
}
catch (Throwable t) {
if (rootCause == null) {
rootCause = t;
}
else if (rootCause != t) {
// Self-suppression not permitted
rootCause.addSuppressed(t);
}
}
}
if (rootCause != null) {
propagateIfPossible(rootCause, Exception.class);
// not possible
throw new AssertionError(rootCause);
}
}
}
代码示例来源:origin: wildfly/wildfly
@NullableDecl
private Iterator<? extends Iterator<? extends T>> getTopMetaIterator() {
while (topMetaIterator == null || !topMetaIterator.hasNext()) {
if (metaIterators != null && !metaIterators.isEmpty()) {
topMetaIterator = metaIterators.removeFirst();
} else {
return null;
}
}
return topMetaIterator;
}
代码示例来源:origin: apache/ignite
/** */
private void changeServer() {
if (!backups.isEmpty()) {
backups.addLast(primary);
primary = backups.removeFirst();
try {
ch.close();
}
catch (Exception ignored) {
}
ch = null;
}
}
}
代码示例来源:origin: apache/incubator-druid
/**
* Closes all {@code Closeable} instances that have been added to this {@code Closer}. If an
* exception was thrown in the try block and passed to one of the {@code exceptionThrown} methods,
* any exceptions thrown when attempting to close a closeable will be suppressed. Otherwise, the
* <i>first</i> exception to be thrown from an attempt to close a closeable will be thrown and any
* additional exceptions that are thrown after that will be suppressed.
*/
@Override
public void close() throws IOException
{
Throwable throwable = thrown;
// close closeables in LIFO order
while (!stack.isEmpty()) {
Closeable closeable = stack.removeFirst();
try {
closeable.close();
}
catch (Throwable e) {
if (throwable == null) {
throwable = e;
} else {
suppress(throwable, e);
}
}
}
if (thrown == null && throwable != null) {
Throwables.propagateIfPossible(throwable, IOException.class);
throw new AssertionError(throwable); // not possible
}
}
代码示例来源:origin: google/j2objc
/**
* Closes all {@code Closeable} instances that have been added to this {@code Closer}. If an
* exception was thrown in the try block and passed to one of the {@code exceptionThrown} methods,
* any exceptions thrown when attempting to close a closeable will be suppressed. Otherwise, the
* <i>first</i> exception to be thrown from an attempt to close a closeable will be thrown and any
* additional exceptions that are thrown after that will be suppressed.
*/
@Override
public void close() throws IOException {
Throwable throwable = thrown;
// close closeables in LIFO order
while (!stack.isEmpty()) {
Closeable closeable = stack.removeFirst();
try {
closeable.close();
} catch (Throwable e) {
if (throwable == null) {
throwable = e;
} else {
suppressor.suppress(closeable, throwable, e);
}
}
}
if (thrown == null && throwable != null) {
Throwables.propagateIfPossible(throwable, IOException.class);
throw new AssertionError(throwable); // not possible
}
}
代码示例来源:origin: robolectric/robolectric
/**
* Ends the most recent active trace section.
*
* @throws {@link AssertionError} if called without any active trace section.
*/
@Implementation(minSdk = JELLY_BEAN_MR2)
protected static void endSection() {
if (Trace.isTagEnabled(TRACE_TAG_APP)) {
synchronized (lock) {
if (currentSections.isEmpty()) {
Log.e(TAG, "Trying to end a trace section that was never started");
return;
}
previousSections.offer(currentSections.removeFirst());
}
}
}
代码示例来源:origin: Sable/soot
public static RefType lcsc(RefType a, RefType b, RefType anchor) {
if (a == b) {
return a;
}
Deque<RefType> pathA = superclassPath(a, anchor);
Deque<RefType> pathB = superclassPath(b, anchor);
RefType r = null;
while (!(pathA.isEmpty() || pathB.isEmpty()) && TypeResolver.typesEqual(pathA.getFirst(), pathB.getFirst())) {
r = pathA.removeFirst();
pathB.removeFirst();
}
return r;
}
代码示例来源:origin: Sable/soot
public static RefType lcsc(RefType a, RefType b) {
if (a == b) {
return a;
}
Deque<RefType> pathA = superclassPath(a, null);
Deque<RefType> pathB = superclassPath(b, null);
RefType r = null;
while (!(pathA.isEmpty() || pathB.isEmpty()) && TypeResolver.typesEqual(pathA.getFirst(), pathB.getFirst())) {
r = pathA.removeFirst();
pathB.removeFirst();
}
return r;
}
代码示例来源:origin: embulk/embulk
private boolean nextLine(boolean skipEmptyLine) {
while (true) {
if (!unreadLines.isEmpty()) {
line = unreadLines.removeFirst();
} else {
line = input.poll();
if (line == null) {
return false;
}
}
linePos = 0;
lineNumber++;
boolean skip = skipEmptyLine && (line.isEmpty() || (commentLineMarker != null && line.startsWith(commentLineMarker)));
if (!skip) {
return true;
}
}
}
代码示例来源:origin: square/okhttp
/**
* Removes and returns the stream's received response headers, blocking if necessary until headers
* have been received. If the returned list contains multiple blocks of headers the blocks will be
* delimited by 'null'.
*/
public synchronized Headers takeHeaders() throws IOException {
readTimeout.enter();
try {
while (headersQueue.isEmpty() && errorCode == null) {
waitForIo();
}
} finally {
readTimeout.exitAndThrowIfTimedOut();
}
if (!headersQueue.isEmpty()) {
return headersQueue.removeFirst();
}
throw new StreamResetException(errorCode);
}
代码示例来源:origin: prestodb/presto
/**
* Closes all {@code Closeable} instances that have been added to this {@code Closer}. If an
* exception was thrown in the try block and passed to one of the {@code exceptionThrown} methods,
* any exceptions thrown when attempting to close a closeable will be suppressed. Otherwise, the
* <i>first</i> exception to be thrown from an attempt to close a closeable will be thrown and any
* additional exceptions that are thrown after that will be suppressed.
*/
@Override
public void close() throws IOException {
Throwable throwable = thrown;
// close closeables in LIFO order
while (!stack.isEmpty()) {
Closeable closeable = stack.removeFirst();
try {
closeable.close();
} catch (Throwable e) {
if (throwable == null) {
throwable = e;
} else {
suppressor.suppress(closeable, throwable, e);
}
}
}
if (thrown == null && throwable != null) {
Throwables.propagateIfPossible(throwable, IOException.class);
throw new AssertionError(throwable); // not possible
}
}
代码示例来源:origin: Sable/soot
private <T> Set<T> reachable(T first, DirectedGraph<T> g) {
if (first == null || g == null) {
return Collections.<T>emptySet();
}
Set<T> visited = new HashSet<T>(g.size());
Deque<T> q = new ArrayDeque<T>();
q.addFirst(first);
do {
T t = q.removeFirst();
if (visited.add(t)) {
q.addAll(g.getSuccsOf(t));
}
} while (!q.isEmpty());
return visited;
}
}
内容来源于网络,如有侵权,请联系作者删除!