Java 8 ArrayDeque - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Java 8 ArrayDeque class.

This code example shows how to use the following methods:
        + "For more info see javadoc for Matchers class."; 
    assertThat(actual.getMessage()).isEqualTo(expected);
  } 
 
  @Test public void toStringFormat() { 
    Deque<StackTrace.Element> elements = new ArrayDeque<StackTrace.Element>();
 
    StackTrace onlyClass = new StackTrace("java.lang.NullPointerException", null, elements, null);
    assertThat(onlyClass.toString()).isEqualTo("java.lang.NullPointerException");
 
    StackTrace onlyMessage = new StackTrace(null, "Hello, World!", elements, null);
    assertThat(onlyMessage.toString()).isEqualTo("Hello, World!");
 
    StackTrace both = new StackTrace("java.lang.NullPointerException", "Hi, Mom!", elements, null);
    assertThat(both.toString()).isEqualTo("java.lang.NullPointerException: Hi, Mom!");
  } 
} 
7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:
    private final ThreadLocal<Deque<E>> deque = new ThreadLocal<Deque<E>>();
 
    public void push(E item) {
        Deque<E> st = deque.get();
        if (st == null) {
            st = new ArrayDeque<E>();
            deque.set(st);
        } 
        st.push(item);
    } 
 
    public E peek() { 
        Deque<E> st = deque.get();
        if (st == null) {
            return null; 
        } 
        return st.peek();
    } 
 
    public E pop() { 
7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:addLast, removeFirst, size
    public void logManagingTrust(int userId, ComponentName agent, boolean managing) {
        addEvent(new Event(TYPE_MANAGING_TRUST, userId, agent, null, 0, false, managing));
    } 
 
    private void addEvent(Event e) {
        if (mEvents.size() >= HISTORY_LIMIT) {
            mEvents.removeFirst();
        } 
        mEvents.addLast(e);
    } 
 
    public void dump(PrintWriter writer, int limit, int userId, String linePrefix,
            boolean duplicateSimpleNames) {
        int count = 0;
        Iterator<Event> iter = mEvents.descendingIterator();
        while (iter.hasNext() && count < limit) {
            Event ev = iter.next();
            if (userId != UserHandle.USER_ALL && userId != ev.userId) {
                continue; 
            } 
7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:
import java.util.ArrayDeque;
import java.util.Queue;
 
public class ReadOnlyDirectByteBufferBufTest { 
 
    private final Queue<ByteBuf> buffers = new ArrayDeque<ByteBuf>();
    protected ByteBuf buffer(ByteBuffer buffer) {
        return new ReadOnlyByteBufferBuf(UnpooledByteBufAllocator.DEFAULT, buffer);
    } 
 
    protected ByteBuffer allocate(int size) {
        return ByteBuffer.allocateDirect(size);
    } 
 
    @After 
    public void dispose() { 
       for (;;) { 
           ByteBuf buf = buffers.poll();
           if (buf == null) {
               break; 
7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:
        + "For more info see javadoc for Matchers class."; 
    assertThat(actual.getMessage()).isEqualTo(expected);
  } 
 
  @Test public void toStringFormat() {
    Deque<StackTrace.Element> elements = new ArrayDeque<StackTrace.Element>();
 
    StackTrace onlyClass = new StackTrace("java.lang.NullPointerException", null, elements, null);
    assertThat(onlyClass.toString()).isEqualTo("java.lang.NullPointerException");
 
    StackTrace onlyMessage = new StackTrace(null, "Hello, World!", elements, null);
    assertThat(onlyMessage.toString()).isEqualTo("Hello, World!");
 
    StackTrace both = new StackTrace("java.lang.NullPointerException", "Hi, Mom!", elements, null);
    assertThat(both.toString()).isEqualTo("java.lang.NullPointerException: Hi, Mom!");
  } 
} 
6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:
  /** 
   * Initialize a new {@link FILOScheduler}. 
   */ 
  public FILOScheduler() 
  { 
    _stack = new ArrayDeque<Instruction>(); 
  } 
 
  public void scheduleInstructions(List<Instruction> instructions) 
  { 
    _stack.addAll(instructions);  /* adds to last */ 
  } 
 
  public boolean hasNext() 
  { 
    return !_stack.isEmpty(); 
  } 
 
  public Instruction next() 
  { 
7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:
        PASS_THROUGH,
        AWAIT_HEADERS,
        AWAIT_CONTENT
    } 
 
    private final Queue<CharSequence> acceptEncodingQueue = new ArrayDeque<CharSequence>();
    private CharSequence acceptEncoding;
    private EmbeddedChannel encoder;
    private State state = State.AWAIT_HEADERS;
 
    @Override 
    public boolean acceptOutboundMessage(Object msg) throws Exception {
        return msg instanceof HttpContent || msg instanceof HttpResponse;
    } 
 
    @Override 
    protected void decode(ChannelHandlerContext ctx, HttpRequest msg, List<Object> out)
            throws Exception {
        CharSequence acceptedEncoding = msg.headers().get(HttpHeaderNames.ACCEPT_ENCODING);
        if (acceptedEncoding == null) {
7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:add, remove, size
        deque.clear();
    } 
 
    public void add(double o)
    { 
        if (size == deque.size())
        { 
            deque.remove();
        } 
        deque.add(o);
    } 
} 
6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:
	public final Message<?> receive(long timeout) { 
		ChannelInterceptorList interceptorList = this.getInterceptors(); 
		Deque<ChannelInterceptor> interceptorStack = null; 
		try { 
			if (interceptorList.getInterceptors().size() > 0) { 
				interceptorStack = new ArrayDeque<ChannelInterceptor>(); 
 
				if (!interceptorList.preReceive(this, interceptorStack)) { 
					return null; 
				} 
			} 
			Message<?> message = this.doReceive(timeout); 
			message = interceptorList.postReceive(message, this); 
			if (interceptorStack != null) { 
				interceptorList.afterReceiveCompletion(message, this, null, interceptorStack); 
			} 
			return message; 
		} 
		catch (RuntimeException e) { 
			if (interceptorStack != null) { 

6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:
package cucumber.runtime.io; 
 
import java.util.ArrayDeque;
import java.util.Deque;
import java.util.Iterator;
import java.util.NoSuchElementException;
 
public class FlatteningIterator implements Iterator {
    private final Deque<Iterator<?>> iterators = new ArrayDeque<Iterator<?>>();
 
    private Object next; 
    private boolean nextBlank = true;
 
    public void push(Iterator<?> iterator) {
        iterators.addFirst(iterator);
    } 
 
    @Override 
    public void remove() { 
        throw new UnsupportedOperationException();

6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
See Code Examples for Java 8 ArrayDeque Methods: