Refine search
@Override public List<Cookie> loadForRequest(HttpUrl url) { if (requestCookies.isEmpty()) return Collections.emptyList(); return requestCookies.removeFirst(); } }
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();
@Override public Page getOutput() { if (!outputPages.isEmpty()) { return outputPages.removeFirst(); } return null; }
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; }
/** * Remove all the characters observed. */ public void reset() { while (!prevTwoChars.isEmpty()) { prevTwoChars.removeFirst(); } } }
@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; }
@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; }
/** * 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 } }
@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); } } }
@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; }
/** */ private void changeServer() { if (!backups.isEmpty()) { backups.addLast(primary); primary = backups.removeFirst(); try { ch.close(); } catch (Exception ignored) { } ch = null; } } }
/** * 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 } }
/** * 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 } }
/** * 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()); } } }
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; }
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; }
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; } } }
/** * 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); }
/** * 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 } }
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; } }