List of usage examples for java.util LinkedList size
int size
To view the source code for java.util LinkedList size.
Click Source Link
From source file:Main.java
/** * Takes a number of tags of name 'name' that are children of 'root', and * looks for attributes of 'attrib' on them. Converts attributes to an * int and returns in an array.//from w w w . j a v a 2 s .c om */ public static int[] getElementArrayInt(Element root, String name, String attrib) { if (root == null) return null; NodeList nl = root.getChildNodes(); LinkedList<Integer> elementCache = new LinkedList<Integer>(); int size = nl.getLength(); for (int i = 0; i < size; i++) { Node node = nl.item(i); if (!(node instanceof Element)) continue; Element ele = (Element) node; if (!ele.getTagName().equals(name)) continue; String valS = ele.getAttribute(attrib); int eleVal = 0; try { eleVal = Integer.parseInt(valS); } catch (Exception e) { } elementCache.addLast(new Integer(eleVal)); } int[] retArr = new int[elementCache.size()]; Iterator<Integer> it = elementCache.iterator(); int idx = 0; while (it.hasNext()) { retArr[idx++] = it.next().intValue(); } return retArr; }
From source file:jp.co.ctc_g.jse.vid.ViewId.java
private static int size(ViewIdStore store) { int size = 0; synchronized (store.semaphore()) { LinkedList<ViewId> ids = store.find(false); size = ids != null ? ids.size() : 0; }//from www . j a v a 2 s. c o m return size; }
From source file:jp.co.ctc_g.jse.vid.ViewId.java
private static ViewId history(int history, ViewIdStore store) { ViewId id = null;/* w ww . ja v a 2 s. com*/ synchronized (store.semaphore()) { LinkedList<ViewId> ids = store.find(false); id = (ids != null && !ids.isEmpty() && ids.size() > history) ? ids.get(ids.size() - history - 1) : null; } return id; }
From source file:edu.tum.cs.vis.model.util.algorithm.ACCUM.java
/** * Diffuse a vector field at 1 vertex, weighted by a Gaussian of width 1/sqrt(invsigma2) Ported * from trimesh2 (2.12)//from ww w . j av a2 s.co m */ @SuppressWarnings("javadoc") private static void diffuse_vert_field(final Model m, HashMap<Vertex, Curvature> curvatures, Map<Vertex, Long> flags, AtomicLong flag_curr, final ACCUM accum, int v, float invsigma2, Vertex flt) { Vertex vert = m.getVertices().get(v); if (vert.getNeighbors().size() == 0) { // flt.set(0, 0, 0); accum.a(m, curvatures, vert, flt, 1.0f, vert); return; } // flt.set(0, 0, 0); accum.a(m, curvatures, vert, flt, vert.getPointarea(), vert); float sum_w = vert.getPointarea(); final Vector3f nv = vert.getNormalVector(); long flag_curr_val = flag_curr.incrementAndGet(); flags.put(vert, flag_curr_val); LinkedList<Vertex> boundary = new LinkedList<Vertex>(); boundary.addAll(vert.getNeighbors()); while (boundary.size() > 0) { Vertex n = boundary.pop(); if (flags.get(n) != null && flags.get(n) == flag_curr_val) continue; flags.put(n, flag_curr_val); if (nv.dot(n.getNormalVector()) <= 0.0f) continue; // Gaussian weight float w = wt(n, vert, invsigma2); if (w == 0.0f) continue; // Downweight things pointing in different directions w *= nv.dot(n.getNormalVector()); // Surface area "belonging" to each point w *= n.getPointarea(); // Accumulate weight times field at neighbor accum.a(m, curvatures, vert, flt, w, n); sum_w += w; for (Vertex nn : n.getNeighbors()) { if (flags.get(nn) != null && flags.get(nn) == flag_curr_val) continue; boundary.push(nn); } } flt.scale(1 / sum_w); }
From source file:com.huateng.startup.init.MenuInfoUtil.java
/** * ???/*w ww .j a v a2 s . com*/ * @param degree */ @SuppressWarnings("unchecked") public static LinkedHashMap<String, Object> setOperatorMenuWithDegree(String degree, String contextPath, Document document) { String sql = "select * FROM TBL_ROLE_FUNC_MAP WHERE KEY_ID in ( " + degree + ")"; ICommQueryDAO commQueryDAO = (ICommQueryDAO) ContextUtil.getBean("CommQueryDAO"); List<Object[]> funcMapList = commQueryDAO.findBySQLQuery(sql); valueIdRole(funcMapList); List<Object> menuLvl1List = allMenuBean.getDataList(); LinkedHashMap<String, Object> menuIndexMap = new LinkedHashMap<String, Object>(); String panelStr = ""; //????? for (int i = 0, n = menuLvl1List.size(); i < n; i++) { Map<String, Object> menuLvl1Map = (Map<String, Object>) menuLvl1List.get(i); LinkedList<Object> menuLvl2List = (LinkedList<Object>) menuLvl1Map.get(Constants.MENU_CHILDREN); List<String> menuList = new ArrayList<String>(); for (int j = 0, m = menuLvl2List.size(); j < m; j++) { Map<String, Object> menuLvl2Map = (Map<String, Object>) menuLvl2List.get(j); LinkedList<Object> menuLvl3List = (LinkedList<Object>) menuLvl2Map.get(Constants.MENU_CHILDREN); for (int k = 0, l = menuLvl3List.size(); k < l; k++) { Map<String, Object> menuLvl3Map = (Map<String, Object>) menuLvl3List.get(k); for (int a = 0, b = funcMapList.size(); a < b; a++) { if (StringUtils.trim(funcMapList.get(a)[1].toString()) .equals(StringUtils.trim(menuLvl3Map.get(Constants.MENU_ID).toString()))) { if (!menuIndexMap.containsKey(menuLvl1Map.get(Constants.MENU_ID).toString())) { Map<String, Object> menuLvl1HashMap = new LinkedHashMap<String, Object>(); String menuId = menuLvl1Map.get(Constants.MENU_ID).toString(); menuLvl1HashMap.put(Constants.MENU_ID, menuLvl1Map.get(Constants.MENU_ID)); menuLvl1HashMap.put(Constants.MENU_TEXT, menuLvl1Map.get(Constants.MENU_TEXT)); menuLvl1HashMap.put(Constants.MENU_CLS, menuLvl1Map.get(Constants.MENU_CLS)); menuLvl1HashMap.put(Constants.MENU_HANDLER, Constants.MENU_LVL1_FUNC); menuLvl1HashMap.put(Constants.TOOL_BAR_TYPE, Constants.TOOL_BAR_BUTTON); menuLvl1HashMap.put(Constants.TOOLBAR_ICON, Constants.TOOLBAR_ICON_MENU); menuLvl1HashMap.put(Constants.IS_EXPAND, true); if ("1".equals(menuId) && panelStr.indexOf("baseTree") == -1) { panelStr = panelStr + "baseTree,"; } if ("2".equals(menuId) && panelStr.indexOf("mchtTree") == -1) { panelStr = panelStr + "mchtTree,"; } if ("3".equals(menuId) && panelStr.indexOf("termTree") == -1) { panelStr = panelStr + "termTree,"; } if ("5".equals(menuId) && panelStr.indexOf("queryTree") == -1) { panelStr = panelStr + "queryTree,"; } if ("9".equals(menuId) && panelStr.indexOf("onLinePayTree") == -1) { panelStr = panelStr + "onLinePayTree,"; } if ("10".equals(menuId) && panelStr.indexOf("taskTree") == -1) { panelStr = panelStr + "taskTree,"; } if ("8".equals(menuId) && panelStr.indexOf("clearTree") == -1) { panelStr = panelStr + "clearTree,"; } if ("4".equals(menuId) && panelStr.indexOf("riskTree") == -1) { panelStr = panelStr + "riskTree,"; } if ("11".equals(menuId) && panelStr.indexOf("provisionsTree") == -1) { panelStr = panelStr + "provisionsTree,"; } if ("12".equals(menuId) && panelStr.indexOf("errorTree") == -1) { panelStr = panelStr + "errorTree,"; } Map<String, Object> menuLvl2HashMap = new LinkedHashMap<String, Object>(); menuLvl2HashMap.put(Constants.MENU_ID, menuLvl2Map.get(Constants.MENU_ID)); menuLvl2HashMap.put(Constants.MENU_TEXT, menuLvl2Map.get(Constants.MENU_TEXT)); menuLvl2HashMap.put(Constants.MENU_PARENT_ID, menuLvl2Map.get(Constants.MENU_PARENT_ID)); menuLvl2HashMap.put(Constants.MENU_CLS, menuLvl2Map.get(Constants.MENU_CLS)); menuLvl2HashMap.put(Constants.TOOLBAR_ICON, Constants.TOOLBAR_ICON_MENUITEM); menuLvl2HashMap.put(Constants.IS_EXPAND, true); Map<String, Object> menuLvl3HashMap = new LinkedHashMap<String, Object>(); int index = menuList.lastIndexOf((String) menuLvl3Map.get(Constants.MENU_ID)); LinkedList<Object> menuLvl3Child = new LinkedList<Object>(); //System.out.println((String)menuLvl3Map.get(Constants.MENU_ID) + ">>>>>>>>>" + index + ">>>>>" + menuList.size()); if (-1 == index) { String tbar = MenuUtil.initMenu((String) menuLvl3Map.get(Constants.MENU_ID), (String) funcMapList.get(a)[5]); menuLvl3HashMap.put(Constants.MENU_ID, menuLvl3Map.get(Constants.MENU_ID)); menuLvl3HashMap.put(Constants.MENU_TEXT, menuLvl3Map.get(Constants.MENU_TEXT)); menuLvl3HashMap.put(Constants.MENU_PARENT_ID, menuLvl3Map.get(Constants.MENU_PARENT_ID)); menuLvl3HashMap.put(Constants.MENU_LEAF, true); menuLvl3HashMap.put(Constants.MENU_URL, menuLvl3Map.get(Constants.MENU_URL)); menuLvl3HashMap.put(Constants.ROLE_FLAG, tbar); menuLvl3HashMap.put(Constants.MENU_CLS, menuLvl3Map.get(Constants.MENU_CLS)); menuLvl3HashMap.put(Constants.MENU_HANDLER, Constants.MENU_LVL3_FUNC); menuLvl3HashMap.put(Constants.TOOLBAR_ICON, menuLvl3Map.get(Constants.TOOLBAR_ICON)); menuLvl3HashMap.put(Constants.IS_EXPAND, true); menuList.add((String) menuLvl3Map.get(Constants.MENU_ID)); menuLvl3Child.add(menuLvl3HashMap); } else { Map<String, Object> menu = (Map<String, Object>) menuLvl3Child.get(index); menu.put(Constants.ROLE_FLAG, (String) menu.get(Constants.ROLE_FLAG) + funcMapList.get(a)[5]); } menuLvl2HashMap.put(Constants.MENU_CHILDREN, menuLvl3Child); menuLvl2HashMap.put(Constants.TOOL_BAR_CHILDREN, menuLvl3Child); LinkedList<Object> menuLvl2Child = new LinkedList<Object>(); menuLvl2Child.add(menuLvl2HashMap); menuLvl1HashMap.put(Constants.MENU_CHILDREN, menuLvl2Child); menuLvl1HashMap.put(Constants.TOOL_BAR_CHILDREN, menuLvl2Child); menuIndexMap.put(menuLvl1Map.get(Constants.MENU_ID).toString(), menuLvl1HashMap); } else { Map<String, Object> menuLvl1HashMap = (Map<String, Object>) menuIndexMap .get(menuLvl1Map.get(Constants.MENU_ID).toString()); LinkedList<Object> menuLvl2Child = (LinkedList<Object>) menuLvl1HashMap .get(Constants.MENU_CHILDREN); boolean hasMenu = false; for (int c = 0, d = menuLvl2Child.size(); c < d; c++) { Map<String, Object> menuLvl2HashMap = (Map<String, Object>) menuLvl2Child .get(c); if (StringUtils.trim(menuLvl2HashMap.get(Constants.MENU_ID).toString()).equals( StringUtils.trim(menuLvl2Map.get(Constants.MENU_ID).toString()))) { LinkedList<Object> menuLvl3Child = (LinkedList<Object>) menuLvl2HashMap .get(Constants.MENU_CHILDREN); Map<String, Object> menuLvl3HashMap = new LinkedHashMap<String, Object>(); int index = menuList .lastIndexOf((String) menuLvl3Map.get(Constants.MENU_ID)); if (-1 == index) { String tbar = MenuUtil.initMenu( (String) menuLvl3Map.get(Constants.MENU_ID), (String) funcMapList.get(a)[5]); menuLvl3HashMap.put(Constants.MENU_ID, menuLvl3Map.get(Constants.MENU_ID)); menuLvl3HashMap.put(Constants.MENU_TEXT, menuLvl3Map.get(Constants.MENU_TEXT)); menuLvl3HashMap.put(Constants.MENU_PARENT_ID, menuLvl3Map.get(Constants.MENU_PARENT_ID)); menuLvl3HashMap.put(Constants.MENU_LEAF, true); menuLvl3HashMap.put(Constants.MENU_URL, menuLvl3Map.get(Constants.MENU_URL)); menuLvl3HashMap.put(Constants.ROLE_FLAG, tbar); menuLvl3HashMap.put(Constants.MENU_CLS, menuLvl3Map.get(Constants.MENU_CLS)); menuLvl3HashMap.put(Constants.MENU_HANDLER, Constants.MENU_LVL3_FUNC); menuLvl3HashMap.put(Constants.TOOLBAR_ICON, menuLvl3Map.get(Constants.TOOLBAR_ICON)); menuLvl3HashMap.put(Constants.IS_EXPAND, true); menuList.add((String) menuLvl3Map.get(Constants.MENU_ID)); menuLvl3Child.add(menuLvl3HashMap); } // else{ // Map<String, Object> menu = (Map<String, Object>)menuLvl3Child.get(index); // menu.put(Constants.ROLE_FLAG,(String)menu.get(Constants.ROLE_FLAG) + funcMapList.get(a)[5]); // } menuLvl2HashMap.put(Constants.MENU_CHILDREN, menuLvl3Child); menuLvl2HashMap.put(Constants.TOOL_BAR_CHILDREN, menuLvl3Child); menuLvl2HashMap.put(Constants.IS_EXPAND, true); menuLvl2Child.set(c, menuLvl2HashMap); hasMenu = true; break; } } if (!hasMenu) { String tbar = MenuUtil.initMenu((String) menuLvl3Map.get(Constants.MENU_ID), (String) funcMapList.get(a)[5]); Map<String, Object> menuLvl2HashMap = new HashMap<String, Object>(); menuLvl2HashMap.put(Constants.MENU_ID, menuLvl2Map.get(Constants.MENU_ID)); menuLvl2HashMap.put(Constants.MENU_TEXT, menuLvl2Map.get(Constants.MENU_TEXT)); menuLvl2HashMap.put(Constants.MENU_PARENT_ID, menuLvl2Map.get(Constants.MENU_PARENT_ID)); menuLvl2HashMap.put(Constants.MENU_CLS, menuLvl2Map.get(Constants.MENU_CLS)); menuLvl2HashMap.put(Constants.TOOLBAR_ICON, Constants.TOOLBAR_ICON_MENUITEM); menuLvl2HashMap.put(Constants.IS_EXPAND, true); LinkedList<Object> menuLvl3Child = new LinkedList<Object>(); Map<String, Object> menuLvl3HashMap = new LinkedHashMap<String, Object>(); menuLvl3HashMap.put(Constants.MENU_ID, menuLvl3Map.get(Constants.MENU_ID)); menuLvl3HashMap.put(Constants.MENU_TEXT, menuLvl3Map.get(Constants.MENU_TEXT)); menuLvl3HashMap.put(Constants.MENU_PARENT_ID, menuLvl3Map.get(Constants.MENU_PARENT_ID)); menuLvl3HashMap.put(Constants.MENU_LEAF, true); menuLvl3HashMap.put(Constants.MENU_URL, menuLvl3Map.get(Constants.MENU_URL)); menuLvl3HashMap.put(Constants.MENU_CLS, menuLvl3Map.get(Constants.MENU_CLS)); menuLvl3HashMap.put(Constants.ROLE_FLAG, tbar); menuLvl3HashMap.put(Constants.MENU_HANDLER, Constants.MENU_LVL3_FUNC); //menuLvl3HashMap.put(Constants.TOOLBAR_ICON, Constants.TOOLBAR_ICON_MENUITEM); menuLvl3HashMap.put(Constants.TOOLBAR_ICON, menuLvl3Map.get(Constants.TOOLBAR_ICON)); menuLvl3HashMap.put(Constants.IS_EXPAND, true); menuLvl3Child.add(menuLvl3HashMap); menuLvl2HashMap.put(Constants.MENU_CHILDREN, menuLvl3Child); menuLvl2HashMap.put(Constants.TOOL_BAR_CHILDREN, menuLvl3Child); menuLvl2Child.add(menuLvl2HashMap); } menuLvl1HashMap.put(Constants.MENU_CHILDREN, menuLvl2Child); menuLvl1HashMap.put(Constants.TOOL_BAR_CHILDREN, menuLvl2Child); menuLvl1HashMap.put(Constants.IS_EXPAND, true); menuIndexMap.put(menuLvl1Map.get(Constants.MENU_ID).toString(), menuLvl1HashMap); } } } } } } menuIndexMap.remove(Constants.TREE_MENU_PANEL); if (panelStr.length() != 0) { menuIndexMap.put(Constants.TREE_MENU_PANEL, panelStr.substring(0, panelStr.length() - 1)); } else { menuIndexMap.put(Constants.TREE_MENU_PANEL, ""); } return menuIndexMap; }
From source file:de.rub.syssec.saaf.Headless.java
/** * Analyze one or multiple APKs./* w w w . j av a2s . c o m*/ * If you use MultiThreading(default) be aware, sometimes if an error occurs, * no Exception and no StackTrace is shown. * * important command parameter: * <default> APKs in given directory are analyzed. * --recursive, -r APKs in subdirectories are also analyzed. * --fileList, -fl APKs found at given file location are analyzed. * --single-threaded, -st to deactivate MultiThreading * * @param path {fileLocation of an APK, * dir with several APKs in it, * file with several file paths to APKs} * depending on cmd-parameter. * */ public static void startAnalysis(File path) { if (path == null) { LOGGER.error("Please specify a file or directory to analyze!"); return; } else if (!path.exists()) { LOGGER.error("File or directory does not exist. Inserted path: " + path); return; } LinkedList<File> apks = new LinkedList<File>(); if (path.isFile() && !CONFIG.getBooleanConfigValue(ConfigKeys.USE_FILE_LIST)) { apks = gatherApksFromPath(path); } else if (path.isFile() && CONFIG.getBooleanConfigValue(ConfigKeys.USE_FILE_LIST)) { apks = gatherApksFromFileList(path); } else if (path.isDirectory() && !CONFIG.getBooleanConfigValue(ConfigKeys.RECURSIVE_DIR_ANALYSIS)) { apks = gatherApksFromPath(path); } else if (path.isDirectory() && CONFIG.getBooleanConfigValue(ConfigKeys.RECURSIVE_DIR_ANALYSIS)) { apks = gatherApksFromPath(path); } if (apks.size() <= 0) { LOGGER.error("Found no APK to analyze!"); return; } performAnalysis(apks); }
From source file:jp.co.ctc_g.jse.vid.ViewId.java
private static void is(ViewId self, ViewIdStore store) { Args.checkNotNull(self);// www. j a va 2 s. c o m self.freeze(); synchronized (store.semaphore()) { LinkedList<ViewId> ids = store.find(); assert ids != null; if (ids.contains(self)) { int index = ids.indexOf(self); for (int i = ids.size() - 1; i > index; i--) { ids.remove(i); } if (OVERRIDE_THE_SAME_ONE) { ids.set(index, self); } } else { ids.add(self); } store.store(ids); } }
From source file:se.trillian.goodies.spring.DomainObjectFactoryFactoryBean.java
private static Constructor<?> findMatchingConstructor(Class<?> clazz, Method m) { LinkedList<Constructor<?>> constructors = new LinkedList<Constructor<?>>(); Constructor<?> directMatch = null; for (Constructor<?> c : clazz.getDeclaredConstructors()) { if (isParameterTypesPrefix(m.getParameterTypes(), c.getParameterTypes())) { constructors.add(c);/* w w w. ja v a 2 s.c om*/ if (directMatch == null && isParameterTypesPrefix(c.getParameterTypes(), m.getParameterTypes())) { directMatch = c; } } } if (constructors.isEmpty()) { throw new IllegalArgumentException("No matching constructor found in " + "implementation class '" + clazz + "' for factory method '" + m + "'"); } if (constructors.size() > 1) { if (directMatch != null) { return directMatch; } throw new IllegalArgumentException("More than 1 matching constructor " + "found in implementation class '" + clazz + "' for factory method '" + m + "'"); } return constructors.getFirst(); }
From source file:AndroidUninstallStock.java
public static String getDeviceStatus(String adb, String select) throws Exception { LinkedList<String> devices = run(adb, "devices"); if (devices.size() < 2) { return "Error: No devices!"; }//from w w w . ja va 2 s . c o m int devindex = -1; String devselect = (select == null || select.isEmpty()) ? lastdevice : select; if (devselect.isEmpty()) { if (devices.size() == 2) { devindex = 1; } else { return "Error: Devices > 1. Disconnect excess devices or use --dev"; } } else { for (int x = devices.size() - 1; x > 0 && devindex == -1; x--) { if (devices.get(x).indexOf(devselect) == 0) devindex = x; } } if (devindex > -1) { String[] devtemp = devices.get(devindex).split("\\t"); if (devtemp.length != 2) { throw new Exception("Error: Parsing list devices"); } devselect = lastdevice = devtemp[0].trim(); if (devtemp[1].trim().equals("unauthorized")) { return "Error: Need authorization on device " + devselect; } } else { return "Error: Device " + devselect + " not found ADB!"; } return ""; }
From source file:io.hops.common.INodeUtil.java
public static void findPathINodesById(long inodeId, boolean inTree, LinkedList<INode> preTxResolvedINodes, boolean[] isPreTxPathFullyResolved) throws StorageException { if (inTree) { INode inode = indexINodeScanById(inodeId); if (inode == null) { isPreTxPathFullyResolved[0] = false; return; }//from w ww . j a v a 2 s. c om preTxResolvedINodes.add(inode); readFromLeafToRoot(inode, preTxResolvedINodes); } isPreTxPathFullyResolved[0] = true; //reverse the list int firstCounter = 0; int lastCounter = preTxResolvedINodes.size() - 1 - firstCounter; INode firstNode = null; INode lastNode = null; while (firstCounter < (preTxResolvedINodes.size() / 2)) { firstNode = preTxResolvedINodes.get(firstCounter); lastNode = preTxResolvedINodes.get(lastCounter); preTxResolvedINodes.remove(firstCounter); preTxResolvedINodes.add(firstCounter, lastNode); preTxResolvedINodes.remove(lastCounter); preTxResolvedINodes.add(lastCounter, firstNode); firstCounter++; lastCounter = preTxResolvedINodes.size() - 1 - firstCounter; } }