List of usage examples for java.util ArrayDeque ArrayDeque
public ArrayDeque()
From source file:com.google.gwt.emultest.java.util.ArrayDequeTest.java
public void testAdd() throws Exception { Object o1 = new Object(); Object o2 = new Object(); Object o3 = new Object(); ArrayDeque<Object> deque = new ArrayDeque<>(); assertTrue(deque.add(o1));/*w ww. ja v a 2 s.c o m*/ checkDequeSizeAndContent(deque, o1); assertTrue(deque.add(o2)); checkDequeSizeAndContent(deque, o1, o2); assertTrue(deque.add(o3)); checkDequeSizeAndContent(deque, o1, o2, o3); try { deque.add(null); fail(); } catch (NullPointerException expected) { } }
From source file:com.comcast.oscar.dictionary.DictionaryTLV.java
/** * //from ww w . ja v a2 s . c om * @param sTlvDotNotation Example 24.1.3 * @param dsq DictionarySQLQueries * @return ArrayDeque<String> of TLV Names found in Dictionary */ public static ArrayDeque<String> getTypeHierarchyStack(String sTlvDotNotation, DictionarySQLQueries dsq) { boolean localDebug = Boolean.FALSE; ArrayDeque<String> adTypeHierarchyStack = new ArrayDeque<String>(); List<String> lsTlvDotNotation = new ArrayList<String>(); lsTlvDotNotation = Arrays.asList(sTlvDotNotation.split("\\.")); if (debug | localDebug) System.out.println("ConfigrationFileExport.getTlvDefintion(): " + lsTlvDotNotation.toString()); //Get TLV Dictionary for the Top Level JSONObject joTlvDictionary = dsq.getTlvDefinition(Integer.decode(lsTlvDotNotation.get(0))); //Search for TLV Definition if (lsTlvDotNotation.size() == 1) { try { adTypeHierarchyStack.addFirst(joTlvDictionary.getString(Dictionary.TLV_NAME)); } catch (JSONException e) { e.printStackTrace(); } } else if (lsTlvDotNotation.size() >= 1) { try { adTypeHierarchyStack.addFirst(joTlvDictionary.getString(Dictionary.TLV_NAME)); } catch (JSONException e) { e.printStackTrace(); } int iRecursiveSearch = 0; while (iRecursiveSearch < lsTlvDotNotation.size()) { if (debug | localDebug) System.out.println("ConfigrationFileExport.getTlvDefintion(): WHILE-LOOP"); try { if (joTlvDictionary.getString(Dictionary.TYPE).equals(lsTlvDotNotation.get(iRecursiveSearch))) { if (joTlvDictionary.getBoolean(Dictionary.ARE_SUBTYPES)) { try { JSONArray jaTlvDictionary = joTlvDictionary.getJSONArray(Dictionary.SUBTYPE_ARRAY); for (int iIndex = 0; iIndex < jaTlvDictionary.length(); iIndex++) { if (debug | localDebug) System.out.println("ConfigrationFileExport.getTlvDefintion(): FOR-LOOP"); JSONObject joTlvDictionaryTemp = jaTlvDictionary.getJSONObject(iIndex); if (joTlvDictionaryTemp.getString(Dictionary.TYPE) .equals(lsTlvDotNotation.get(iRecursiveSearch + 1))) { joTlvDictionary = joTlvDictionaryTemp; iRecursiveSearch++; try { adTypeHierarchyStack .addFirst(joTlvDictionary.getString(Dictionary.TLV_NAME)); } catch (JSONException e) { e.printStackTrace(); } break; } } } catch (JSONException e) { e.printStackTrace(); } } else { iRecursiveSearch++; } } } catch (JSONException e1) { e1.printStackTrace(); } } } return adTypeHierarchyStack; }
From source file:io.uploader.drive.util.FileUtils.java
public static Queue<Path> getAllFilesPath(Path srcDir, FileFinderOption option) throws IOException { Queue<Path> queue = new ArrayDeque<Path>(); if (srcDir == null || !Files.isDirectory(srcDir)) return queue; TreePathFinder tpf = new TreePathFinder(queue, option); Files.walkFileTree(srcDir, tpf); return queue; }
From source file:com.google.uzaygezen.core.MapNode.java
/** * For testing purposes only.//w w w . j a va 2 s .c o m * * @return the number of nodes in the subtree rooted in this node and the * number of leaves. */ int[] subtreeSizeAndLeafCount() { Deque<MapNode<K, V>> stack = new ArrayDeque<MapNode<K, V>>(); stack.push(this); MapNode<K, V> node; int size = 0; int leafCount = 0; while ((node = stack.poll()) != null) { ++size; if (node.children.isEmpty()) { ++leafCount; } for (MapNode<K, V> child : node.children.values()) { stack.push(child); } } return new int[] { size, leafCount }; }
From source file:org.craftercms.social.domain.UGC.java
public UGC() { ancestors = new ArrayDeque<>(); children = new ArrayDeque<>(); attachments = new ArrayList<>(); user = null;//ww w .j a va2 s .c o m }
From source file:org.apache.oozie.workflow.lite.LiteWorkflowValidator.java
public void validateWorkflow(LiteWorkflowApp app, boolean validateForkJoin) throws WorkflowException { NodeDef startNode = app.getNode(StartNodeDef.START); if (startNode == null) { throw new WorkflowException(ErrorCode.E0700, "no start node"); // shouldn't happen, but just in case... }/*from w w w . ja v a 2 s. c om*/ ForkJoinCount forkJoinCount = new ForkJoinCount(); performBasicValidation(app, startNode, new ArrayDeque<String>(), new HashSet<NodeDef>(), forkJoinCount); if (validateForkJoin) { // don't validate fork/join pairs if the number of forks and joins mismatch if (forkJoinCount.forks != forkJoinCount.joins) { throw new WorkflowException(ErrorCode.E0730); } validateForkJoin(app, startNode, null, null, true, new ArrayDeque<String>(), new HashMap<String, String>(), new HashMap<String, Optional<String>>()); } }
From source file:org.chromium.chrome.browser.download.ui.ThumbnailProviderImpl.java
public ThumbnailProviderImpl(int iconSizePx) { mIconSizePx = iconSizePx;/* ww w . ja va2s.c om*/ mHandler = new Handler(Looper.getMainLooper()); mRequestQueue = new ArrayDeque<>(); mNativeThumbnailProvider = nativeInit(); }
From source file:org.apache.sling.etcd.testing.tree.Node.java
/** * @return the etcd key/* ww w . j ava 2s . co m*/ */ @Nonnull public String path() { return path(path(this, new ArrayDeque<String>())); }
From source file:com.denimgroup.threadfix.framework.impl.rails.RailsControllerParser.java
public static Collection parse(@Nonnull File rootFile) { if (!rootFile.exists() || !rootFile.isDirectory()) { LOG.error("Root file not found or is not directory. Exiting."); return null; }// ww w.j ava2 s .c o m File ctrlDir = new File(rootFile, "app/controllers"); if (!ctrlDir.exists() || !ctrlDir.isDirectory()) { LOG.error("{rootFile}/app/controllers/ not found or is not directory. Exiting."); return null; } Collection<File> rubyFiles = (Collection<File>) FileUtils.listFiles(ctrlDir, new WildcardFileFilter("*_controller.rb"), TrueFileFilter.INSTANCE); RailsControllerParser parser = new RailsControllerParser(); parser.modelMap = RailsModelParser.parse(rootFile); parser.railsControllers = list(); for (File rubyFile : rubyFiles) { parser._continue = true; parser.tokenQueue = new ArrayDeque<String>(); parser.currentRailsController = null; parser.currentCtrlMethod = null; parser.currentParamName = null; EventBasedTokenizerRunner.runRails(rubyFile, parser); if (parser.currentRailsController != null && parser.currentCtrlMethod != null && parser.currentCtrlMethod.getMethodName() != null) { parser.currentRailsController.addControllerMethod(parser.currentCtrlMethod); } if (parser.currentRailsController != null && parser.currentRailsController.getControllerMethods() != null && parser.currentRailsController.getControllerMethods().size() > 0) { parser.currentRailsController.setControllerFile(rubyFile); parser.railsControllers.add(parser.currentRailsController); } } return parser.railsControllers; }
From source file:org.optaplanner.core.impl.solver.termination.UnimprovedTimeMillisSpentScoreDifferenceThresholdTermination.java
@Override public void solvingStarted(DefaultSolverScope solverScope) { bestScoreImprovementHistoryQueue = new ArrayDeque<>(); solverSafeTimeMillis = solverScope.getBestSolutionTimeMillis() + unimprovedTimeMillisSpentLimit; }