List of usage examples for java.util LinkedList addFirst
public void addFirst(E e)
From source file:com.google.ie.business.service.impl.ProjectServiceImpl.java
@SuppressWarnings("unchecked") private void addIdeaToRecentlyPickedIdeaListInCache(Idea ideaToBeAdded) { /* Get the list of recently picked ideas from cache */ LinkedList<Idea> ideas = (LinkedList<Idea>) CacheHelper.getObject(CacheConstants.IDEA_NAMESPACE, CacheConstants.RECENTLY_PICKED_IDEAS); if (ideas != null) { Iterator<Idea> iterator = ideas.iterator(); Idea ideaFromCache = null;/* w w w . j ava2 s . c om*/ /* Iterate to check whether the list already contains the idea */ while (iterator.hasNext()) { ideaFromCache = iterator.next(); String ideaKey = ideaFromCache.getKey(); if (ideaKey.equalsIgnoreCase(ideaToBeAdded.getKey())) { /* * If idea already exists in the list , move it to the head */ ideas.remove(ideaFromCache); ideas.addFirst(ideaFromCache); CacheHelper.putObject(CacheConstants.IDEA_NAMESPACE, CacheConstants.RECENTLY_PICKED_IDEAS, ideas, CacheConstants.RECENTLY_PICKED_IDEAS_EXPIRATION_DELAY); return; } } } /* This is executed if the idea does not already exist in cache */ ideaService.addIdeaToListInCache(ideaToBeAdded, CacheConstants.RECENTLY_PICKED_IDEAS, DEFAULT_NO_OF_RECENT_PROJECTS, CacheConstants.RECENTLY_PICKED_IDEAS_EXPIRATION_DELAY); }
From source file:org.apache.metron.stellar.common.StellarCompiler.java
@Override public void exitFunc_args(StellarParser.Func_argsContext ctx) { final FrameContext.Context context = getArgContext(); expression.tokenDeque.push(new Token<>((tokenDeque, state) -> { LinkedList<Object> args = new LinkedList<>(); while (true) { Token<?> token = popDeque(tokenDeque); if (token.getUnderlyingType().equals(FunctionMarker.class)) { break; } else { args.addFirst(token.getValue()); }//from ww w . jav a2s . c om } tokenDeque.push(new Token<>(args, List.class, context)); }, DeferredFunction.class, context)); }
From source file:org.apache.metron.stellar.common.StellarCompiler.java
@Override public void exitList_entity(StellarParser.List_entityContext ctx) { final FrameContext.Context context = getArgContext(); expression.tokenDeque.push(new Token<>((tokenDeque, state) -> { LinkedList<Object> args = new LinkedList<>(); while (true) { Token<?> token = popDeque(tokenDeque); if (token.getUnderlyingType().equals(FunctionMarker.class)) { break; } else { args.addFirst(token.getValue()); }/*from w ww. j a v a 2s .c o m*/ } tokenDeque.push(new Token<>(args, List.class, context)); }, DeferredFunction.class, context)); }
From source file:com.jaspersoft.jasperserver.api.common.service.impl.JdbcDriverServiceImpl.java
private List<ClassLoader> getAvailableClassLoaders(String driverClass) { LinkedList<ClassLoader> classLoaders = new LinkedList<ClassLoader>(); ClassLoader repositoryClassLoader = getClassLoaderByClassName(driverClass); if (repositoryClassLoader != null) { classLoaders.add(repositoryClassLoader); }/*w w w. j a va 2 s. c o m*/ //Adding system classloader to the start of to the end of list if (systemClassLoaderFirst) { classLoaders.addFirst(getSystemClassLoader()); } else { classLoaders.addLast(getSystemClassLoader()); } return classLoaders; }
From source file:edu.cmu.tetrad.search.SearchGraphUtils.java
public static Graph bestGuessCycleOrientation(Graph graph, IndependenceTest test) { while (true) { List<Node> cycle = GraphUtils.directedCycle(graph); if (cycle == null) { break; }//from ww w . j a v a 2s.c om LinkedList<Node> _cycle = new LinkedList<Node>(cycle); Node first = _cycle.getFirst(); Node last = _cycle.getLast(); _cycle.addFirst(last); _cycle.addLast(first); int _j = -1; double minP = Double.POSITIVE_INFINITY; for (int j = 1; j < _cycle.size() - 1; j++) { int i = j - 1; int k = j + 1; Node x = test.getVariable(_cycle.get(i).getName()); Node y = test.getVariable(_cycle.get(j).getName()); Node z = test.getVariable(_cycle.get(k).getName()); test.isIndependent(x, z, Collections.singletonList(y)); double p = test.getPValue(); if (p < minP) { _j = j; minP = p; } } Node x = _cycle.get(_j - 1); Node y = _cycle.get(_j); Node z = _cycle.get(_j + 1); graph.removeEdge(x, y); graph.removeEdge(z, y); graph.addDirectedEdge(x, y); graph.addDirectedEdge(z, y); } return graph; }
From source file:com.android.deskclock.timer.TimerFullScreenFragment.java
public void updateAllTimesUpTimers() { boolean notifyChange = false; // To avoid race conditions where a timer was dismissed and it is still in the timers list // and can be picked again, create a temporary list of timers to be removed first and // then removed them one by one LinkedList<TimerObj> timesupTimers = new LinkedList<>(); for (int i = 0; i < mAdapter.getCount(); i++) { TimerObj timerObj = mAdapter.getItem(i); if (timerObj.mState == TimerObj.STATE_TIMESUP) { timesupTimers.addFirst(timerObj); notifyChange = true;/* www .j av a2s . c om*/ } } while (timesupTimers.size() > 0) { final TimerObj t = timesupTimers.remove(); onStopButtonPressed(t); } if (notifyChange) { mPrefs.edit().putBoolean(Timers.REFRESH_UI_WITH_LATEST_DATA, true).apply(); } }
From source file:com.openedit.BaseWebPageRequest.java
protected LinkedList getParentsAsList() { LinkedList parents = new LinkedList(); BaseWebPageRequest parent = this; while (parent != null) { parents.addFirst(parent); parent = (BaseWebPageRequest) parent.getParent(); }/* www. j ava2 s . co m*/ return parents; }
From source file:marytts.tools.install.ComponentDescription.java
public LinkedList<String> getInstalledFileNames() { LinkedList<String> files = new LinkedList<String>(); if (installedFilesNames != null) { StringTokenizer st = new StringTokenizer(installedFilesNames, ","); while (st.hasMoreTokens()) { String next = st.nextToken().trim(); if (!"".equals(next)) { files.addFirst(next); // i.e., reverse order }//from www. ja va 2s .c o m } } return files; }
From source file:org.nuxeo.ecm.core.storage.dbs.DBSDocument.java
@Override public String getPath() throws DocumentException { String name = getName();/* ww w . j a v a2 s . c om*/ Document doc = getParent(); if (doc == null) { if ("".equals(name)) { return "/"; // root } else { return name; // placeless, no slash } } LinkedList<String> list = new LinkedList<String>(); list.addFirst(name); while (doc != null) { list.addFirst(doc.getName()); doc = doc.getParent(); } return StringUtils.join(list, '/'); }
From source file:architecture.ee.plugin.impl.PluginManagerImpl.java
public List<ResourceBundle> getPluginResourceBundles(Locale l) { List<ResourceBundle> resources = bundleCache.get(l); if (resources == null) { LinkedList<ResourceBundle> list = new LinkedList<ResourceBundle>(); for (Plugin p : plugins.values()) { try { ResourceBundle b = getPluginResourceBundle(p, l); if (b != null) list.addFirst(b); } catch (Exception e) { log.error(e.getMessage(), e); }//w w w. j a v a2 s.co m } resources = list; bundleCache.put(l, resources); } return resources; }