List of usage examples for java.util LinkedList clear
public void clear()
From source file:Main.java
public static void main(String[] args) { LinkedList<String> lList = new LinkedList<String>(); lList.add("1"); lList.add("2"); lList.add("3"); lList.add("4"); lList.add("5"); System.out.println("LinkedList contains : " + lList); lList.clear(); System.out.println("LinkedList now contains : " + lList); }
From source file:Main.java
public static void main(String[] args) { // create a LinkedList LinkedList<String> list = new LinkedList<String>(); // add some elements list.add("Hello"); list.add("from java2s.com"); list.add("10"); // print the list System.out.println("LinkedList:" + list); // clear the list list.clear(); // print the list System.out.println("LinkedList:" + list); }
From source file:io.hops.common.INodeUtil.java
public static boolean resolvePathWithNoTransaction(String path, boolean resolveLink, LinkedList<INode> preTxResolvedINodes) throws UnresolvedPathException, StorageException, TransactionContextException { preTxResolvedINodes.clear(); byte[][] components = INode.getPathComponents(path); INode curNode = getRoot();//w w w.j a va2 s .c o m preTxResolvedINodes.add(curNode); if (components.length == 1) { return false; } INodeResolver resolver = new INodeResolver(components, curNode, resolveLink, false); while (resolver.hasNext()) { curNode = resolver.next(); if (curNode != null) { preTxResolvedINodes.add(curNode); } } return preTxResolvedINodes.size() == components.length; }
From source file:org.jsweet.plugin.builder.JSweetBuilder.java
private static void cleanFiles(BuildingContext context) throws CoreException { try {/*from ww w. ja v a 2 s . c o m*/ context.project.deleteMarkers(JSWEET_PROBLEM_MARKER_TYPE, true, IResource.DEPTH_INFINITE); File tsOutDir = new File(context.project.getLocation().toFile(), Preferences.getTsOutputFolder(context.project, context.profile)); LinkedList<File> files = new LinkedList<>(); if (tsOutDir.exists()) { Util.addFiles(".ts", tsOutDir, files); for (File f : files) { FileUtils.deleteQuietly(f); } if (!hasFile(tsOutDir)) { FileUtils.deleteQuietly(tsOutDir); } } files.clear(); File jsOutDir = new File(context.project.getLocation().toFile(), Preferences.getJsOutputFolder(context.project, context.profile)); if (jsOutDir.exists()) { Util.addFiles(".js", jsOutDir, files); Util.addFiles(".js.map", jsOutDir, files); for (File f : files) { FileUtils.deleteQuietly(f); } if (!hasFile(jsOutDir)) { FileUtils.deleteQuietly(jsOutDir); } } context.project.refreshLocal(IResource.DEPTH_INFINITE, null); } catch (NoClassDefFoundError e) { e.printStackTrace(); } }
From source file:org.cloudifysource.usm.USMUtils.java
/********* * Returns the list of parent processes, starting by the child pid and ending with the current pid. * * @param childPid// w w w. j a v a2 s .com * the list starting point. * @param myPid * the curennt process pid. * @return the pid list. * @throws USMException * in case of an error. */ public static List<Long> getProcessParentChain(final long childPid, final long myPid) throws USMException { final LinkedList<Long> list = new LinkedList<Long>(); if (childPid == 0) { logger.warning("The child PID is 0 - this usually means that this USM instance had a problem " + "during startup. Please check the logs for more details."); return list; } long currentPid = childPid; while (currentPid != myPid) { list.add(currentPid); final long ppid = USMUtils.getParentPid(currentPid); if (ppid == 0) { logger.severe("Attempt to create a process chain from child process " + childPid + " this process(" + myPid + "). Process " + childPid + " is not a descendant of this process. Only process " + childPid + " will be included in the chain"); list.clear(); list.add(childPid); return list; } currentPid = ppid; } return list; }
From source file:com.newlandframework.avatarmq.core.MessageCache.java
private void commitMessage(ConcurrentLinkedQueue<T> messages) { LinkedList<T> list = new LinkedList<T>(); list.addAll(messages);//from www. j a va 2 s .c o m cache.clear(); if (list != null && list.size() > 0) { parallelDispatch(list); list.clear(); } }
From source file:com.commander4j.sys.JHostList.java
public LinkedList<JHost> getHosts() { final LinkedList<JHost> temphostlist = new LinkedList<JHost>(); temphostlist.clear(); int s = hosts.size(); if (s > 0) { for (int x = 1; x <= s; x++) { temphostlist.addLast(hosts.get(String.valueOf(x))); }/*from w w w . ja va2s.c o m*/ } return temphostlist; }
From source file:com.icantrap.collections.dawg.DawgBuilder.java
/** * Builds the dawg based on the words added. * * @return the new Dawg instance/*from w w w . ja va 2 s . c o m*/ */ public Dawg build() { compress(); for (Node node : nodeList) node.index = -1; LinkedList<Node> stack = new LinkedList<Node>(); nodeList.clear(); stack.clear(); stack.addLast(root); int index = 0; while (!stack.isEmpty()) { Node ptr = stack.removeFirst(); if (-1 == ptr.index) ptr.index = index++; nodeList.add(ptr); for (Node nextChild : ptr.nextChildren) stack.addLast(nextChild); if (null != ptr.child) stack.addLast(ptr.child); } int[] ints = new int[index]; for (Node node : nodeList) ints[node.index] = node.toInteger(); return new Dawg(ints); }
From source file:org.rhq.core.pc.operation.OperationThreadPoolGateway.java
/** * Will drain the given queue and return its contents. No synchronization is performed on the queue object. After * this returns, the given queue will be empty. * * @param queue the queue to drain of all contents (will never be <code>null</code> but may be empty) * * @return the invocations that were drained from the queue *///ww w .j ava 2s . c om private List<OperationInvocation> drainQueue(Map<Integer, LinkedList<OperationInvocation>> queue) { List<OperationInvocation> contents = new ArrayList<OperationInvocation>(); for (LinkedList<OperationInvocation> resourceOperations : queue.values()) { contents.addAll(resourceOperations); resourceOperations.clear(); } queue.clear(); return contents; }
From source file:automenta.knowtention.channel.LineFileChannel.java
@Override public void run() { FileInputStream fileInputStream = null; FileChannel channel = null;/*from w w w .j a v a2s. c om*/ ByteBuffer buffer = null; LinkedList<String> lines = new LinkedList(); StringBuilder builder = new StringBuilder(); long lastSize = -1, lastLastModified = -1; while (running) { try { Thread.sleep(delayPeriodMS); } catch (InterruptedException ex) { } lines.clear(); try { fileInputStream = new FileInputStream(file); channel = fileInputStream.getChannel(); long lastModified = file.lastModified(); long csize = channel.size(); if ((lastModified == lastLastModified) && (csize == lastSize)) { //also check file update time? fileInputStream.close(); continue; } int currentPos = (int) csize; buffer = channel.map(FileChannel.MapMode.READ_ONLY, 0, csize); buffer.position(currentPos); lastSize = csize; lastLastModified = lastModified; int count = 0; for (long i = csize - 1; i >= 0; i--) { char c = (char) buffer.get((int) i); if (c == '\n') { count++; builder.reverse(); lines.addFirst(builder.toString()); if (count == numLines) { break; } builder.setLength(0); } else builder.append(c); } update(lines); lines.clear(); buffer.clear(); channel.close(); fileInputStream.close(); fileInputStream = null; } catch (Exception ex) { Logger.getLogger(LineFileChannel.class.getName()).log(Level.SEVERE, null, ex); } } try { channel.close(); } catch (IOException ex) { Logger.getLogger(LineFileChannel.class.getName()).log(Level.SEVERE, null, ex); } }