private AST pop() { if ( parents.size() == 0 ) { return null; } else { return parents.removeFirst(); } }
/** * Retrieves and removes an extracted message from the accumulated buffer * or returns null if there are no more messages. */ public Message getMessage() { if( messages.isEmpty() ) { return null; } return messages.removeFirst(); }
public void samplingInMinutes() { synchronized (this.csListHour) { this.csListHour.add(new CallSnapshot(System.currentTimeMillis(), this.times.get(), this.value .get())); if (this.csListHour.size() > 7) { this.csListHour.removeFirst(); } } }
private synchronized boolean onTransactions(List<Transaction> txs) { if (txs.isEmpty()) return false; long[] gasPrices = new long[txs.size()]; for (int i = 0; i < txs.size(); ++i) { gasPrices[i] = ByteUtil.byteArrayToLong(txs.get(i).getGasPrice()); } blockGasPrices.add(gasPrices); while (blockGasPrices.size() > getMinBlocks() && (calcGasPricesSize() - blockGasPrices.getFirst().length) >= getMinTransactions()) { blockGasPrices.removeFirst(); } return true; }
private void buildIndex() { LinkedList<TreeNode> queue = new LinkedList<>(); queue.add(root); while (!queue.isEmpty()) { TreeNode node = queue.removeFirst(); index.put(node.cuboidId, node); for (TreeNode child : node.children) { queue.add(child); } } }
Integer old = index; if (index == null) { index = history.size() - 1; } else { if (up) { index = index - 1; if (index < 0) { index = history.size() - 1; if (index > history.size() - 1) { index = 0; channel.setAttribute(HISTORY_LIST_KEY, history); if (history.isEmpty()) { history.addLast(result); } else if (!result.equals(history.getLast())) { history.remove(result); history.addLast(result); if (history.size() > 10) { history.removeFirst();
private static boolean insertNestedClass(ClassNode root, ClassNode child) { Set<String> setEnclosing = child.enclosingClasses; LinkedList<ClassNode> stack = new LinkedList<>(); stack.add(root); while (!stack.isEmpty()) { ClassNode node = stack.removeFirst(); if (setEnclosing.contains(node.classStruct.qualifiedName)) { node.nested.add(child); child.parent = node; return true; } // note: ordered list stack.addAll(node.nested); } return false; }
@Override public void run() { snapshotList.addLast(statsBenchmark.createSnapshot()); if (snapshotList.size() > 10) { snapshotList.removeFirst(); } } }, 1000, 1000);
public boolean hasMoreData() { while (!sources.isEmpty() && !((DoubleDataSource) sources.getFirst()).hasMoreData()) { sources.removeFirst(); } if (sources.isEmpty()) return false; return true; }
public BitSet getTransitiveOutputSet(int input) { BitSet visited = new BitSet(); BitSet result = new BitSet(); LinkedList<Integer> workList = new LinkedList<>(); workList.addLast(input); while (!workList.isEmpty()) { Integer valueNumber = workList.removeFirst(); visited.set(valueNumber); BitSet outputSet = getOutputSet(valueNumber); result.or(outputSet); for (int i = outputSet.nextSetBit(0); i >= 0; i = outputSet.nextSetBit(i+1)) { if (!visited.get(i)) { workList.addLast(i); } } } return result; }
/** * Makes list of tuples of the given size out of list of words. * * @param words words * @return list of tuples of size {@link #tupleSize} */ private List<String> getTuples(List<String> words) { List<String> result = new ArrayList<String>(); LinkedList<String> tuple = new LinkedList<String>(); Iterator<String> it = words.iterator(); for (int i = 0; i < tupleSize - 1; i++) { tuple.add(it.next()); } while (it.hasNext()) { tuple.addLast(it.next()); result.add(Utilities.join(tuple)); tuple.removeFirst(); } return result; }
private void cleanUpHistory() { if (!mHistoryOfNumbers.isEmpty() && mHistoryOfNumbers.size() >= MAX_HISTORY_SIZE) { for (int i = 0; i < Math.max(1, MAX_HISTORY_SIZE / 2); i++) { mPreviousNumbers.remove(mHistoryOfNumbers.removeFirst()); } } } }
LinkedList<T> queue = new LinkedList<>(); visited.add(o); queue.addLast(o); while (! queue.isEmpty()) { for (T obj : getPredecessors(queue.removeFirst())) { if (! visited.contains(obj)) { visited.add(obj); queue.addLast(obj); result.addFirst(obj);
stack.addLast(g); while (!stack.isEmpty()) { Group g = stack.getFirst(); stack.removeFirst();
import java.util.LinkedList; class Test { public static void main(String args[]) { char arr[] = {3,1,4,1,5,9,2,6,5,3,5,8,9}; LinkedList<Integer> fifo = new LinkedList<Integer>(); for (int i = 0; i < arr.length; i++) fifo.add (new Integer (arr[i])); System.out.print (fifo.removeFirst() + "."); while (! fifo.isEmpty()) System.out.print (fifo.removeFirst()); System.out.println(); } }
if (ll.size() > markovOrder) { ll.removeLast(); ll.addLast(t.getChild(0)); if (ll.size() > markovOrder) { ll.removeFirst();
private Iterator currentIterator() { while ( iteratorStack.size() > 0 ) { Iterator curIter = (Iterator) iteratorStack.getFirst(); if ( curIter.hasNext() ) { return curIter; } iteratorStack.removeFirst(); } return null; }
/** * Walks over the child notes, maintaining the tree order and not using recursion. */ protected void walkDescendantsIteratively(final LinkedList<Node> nodes, final CssSelector cssSelector, final List<Node> result) { while (!nodes.isEmpty()) { Node node = nodes.removeFirst(); selectAndAdd(node, cssSelector, result); // append children in walking order to be processed right after this node int childCount = node.getChildNodesCount(); for (int i = childCount - 1; i >= 0; i--) { nodes.addFirst(node.getChild(i)); } } }
/** * Creates a new iterator representation for all files within a folder. * * @param folder The root folder. */ protected FolderIterator(File folder) { files = new LinkedList<File>(Collections.singleton(folder)); File candidate; do { candidate = files.removeFirst(); File[] file = candidate.listFiles(); if (file != null) { files.addAll(0, Arrays.asList(file)); } } while (!files.isEmpty() && (files.peek().isDirectory() || files.peek().equals(new File(folder, JarFile.MANIFEST_NAME)))); }
public Thread deQ(Thread t) throws IllegalMonitorStateException { if (t != q.getFirst()) { throw new IllegalMonitorStateException(); } return q.removeFirst(); }