@Override protected Deque<Value> newValueChain() { return new ArrayDeque<Value>(); }
private void flushPendingEvent() { while (!pendingEventQueue.isEmpty()) eventQueue.push(pendingEventQueue.removeFirst()); }
/** * Returns an array containing all of the elements in this deque in proper * sequence (from first to last element). * * <p> * The returned array will be "safe" in that no references to it are * maintained by this deque. (In other words, this method must allocate a * new array). The caller is thus free to modify the returned array. * * <p> * This method acts as bridge between array-based and collection-based APIs. * * @return an array containing all of the elements in this deque */ @Override public Object[] toArray() { return copyElements(new Object[size()]); }
pendingEventQueue.addLast(TreeEvent.newVisitEvent(key, null)); break; if (key.equals("value") && !pendingEventQueue.isEmpty()) { TreeEvent e = pendingEventQueue.peekLast(); if (e.event == EventType.VISIT) { pendingEventQueue.removeLast(); pendingEventQueue.addLast(TreeEvent.newVisitEvent(e.nodeName, value)); break;
public void consumeEvent() throws Exception { while ((eventQueue = getNext()) != null) { while (!eventQueue.isEmpty()) { SilkEvent e = null; try { e = eventQueue.getFirst(); } finally { if (e != null) { eventQueue.removeFirst(); handler.handle(e); eventCount++; } } } } }
public void push(SilkFunctionPlugin plugin) { eventQueue.addLast(plugin); }
public ArrayDeque<SilkEvent> getNext() throws ExecutionException { if (eventQueue != null && !eventQueue.isEmpty()) return eventQueue; if (noMoreJob && eventContainer.isEmpty()) return null; try { Future<ArrayDeque<SilkEvent>> container = eventContainer.take(); return container.get(); } catch (InterruptedException e) { if (eventContainer.isEmpty()) return null; else return getNext(); } }
public ArrayDeque<SilkEvent> call() throws Exception { for (int cursor = 0; cursor < cache.size(); cursor++) { try { SilkEvent e = SilkLinePushParser.parseLine(lexer, tokenStream, cache.get(cursor)); if (e != null) { eventQueue.add(e); } } catch (XerialException e) { if (e.getErrorCode() == XerialErrorCode.PARSE_ERROR) _logger.warn(e); else throw e; } } // finished the parsing cache.clear(); if (_logger.isTraceEnabled()) _logger.trace(String.format("finished workder=%d. event queue size = %d", lsn, eventQueue.size())); return eventQueue; }
while ((token = _lexer.nextToken()) != Token.EOF_TOKEN) { if (getCurrentParseState() == ParseState.KeyedValue) { keyStack.removeLast(); popParseState(); if (getCurrentParseState() == ParseState.Key) keyStack.addLast(unescapeString(token.getText())); continue;
/** * Pops an element from the stack represented by this deque. In other words, * removes and returns the first element of this deque. * * <p> * This method is equivalent to {@link #removeFirst()}. * * @return the element at the front of this deque (which is the top of the * stack represented by this deque) * @throws NoSuchElementException * {@inheritDoc} */ public E pop() { return removeFirst(); }
void emit(JSONToken type) { tokenQueue.add(new Token(type, null)); }
/** * Retrieves, but does not remove, the head of the queue represented by this * deque. This method differs from {@link #peek peek} only in that it throws * an exception if this deque is empty. * * <p> * This method is equivalent to {@link #getFirst}. * * @return the head of the queue represented by this deque * @throws NoSuchElementException * {@inheritDoc} */ public E element() { return getFirst(); }
/** * Serialize this deque. * * @serialData The current size (<tt>int</tt>) of the deque, followed by all * of its elements (each an object reference) in first-to-last * order. */ private void writeObject(ObjectOutputStream s) throws IOException { s.defaultWriteObject(); // Write out size s.writeInt(size()); // Write out elements in order. int mask = elements.length - 1; for (int i = head; i != tail; i = (i + 1) & mask) s.writeObject(elements[i]); }
private ParseState getCurrentParseState() { return parseStateStack.getLast(); }
public void resetMarks() { markQueue.clear(); }