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 ww . ja v a 2s. c om*/ */ public static String[] getElementArrayString(Element root, String name, String attrib) { if (root == null) return null; NodeList nl = root.getChildNodes(); LinkedList<String> elementCache = new LinkedList<String>(); 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); elementCache.addLast(valS); } String[] retArr = new String[elementCache.size()]; Iterator<String> it = elementCache.iterator(); int idx = 0; while (it.hasNext()) { retArr[idx++] = it.next(); } return retArr; }
From source file:com.arman.efficientqhalgoforch.SuperAwesomeCardFragment.java
/** * Line/*from w ww . j ava 2s. c o m*/ */ public static float[] ItoFloat(LinkedList<Integer> d) { float[] floatArray = new float[d.size() + 1]; floatArray[0] = 0.f; for (int i = 1, j = 0; i < floatArray.length; i++, j++) { floatArray[i] = (float) (d.get(j) / 1.0); } return floatArray; }
From source file:com.allinfinance.startup.init.MenuInfoUtil.java
/** * ????//w ww .j a v a 2 s .co m * @param menuBean */ @SuppressWarnings("unchecked") private static void addLvl3Menu(Map<String, Object> menuBean) { List<Object> menuLvl1List = allMenuBean.getDataList(); for (int i = 0, n = menuLvl1List.size(); i < n; i++) { Map<String, Object> tmpMenuBeanLvl1 = (Map<String, Object>) menuLvl1List.get(i); LinkedList<Object> menuLvl2List = (LinkedList<Object>) tmpMenuBeanLvl1.get(Constants.MENU_CHILDREN); if (menuLvl2List == null) { continue; } for (int j = 0, m = menuLvl2List.size(); j < m; j++) { Map<String, Object> tmpMenuBeanLvl2 = (Map<String, Object>) menuLvl2List.get(j); //????? ????? if (tmpMenuBeanLvl2.get(Constants.MENU_ID).toString().trim() .equals(menuBean.get(Constants.MENU_PARENT_ID).toString().trim())) { if (!tmpMenuBeanLvl2.containsKey(Constants.MENU_CHILDREN)) { LinkedList<Object> menuLvl3List = new LinkedList<Object>(); menuLvl3List.add(menuBean); tmpMenuBeanLvl2.put(Constants.MENU_CHILDREN, menuLvl3List); } else { LinkedList<Object> menuLvl3List = (LinkedList<Object>) tmpMenuBeanLvl2 .get(Constants.MENU_CHILDREN); menuLvl3List.add(menuBean); tmpMenuBeanLvl2.put(Constants.MENU_CHILDREN, menuLvl3List); } menuLvl2List.set(j, tmpMenuBeanLvl2); } } tmpMenuBeanLvl1.put(Constants.MENU_CHILDREN, menuLvl2List); menuLvl1List.set(i, tmpMenuBeanLvl1); } allMenuBean.setDataList(menuLvl1List); }
From source file:com.allinfinance.startup.init.MenuInfoUtil.java
/** * ???/*from w w w. ja v a 2 s. com*/ * @param degree */ @SuppressWarnings("unchecked") public static LinkedHashMap<String, Object> setOperatorMenuWithDegree(String degree, String contextPath) { String sql = "select VALUE_ID FROM TBL_ROLE_FUNC_MAP ,TBL_ROLE_INF WHERE ROLE_ID = KEY_ID and KEY_ID = " + degree; ICommQueryDAO commQueryDAO = (ICommQueryDAO) ContextUtil.getBean("CommQueryDAO"); List<Object> funcMapList = commQueryDAO.findBySQLQuery(sql); List<Object> menuLvl1List = allMenuBean.getDataList(); LinkedHashMap<String, Object> menuIndexMap = new LinkedHashMap<String, Object>(); //????? 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); 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).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>(); 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); 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.TOOLBAR_ICON, menuLvl2Map.get(Constants.TOOLBAR_ICON)); 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, contextPath + menuLvl3Map.get(Constants.MENU_URL)); menuLvl3HashMap.put(Constants.MENU_CLS, menuLvl3Map.get(Constants.MENU_CLS)); 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)); LinkedList<Object> menuLvl3Child = new LinkedList<Object>(); menuLvl3Child.add(menuLvl3HashMap); 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>(); 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, contextPath + menuLvl3Map.get(Constants.MENU_URL)); menuLvl3HashMap.put(Constants.MENU_CLS, menuLvl3Map.get(Constants.MENU_CLS)); 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)); menuLvl3Child.add(menuLvl3HashMap); menuLvl2HashMap.put(Constants.MENU_CHILDREN, menuLvl3Child); menuLvl2HashMap.put(Constants.TOOL_BAR_CHILDREN, menuLvl3Child); menuLvl2Child.set(c, menuLvl2HashMap); hasMenu = true; break; } } if (!hasMenu) { 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.TOOLBAR_ICON, menuLvl2Map.get(Constants.TOOLBAR_ICON)); 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, contextPath + menuLvl3Map.get(Constants.MENU_URL)); menuLvl3HashMap.put(Constants.MENU_CLS, menuLvl3Map.get(Constants.MENU_CLS)); 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)); 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); menuIndexMap.put(menuLvl1Map.get(Constants.MENU_ID).toString(), menuLvl1HashMap); } } } } } } return menuIndexMap; }
From source file:gr.abiss.calipso.tiers.specifications.GenericSpecifications.java
/** * Get the root predicate, either a conjunction or disjunction * @param clazz the entity type to query for * @param searchTerms the search terms to match * @param root the criteria root//w w w . j a v a2s.c o m * @param cb the criteria builder * @return the resulting predicate */ protected static Predicate buildRootPredicate(final Class clazz, final Map<String, String[]> searchTerms, Root<Persistable> root, CriteriaBuilder cb) { // build a list of criteria/predicates LinkedList<Predicate> predicates = buildSearchPredicates(clazz, searchTerms, root, cb); // wrap list in AND/OR junction Predicate predicate; if (searchTerms.containsKey(SEARCH_MODE) && searchTerms.get(SEARCH_MODE)[0].equalsIgnoreCase(OR) // A disjunction of zero predicates is false so... && predicates.size() > 0) { predicate = cb.or(predicates.toArray(new Predicate[predicates.size()])); } else { predicate = cb.and(predicates.toArray(new Predicate[predicates.size()])); } // return the resulting junction return predicate; }
From source file:gr.abiss.calipso.jpasearch.specifications.GenericSpecifications.java
protected static Predicate getRootPredicate(final Class clazz, final Map<String, String[]> searchTerms, Root<Persistable> root, CriteriaBuilder cb, boolean skipSimpleSearch) { LinkedList<Predicate> predicates = new LinkedList<Predicate>(); Predicate predicate;//from w ww.j av a2 s. c o m parseSearchTerms(clazz, searchTerms, root, cb, predicates); if (!skipSimpleSearch) { // handle "_all", i.e. simple search if (searchTerms.containsKey(SIMPLE_SEARCH_PARAM_NAME) && predicates.size() == 0) { Map<String, String[]> simpleSearchTerms = getSimpleSearchTerms(clazz, searchTerms.get(SIMPLE_SEARCH_PARAM_NAME)); parseSearchTerms(clazz, simpleSearchTerms, root, cb, predicates); } } if (searchTerms.containsKey(SEARCH_MODE) && searchTerms.get(SEARCH_MODE)[0].equalsIgnoreCase(OR) // A disjunction of zero predicates is false && predicates.size() > 0) { predicate = cb.or(predicates.toArray(new Predicate[predicates.size()])); } else { predicate = cb.and(predicates.toArray(new Predicate[predicates.size()])); } return predicate; }
From source file:at.bitfire.davdroid.resource.LocalTaskList.java
public static LocalTaskList[] findAll(Account account, ContentProviderClient providerClient) throws RemoteException { @Cleanup/*from w ww . j a va 2 s .c o m*/ Cursor cursor = providerClient.query(taskListsURI(account), new String[] { TaskContract.TaskLists._ID, TaskContract.TaskLists._SYNC_ID }, null, null, null); LinkedList<LocalTaskList> taskList = new LinkedList<>(); while (cursor != null && cursor.moveToNext()) taskList.add(new LocalTaskList(account, providerClient, cursor.getInt(0), cursor.getString(1))); return taskList.toArray(new LocalTaskList[taskList.size()]); }
From source file:azkaban.jobtype.HadoopSecureSparkWrapper.java
/** * This method is used to enforce queue for Spark application. Rules are explained below. * a) If dynamic resource allocation is enabled for selected spark version and application requires large container * then schedule it into default queue by a default conf(spark.yarn.queue) in spark-defaults.conf. * b) If dynamic resource allocation is enabled for selected spark version and application requires small container * then schedule it into Org specific queue. * c) If dynamic resource allocation is disabled for selected spark version then schedule application into default * queue by a default conf(spark.yarn.queue) in spark-defaults.conf. * @param argArray//from www . j a v a 2s .com * @return */ protected static String[] handleQueueEnforcement(String[] argArray) { SparkConf sparkConf = getSparkProperties(); Configuration conf = new Configuration(); int queueParameterIndex = getUserSpecifiedQueueParameterIndex(argArray); boolean requiredSparkDefaultQueue = false; if (sparkConf.getBoolean(SPARK_CONF_DYNAMIC_ALLOC_ENABLED, false)) { if (isLargeContainerRequired(argArray, conf, sparkConf)) { // Case A requiredSparkDefaultQueue = true; logger.info( "Spark application requires Large containers. Scheduling this application into default queue by a " + "default conf(spark.yarn.queue) in spark-defaults.conf."); } else { // Case B logger.info( "Dynamic allocation is enabled for selected spark version and application requires small container. " + "Hence, scheduling this application into Org specific queue"); if (queueParameterIndex == -1) { LinkedList<String> argList = new LinkedList(Arrays.asList(argArray)); argList.addFirst(SPARK_CONF_QUEUE + "=" + DEFAULT_QUEUE); argList.addFirst(SparkJobArg.SPARK_CONF_PREFIX.sparkParamName); argArray = argList.toArray(new String[argList.size()]); } } } else { // Case C logger.info( "Spark version, selected for this application, doesn't support dynamic allocation. Scheduling this " + "application into default queue by a default conf(spark.yarn.queue) in spark-defaults.conf."); requiredSparkDefaultQueue = true; } if (queueParameterIndex != -1 && requiredSparkDefaultQueue) { logger.info("Azbakan enforces spark.yarn.queue queue. Ignore user param: " + argArray[queueParameterIndex] + " " + argArray[queueParameterIndex + 1]); argArray[queueParameterIndex] = null; argArray[queueParameterIndex + 1] = null; } return argArray; }
From source file:azkaban.jobtype.HadoopSecureSparkWrapper.java
protected static String[] handleNodeLabeling(String[] argArray) { // HadoopSparkJob will set env var on this process if we enable node labeling policy for spark jobtype. // We also detect the yarn cluster settings has enable node labeling // Enabling node labeling policy for spark job type is different from enabling node labeling // feature for Yarn. This config inside Spark job type is to enforce node labeling feature for all // Spark applications submitted via Azkaban Spark job type. Configuration conf = new Configuration(); boolean nodeLabelingYarn = conf.getBoolean(YARN_CONF_NODE_LABELING_ENABLED, false); String nodeLabelingProp = System.getenv(HadoopSparkJob.SPARK_NODE_LABELING_ENV_VAR); boolean nodeLabelingPolicy = nodeLabelingProp != null && nodeLabelingProp.equals(Boolean.TRUE.toString()); String autoNodeLabelProp = System.getenv(HadoopSparkJob.SPARK_AUTO_NODE_LABELING_ENV_VAR); boolean autoNodeLabeling = autoNodeLabelProp != null && autoNodeLabelProp.equals(Boolean.TRUE.toString()); String desiredNodeLabel = System.getenv(HadoopSparkJob.SPARK_DESIRED_NODE_LABEL_ENV_VAR); SparkConf sparkConf = getSparkProperties(); if (nodeLabelingYarn && nodeLabelingPolicy) { ignoreUserSpecifiedNodeLabelParameter(argArray, autoNodeLabeling); // If auto node labeling is enabled, automatically sets spark.yarn.executor.nodeLabelExpression // config based on user requested resources. if (autoNodeLabeling) { if (isLargeContainerRequired(argArray, conf, sparkConf)) { LinkedList<String> argList = new LinkedList<String>(Arrays.asList(argArray)); argList.addFirst(SPARK_EXECUTOR_NODE_LABEL_EXP + "=" + desiredNodeLabel); argList.addFirst(SparkJobArg.SPARK_CONF_PREFIX.sparkParamName); argArray = argList.toArray(new String[argList.size()]); }//from w w w .j a v a 2s . c om } } return argArray; }
From source file:org.zywx.wbpalmstar.plugin.uexiconlist.utils.IconListUtils.java
public static LinkedList<IconBean> getPerPageIconList(LinkedList<IconBean> iconList, int page) { LinkedList<IconBean> gridViewIconList = new LinkedList<IconBean>(); int pageSize = UIConfig.getLine() * UIConfig.getRow(); int startPos = page * pageSize;// ?? int iEnd = startPos + pageSize;// ??? while ((startPos < iconList.size()) && (startPos < iEnd)) { gridViewIconList.add(iconList.get(startPos)); startPos++;/*w ww .j a v a2 s. co m*/ } return gridViewIconList; }