@SuppressWarnings("unchecked") public static List<Class<?>> getInterfaceHierarchy(Class<?> srcClass, BeanContainer beanContainer) { final List<Class<?>> result = new LinkedList<>(); Class<?> realClass = getRealClass(srcClass, beanContainer); final LinkedList<Class> interfacesToProcess = new LinkedList<>(); Class[] interfaces = realClass.getInterfaces(); interfacesToProcess.addAll(Arrays.asList(interfaces)); while (!interfacesToProcess.isEmpty()) { Class<?> iface = interfacesToProcess.remove(); if (!result.contains(iface)) { result.add(iface); for (Class subiface : iface.getInterfaces()) { // if we haven't processed this interface yet then add it to be processed if (!result.contains(subiface)) { interfacesToProcess.add(subiface); } } } } return result; }
goldMentionHeadPositions.put(g.headIndex, new LinkedList<>()); goldMentionHeadPositions.get(g.headIndex).add(g); p.twinless = false; g.twinless = false; goldMentionHeadPositions.get(g.headIndex).remove(g); if(goldMentionHeadPositions.get(g.headIndex).isEmpty()) { goldMentionHeadPositions.remove(g.headIndex); r.twinless = false; g.twinless = false; if(goldMentionHeadPositions.get(g.headIndex).isEmpty()) { goldMentionHeadPositions.remove(g.headIndex);
public int getPreviousPlayPosition(boolean removeFromHistory) { synchronized (this) { if (mShuffleMode == SHUFFLE_NORMAL) { final int histsize = mHistory.size(); if (histsize == 0) { return -1; } final Integer pos = mHistory.get(histsize - 1); if (removeFromHistory) { mHistory.remove(histsize - 1); } return pos.intValue(); } else { if (mPlayPos > 0) { return mPlayPos - 1; } else { return mPlaylist.size() - 1; } } } }
if (index > history.size() - 1) { index = 0; String value = history.get(index); if (old != null && old >= 0 && old < history.size()) { String ov = history.get(old); StringBuilder buf = new StringBuilder(); for (int i = 0; i < ov.length(); i++) { channel.removeAttribute(HISTORY_INDEX_KEY); if (CollectionUtils.isNotEmpty(history) && index != null && index >= 0 && index < history.size()) { String value = history.get(index); if (value != null) { byte[] b1 = value.getBytes(); 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) {
private void finder1(PegCallGraph pcg) { Set clinitMethods = pcg.getClinitMethods(); Iterator it = pcg.iterator(); while (it.hasNext()) { Object head = it.next(); // breadth first scan Set<Object> gray = new HashSet<Object>(); LinkedList<Object> queue = new LinkedList<Object>(); queue.add(head); while (queue.size() > 0) { Object root = queue.getFirst(); Iterator succsIt = pcg.getSuccsOf(root).iterator(); while (succsIt.hasNext()) { Object succ = succsIt.next(); if (!gray.contains(succ)) { gray.add(succ); queue.addLast(succ); } else if (clinitMethods.contains(succ)) { continue; } else { multiCalledMethods.add((SootMethod) succ); } } queue.remove(root); } } }
int nextIdx = dataPages.indexOf(currentPage) + 1; if (destructive && currentPage != null) { dataPages.remove(currentPage); freePage(currentPage); nextIdx --; if (dataPages.size() > nextIdx) { currentPage = dataPages.get(nextIdx); pageBaseObject = currentPage.getBaseObject(); offsetInPage = currentPage.getBaseOffset();
/** * Returns the next key that was typed by the user (that your program has not already processed). * This method should be preceded by a call to {@link #hasNextKeyTyped()} to ensure * that there is a next key to process. * This method returns a Unicode character corresponding to the key * typed (such as {@code 'a'} or {@code 'A'}). * It cannot identify action keys (such as F1 and arrow keys) * or modifier keys (such as control). * * @return the next key typed by the user (that your program has not already processed). * @throws NoSuchElementException if there is no remaining key */ public static char nextKeyTyped() { synchronized (keyLock) { if (keysTyped.isEmpty()) { throw new NoSuchElementException("your program has already processed all keystrokes"); } return keysTyped.remove(keysTyped.size() - 1); // return keysTyped.removeLast(); } }
private void flush(LinkedList<Request> toFlush) throws IOException, RequestProcessorException { if (toFlush.isEmpty()) return; zks.getZKDatabase().commit(); while (!toFlush.isEmpty()) { Request i = toFlush.remove(); if (nextProcessor != null) { nextProcessor.processRequest(i); } } if (nextProcessor != null && nextProcessor instanceof Flushable) { ((Flushable)nextProcessor).flush(); } }
LinkedList<Integer> pathStackIndex = new LinkedList<Integer>(); pathStack.add(from); pathStackIndex.add(new Integer(0)); int psiMax = (g.getSuccsOf(pathStack.get(0))).size(); int level = 0; while (pathStackIndex.get(0).intValue() != psiMax) { int p = (pathStackIndex.get(level)).intValue(); List<Unit> succs = g.getSuccsOf((pathStack.get(level))); pathStack.remove(level); pathStackIndex.remove(level); pathStack.add(to); return pathStack;
public synchronized SelectorSelection register(AbstractSelectableChannel selectableChannel, Listener listener) throws IOException { SelectorSelection selection = null; while (selection == null) { if (freeWorkers.size() > 0) { SelectorWorker worker = freeWorkers.getFirst(); if (worker.isReleased()) { freeWorkers.remove(worker); } else { worker.retain(); selection = new SelectorSelection(worker, selectableChannel, listener); } } else { // Worker starts /w retain count of 1 SelectorWorker worker = new SelectorWorker(this); freeWorkers.addFirst(worker); selection = new SelectorSelection(worker, selectableChannel, listener); } } return selection; }
/** * If available, get a free connection for this host * * @param hostConfiguration the configuraton for the connection pool * @return an available connection for the given config */ public synchronized HttpConnection getFreeConnection(HostConfiguration hostConfiguration) { HttpConnectionWithReference connection = null; HostConnectionPool hostPool = getHostPool(hostConfiguration, false); if ((hostPool != null) && (hostPool.freeConnections.size() > 0)) { connection = (HttpConnectionWithReference) hostPool.freeConnections.removeLast(); freeConnections.remove(connection); // store a reference to this connection so that it can be cleaned up // in the event it is not correctly released storeReferenceToConnection(connection, hostConfiguration, this); if (LOG.isDebugEnabled()) { LOG.debug("Getting free connection, hostConfig=" + hostConfiguration); } // remove the connection from the timeout handler idleConnectionHandler.remove(connection); } else if (LOG.isDebugEnabled()) { LOG.debug("There were no free connections to get, hostConfig=" + hostConfiguration); } return connection; }
private static Statement findFirstBlock(Statement stat, Set<Statement> setStats) { LinkedList<Statement> stack = new LinkedList<>(); stack.add(stat); while (!stack.isEmpty()) { Statement st = stack.remove(0); if (stack.isEmpty() || setStats.contains(st)) { if (st.isLabeled() && !stack.isEmpty() || st.getExprents() != null) { return st; } stack.clear(); switch (st.type) { case Statement.TYPE_SEQUENCE: stack.addAll(0, st.getStats()); break; case Statement.TYPE_IF: case Statement.TYPE_ROOT: case Statement.TYPE_SWITCH: case Statement.TYPE_SYNCRONIZED: stack.add(st.getFirst()); break; default: return st; } } } return null; }
goldMentionHeadPositions.put(g.headIndex, new LinkedList<>()); goldMentionHeadPositions.get(g.headIndex).add(g); p.hasTwin = true; g.hasTwin = true; goldMentionHeadPositions.get(g.headIndex).remove(g); if(goldMentionHeadPositions.get(g.headIndex).isEmpty()) { goldMentionHeadPositions.remove(g.headIndex); r.hasTwin = true; g.hasTwin = true; if(goldMentionHeadPositions.get(g.headIndex).isEmpty()) { goldMentionHeadPositions.remove(g.headIndex);
public int getPreviousPlayPosition(boolean removeFromHistory) { synchronized (this) { if (mShuffleMode == SHUFFLE_NORMAL) { final int histsize = mHistory.size(); if (histsize == 0) { return -1; } final Integer pos = mHistory.get(histsize - 1); if (removeFromHistory) { mHistory.remove(histsize - 1); } return pos.intValue(); } else { if (mPlayPos > 0) { return mPlayPos - 1; } else { return mPlaylist.size() - 1; } } } }