Java 8 Deque - 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 Deque class.

This code example shows how to use the following methods: getFirst, pop, push
        parse(','); 
        return token;
    } 
 
    private State state() { 
        return states.getFirst();
    } 
 
    private void parse(char c) {
        char real = c;
        switch (c) {
            case ',': 
            case '\n': 
                switch (state()) { 
                    case EXPRESSION:
                    case ARRAY:
                    case STRING:
                    case OBJECT:
                        value += c;
                        break; 

7
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: isEmpty, pop, push
    } 
 
    @Override 
    public Class<?> getType(ConfigVisitor visitor, ConfigVisitorNode previous) {
        Deque<ConfigVisitorNode> nodes = visitor.getCurrentNodes();
        if (nodes.isEmpty())
            throw new IllegalArgumentException("Cannot determine type - insufficient info on configuration!");
 
        ConfigVisitorNode current = nodes.pop();
        try { 
            if (current instanceof TypeProvider) {
                return TypeProvider.class.cast(current).getType(visitor, current);
            } else { 
                return getType(visitor, current);
            } 
        } finally { 
            nodes.push(current);
        } 
 
    } 

8
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: isEmpty, addFirst, peek, peekFirst, removeFirst
 
    private Object next; 
    private boolean nextBlank = true;
 
    public void push(Iterator<?> iterator) {
        iterators.addFirst(iterator);
    } 
 
    @Override 
    public void remove() { 
        throw new UnsupportedOperationException();
    } 
 
    private void moveToNext() { 
        if (nextBlank && !this.iterators.isEmpty()) {
            if (!iterators.peek().hasNext()) {
                iterators.removeFirst();
                moveToNext(); 
            } else { 
                final Object next = iterators.peekFirst().next();

8
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: peek
    public E peek() { 
        Deque<E> st = deque.get();
        if (st == null) {
            return null; 
        } 
        return st.peek();
    } 
 
    public E pop() { 
        Deque<E> st = deque.get();
        if (st == null) {
            throw new EmptyStackException();
        } 
        E val = st.pop();
        if (st.isEmpty()) {
            deque.remove();
        } 
        return val;
    } 
 
Full Snippet Info
7
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: addLast, removeFirst, size
    // correctness that the ring buffer and the frequencies table have 
    // consistent content 
    if (item == null) {
      throw new IllegalArgumentException("null items are not supported");
    } 
    assert ringBuffer.size() <= maxSize;
    if (ringBuffer.size() == maxSize) {
      // evict the oldest entry 
      final T removed = ringBuffer.removeFirst();
      final int newFrequency = frequency(removed) - 1;
      if (newFrequency == 0) {
        // free for GC 
        frequencies.remove(removed);
      } else { 
        frequencies.put(removed, newFrequency);
      } 
    } 
 
    // add the new entry and update frequencies 
    ringBuffer.addLast(item);

7
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
See Code Examples for Java 8 Deque Methods: