List of usage examples for java.util LinkedList get
public E get(int index)
From source file:util.allocation.java
public static boolean VMIDInSeparationPolicy(HashMap<String, LinkedList<String>> finalDeploySolution, String currentHOSTSolutionID, String currentVMID, LinkedList<LinkedList<LinkedList<String>>> concreteSeparationPolicy) { LinkedList<String> VMDeployListForOneHost = finalDeploySolution.get(currentHOSTSolutionID); if (VMDeployListForOneHost != null) { for (LinkedList item : concreteSeparationPolicy) { LinkedList<String> conflictSet1 = (LinkedList<String>) item.get(0); LinkedList<String> conflictSet2 = (LinkedList<String>) item.get(1); /*/*ww w . j a va 2s. c om*/ printInfo("print Conflict set"); printLinkedList(conflictSet1); printInfo("\n"); printLinkedList(conflictSet2); printInfo("\n"); printLinkedList(VMDeployListForOneHost); */ if (twoLinkedListShareSameEntity(conflictSet1, VMDeployListForOneHost) && conflictSet2.contains(currentVMID)) return true; if (twoLinkedListShareSameEntity(conflictSet2, VMDeployListForOneHost) && conflictSet1.contains(currentVMID)) return true; } return false; } else { return false; } }
From source file:com.arman.efficientqhalgoforch.SuperAwesomeCardFragment.java
/** * Line// ww w . j a v a 2 s . 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
/** * ????/*from w ww . j a v a2 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:org.jwatch.handler.QuartzInstanceHandler.java
public static JSONObject getJobsList(Map map) { JSONObject jsonObject = new JSONObject(); JSONArray jsonArray = new JSONArray(); int totalCount = 0; try {/* w ww. j a va2 s . c o m*/ LinkedList events = EventService.getEventList(); if (events != null && events.size() > 0) { totalCount = events.size() > EventService.getMaxShowEventListSize() ? EventService.getMaxShowEventListSize() : events.size(); for (int i = 0; i < events.size(); i++) { JobEvent jEvent = (JobEvent) events.get(i); JSONObject object = JSONObject.fromObject(jEvent); object.put("fireTime", Tools.toStringFromDate(jEvent.getFireTime(), null)); object.put("nextFireTime", Tools.toStringFromDate(jEvent.getNextFireTime(), null)); object.put("previousFireTime", Tools.toStringFromDate(jEvent.getPreviousFireTime(), null)); object.put("scheduledFireTime", Tools.toStringFromDate(jEvent.getScheduledFireTime(), null)); jsonArray.add(object); if (i == EventService.getMaxShowEventListSize() - 1) { break; } } } jsonObject.put(GlobalConstants.JSON_DATA_ROOT_KEY, jsonArray); jsonObject.put(GlobalConstants.JSON_SUCCESS_KEY, true); jsonObject.put(GlobalConstants.JSON_TOTAL_COUNT, totalCount); } catch (Throwable t) { log.error(t); jsonObject = JSONUtil.buildError(GlobalConstants.MESSAGE_ERR_TAIL_JOBS); } return jsonObject; }
From source file:com.allinfinance.startup.init.MenuInfoUtil.java
/** * ???// w ww . j a v a 2 s. c o m * @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: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++;//from ww w.j av a 2s .co m } return gridViewIconList; }
From source file:Main.java
/** * Inserts into an ascending sorted list an element. * * Preconditions: The element has to implement the {@code Comparable} * interface and the list have to be sorted ascending. Both conditions will * not be checked: At runtime a class cast exception will be thrown * if the element does not implement the comparable interface and and if the * list is not sorted, the element can't be insert sorted. * * @param <T> element type//from ww w. j a v a2 s. co m * @param list * @param element */ @SuppressWarnings("unchecked") public static <T> void binaryInsert(LinkedList<? super T> list, T element) { if (list == null) { throw new NullPointerException("list == null"); } if (element == null) { throw new NullPointerException("element == null"); } boolean isComparable = element instanceof Comparable<?>; if (!isComparable) { throw new IllegalArgumentException("Not a comparable: " + element); } int size = list.size(); int low = 0; int high = size - 1; int index = size; int cmp = 1; while ((low <= high) && (cmp > 0)) { int mid = (low + high) >>> 1; Comparable<? super T> midVal = (Comparable<? super T>) list.get(mid); cmp = midVal.compareTo(element); if (cmp < 0) { low = mid + 1; } else if (cmp > 0) { high = mid - 1; } } for (int i = low; (i >= 0) && (i < size) && (index == size); i++) { Comparable<? super T> elt = (Comparable<? super T>) list.get(i); if (elt.compareTo(element) >= 0) { index = i; } } list.add(index, element); }
From source file:Main.java
/** * // w w w . j a va2s . com * @param aFile * @return */ public static String getLastLines(String filename, int number) { File aFile = new File(filename); StringBuilder contents = new StringBuilder(); LinkedList<String> ll = new LinkedList<String>(); try { BufferedReader input = new BufferedReader(new FileReader(aFile)); try { String line = null; while ((line = input.readLine()) != null) { ll.add(line); } } finally { input.close(); } } catch (IOException ex) { Log.e(TAG, ex.getMessage()); } if ((ll.size() - number) <= 0) { Log.e(TAG, "Requested number of lines exceeds lines of file"); return "Requested number of lines exceeds lines of file"; } for (int i = (ll.size() - 1); i >= (ll.size() - number); i--) { contents.append(ll.get(i - 1)); contents.append("\n"); } return contents.toString(); }
From source file:jp.co.ctc_g.jse.vid.ViewId.java
private static ViewId history(int history, ViewIdStore store) { ViewId id = null;//w ww .j a v a 2 s. c o m 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:com.primovision.lutransport.core.util.TollCompanyTagUploadUtil.java
private static void mapForEZPassNY(LinkedList<String> expectedColumnList) { LinkedHashMap<String, String> actualColumnMap = new LinkedHashMap<String, String>(); int expectedColumnStartIndex = 2; actualColumnMap.put(expectedColumnList.get(expectedColumnStartIndex++), StringUtils.EMPTY); actualColumnMap.put(expectedColumnList.get(expectedColumnStartIndex++), "TAG NUMBER/"); actualColumnMap.put(expectedColumnList.get(expectedColumnStartIndex++), "TAG NUMBER/"); actualColumnMap.put(expectedColumnList.get(expectedColumnStartIndex++), "Driver Name"); actualColumnMap.put(expectedColumnList.get(expectedColumnStartIndex++), "TRANS"); actualColumnMap.put(expectedColumnList.get(expectedColumnStartIndex++), "TIME"); actualColumnMap.put(expectedColumnList.get(expectedColumnStartIndex++), "AGENCY"); actualColumnMap.put(expectedColumnList.get(expectedColumnStartIndex++), "AMOUNT"); actualColumnMap.put(expectedColumnList.get(expectedColumnStartIndex++), "Invoice Date"); //actualColumnMap.put(expectedColumnList.get(expectedColumnStartIndex++), "Unit #"); tollCompanyToTollTagMapping.put(TOLL_COMPANY_EZ_PASS_NY, actualColumnMap); }