public void appendReferring(Referring currentReferring) { if (_referringProperties == null) { _referringProperties = new LinkedList<Referring>(); } _referringProperties.add(currentReferring); }
public static void main(String args[]) { HashSet<Integer> s = new HashSet<Integer>(); s.add(1); s.add(2); LinkedList<Integer> iList = new LinkedList<Integer>(); iList.add(1); iList.add(2); LinkedList<String> sList = new LinkedList<String>(); sList.add("x"); sList.add("y"); System.out.println(test1(s, iList)); System.out.println(test2(s, iList)); System.out.println(test3(s, sList)); System.out.println(test4(s, sList)); }
import java.util.LinkedList; class Test { public static void main(String args[]) { char arr[] = {3,1,4,1,5,9,2,6,5,3,5,8,9}; LinkedList<Integer> fifo = new LinkedList<Integer>(); for (int i = 0; i < arr.length; i++) fifo.add (new Integer (arr[i])); System.out.print (fifo.removeFirst() + "."); while (! fifo.isEmpty()) System.out.print (fifo.removeFirst()); System.out.println(); } }
private void buildIndex() { LinkedList<TreeNode> queue = new LinkedList<>(); queue.add(root); while (!queue.isEmpty()) { TreeNode node = queue.removeFirst(); index.put(node.cuboidId, node); for (TreeNode child : node.children) { queue.add(child); } } }
public List<StringListMap<T>> subMaps(final int size, boolean perMap) { final LinkedList<StringListMap<T>> maps = new LinkedList<StringListMap<T>>(); int index = 0, count = 0; for (final Entry<String,List<T>> entry : entrySet()) { for (final T value : entry.getValue()) { if (index == maps.size()) { maps.add(new StringListMap<T>()); } maps.get(index).add(entry.getKey(), value); index = perMap ? (++count / size) : (++index % size); } } return maps; } }
public static void compareSpeed() { NodeCachingLinkedList ncll = new NodeCachingLinkedList(); LinkedList ll = new LinkedList(); System.out.println("Testing relative execution time of commonly-used methods..."); ll.removeFirst(); ll.removeLast(); ll.add(o1); ll.remove(0); ll.removeFirst(); ll.removeLast(); ll.add(o1); ll.remove(0); ll.removeFirst(); ll.removeLast(); ll.add(o1); ll.remove(0); System.out.println("Time with LinkedList: " + (endTime - startTime) + " ms"); System.out.println("Time with NodeCachingLinkedList: " + (endTime - startTime) + " ms");
public static void main(String[] args) throws IOException { OsmandRegions or = new OsmandRegions(); or.prepareFile("/Users/victorshcherb/osmand/repos/resources/countries-info/regions.ocbf"); LinkedList<WorldRegion> lst = new LinkedList<WorldRegion>(); lst.add(or.getWorldRegion()); // int i =0; while (!lst.isEmpty()) { WorldRegion wd = lst.pollFirst(); System.out.println((wd.superregion == null ? "" : wd.superregion.getLocaleName()) + " " + wd.getLocaleName() + " " + wd.getRegionDownloadName()); // if(i++ <=5) // lst.addAll(wd.getSubregions()); } or.cacheAllCountries(); // long t = System.currentTimeMillis(); // or.cacheAllCountries(); // System.out.println("Init " + (System.currentTimeMillis() - t)); //testCountry(or, 15.8, 23.09, "chad"); testCountry(or, 52.10, 4.92, "the netherlands", "utrecht"); testCountry(or, 52.15, 7.50, "north rhine-westphalia"); testCountry(or, 28.8056, 29.9858, "egypt"); // testCountry(or, 40.0760, 9.2807, "italy", "sardinia"); testCountry(or, 35.7521, 139.7887, "japan"); testCountry(or, 46.5145, 102.2580, "mongolia"); testCountry(or, 62.54, 43.36, "arkhangelsk oblast", "northwestern federal district"); }
LinkedList<String> pathElements = new LinkedList<>(); int tops = 0; pathElements.add(0, element); pathElements.add(0, TOP_PATH); if (pathElements.size() == 1 && "".equals(pathElements.getLast()) && !prefix.endsWith(FOLDER_SEPARATOR)) { pathElements.add(0, CURRENT_PATH);
@Nullable @Override public Object call() throws Exception { String thNm = Thread.currentThread().getName(); LinkedList<Integer> keys = new LinkedList<>(); LinkedList<Integer> old = res.put(thNm, keys); assert old == null; while (true) { Integer key = keyGen.getAndIncrement(); if (key >= keyCnt) break; map.put(key, "value"); keys.add(key); if (keys.size() > rememberCnt) keys.removeFirst(); } return null; } },
private String[] split(String str, String splitStr) // Same as String.split(.) in JDK 1.4 { LinkedList<String> l = new LinkedList<String>(); StringTokenizer strTok = new StringTokenizer(str, splitStr); while(strTok.hasMoreTokens()) { String tok = strTok.nextToken(); l.add(tok); } return (String[])l.toArray(new String[l.size()]); }
LinkedList<Tree> newChildren = new LinkedList<>(); while (!preTerms.isEmpty() && isPunc(preTerms.getFirst())) { newChildren.add(preTerms.getFirst()); preTerms.removeFirst(); LinkedList<Tree> temp = new LinkedList<>(); if (newChild.children().length > 0) { newChildren.add(newChild); while (!preTerms.isEmpty() && isPunc(preTerms.getLast())) { temp.addFirst(preTerms.getLast()); preTerms.removeLast(); while (!newChildren.isEmpty() && isPunc(newChildren.getFirst())) { newChildren.removeFirst(); while (!newChildren.isEmpty() && isPunc(newChildren.getLast())) {
protected void flattenTree() { flattenedList = new LinkedList<ExecutionTreeNode>(); LinkedList<ExecutionTreeNode> nodesToHandle = new LinkedList<ExecutionTreeNode>(); nodesToHandle.add(rootNode); while (!nodesToHandle.isEmpty()) { ExecutionTreeNode currentNode = nodesToHandle.pop(); if (reverseOrder) { flattenedList.addFirst(currentNode); } else { flattenedList.add(currentNode); } if (currentNode.getChildren() != null && currentNode.getChildren().size() > 0) { for (ExecutionTreeNode childNode : currentNode.getChildren()) { nodesToHandle.add(childNode); } } } flattenedListIterator = flattenedList.iterator(); }
public void samplingInMinutes() { synchronized (this.csListHour) { this.csListHour.add(new CallSnapshot(System.currentTimeMillis(), this.times.get(), this.value .get())); if (this.csListHour.size() > 7) { this.csListHour.removeFirst(); } } }
private void use(Class categoryClass) { CachedClass cachedClass = ReflectionCache.getCachedClass(categoryClass); LinkedList<CachedClass> classStack = new LinkedList<CachedClass>(); for (CachedClass superClass = cachedClass; superClass.getTheClass()!=Object.class; superClass = superClass.getCachedSuperClass()) { classStack.add(superClass); } while (!classStack.isEmpty()) { CachedClass klazz = classStack.removeLast(); applyUse(klazz); } }
private synchronized boolean onTransactions(List<Transaction> txs) { if (txs.isEmpty()) return false; long[] gasPrices = new long[txs.size()]; for (int i = 0; i < txs.size(); ++i) { gasPrices[i] = ByteUtil.byteArrayToLong(txs.get(i).getGasPrice()); } blockGasPrices.add(gasPrices); while (blockGasPrices.size() > getMinBlocks() && (calcGasPricesSize() - blockGasPrices.getFirst().length) >= getMinTransactions()) { blockGasPrices.removeFirst(); } return true; }