List of usage examples for java.util TreeSet iterator
public Iterator<E> iterator()
From source file:nl.nn.ibistesttool.IbisDebuggerAdvice.java
public Object debugPipeLineInputOutputAbort(ProceedingJoinPoint proceedingJoinPoint, PipeLine pipeLine, String correlationId, String message, IPipeLineSession pipeLineSession) throws Throwable { message = (String) ibisDebugger.pipeLineInput(pipeLine, correlationId, message); TreeSet keys = new TreeSet(pipeLineSession.keySet()); Iterator iterator = keys.iterator(); while (iterator.hasNext()) { String sessionKey = (String) iterator.next(); Object sessionValue = pipeLineSession.get(sessionKey); sessionValue = ibisDebugger.pipeLineSessionKey(correlationId, sessionKey, sessionValue); pipeLineSession.put(sessionKey, sessionValue); }//from ww w. j av a 2 s . c o m PipeLineResult pipeLineResult = null; try { PipeLineSessionDebugger pipeLineSessionDebugger = new PipeLineSessionDebugger(pipeLineSession); pipeLineSessionDebugger.setIbisDebugger(ibisDebugger); Object[] args = proceedingJoinPoint.getArgs(); args[3] = pipeLineSessionDebugger; pipeLineResult = (PipeLineResult) proceedingJoinPoint.proceed(args); } catch (Throwable throwable) { throw ibisDebugger.pipeLineAbort(pipeLine, correlationId, throwable); } pipeLineResult.setResult(ibisDebugger.pipeLineOutput(pipeLine, correlationId, pipeLineResult.getResult())); return pipeLineResult; }
From source file:org.openhab.binding.networkhealth.discovery.NetworkHealthDiscoveryService.java
/** * Takes the interfaceIPs and fetches every IP which can be assigned on their network * @param networkIPs The IPs which are assigned to the Network Interfaces * @return Every single IP which can be assigned on the Networks the computer is connected to *//*from w w w .j a va 2s . c o m*/ private Queue<String> getNetworkIPs(TreeSet<String> interfaceIPs) { Queue<String> networkIPs = new LinkedBlockingQueue<String>(); for (Iterator<String> it = interfaceIPs.iterator(); it.hasNext();) { try { // gets every ip which can be assigned on the given network SubnetUtils utils = new SubnetUtils(it.next()); String[] addresses = utils.getInfo().getAllAddresses(); for (int i = 0; i < addresses.length; i++) { networkIPs.add(addresses[i]); } } catch (Exception ex) { } } return networkIPs; }
From source file:com.ichi2.libanki.Utils.java
private static void printJSONObject(JSONObject jsonObject, String indentation, BufferedWriter buff) { try {/*from w ww . j av a 2 s.co m*/ @SuppressWarnings("unchecked") Iterator<String> keys = (Iterator<String>) jsonObject.keys(); TreeSet<String> orderedKeysSet = new TreeSet<String>(); while (keys.hasNext()) { orderedKeysSet.add(keys.next()); } Iterator<String> orderedKeys = orderedKeysSet.iterator(); while (orderedKeys.hasNext()) { String key = orderedKeys.next(); try { Object value = jsonObject.get(key); if (value instanceof JSONObject) { if (buff != null) { buff.write(indentation + " " + key + " : "); buff.newLine(); } Timber.i(" " + indentation + key + " : "); printJSONObject((JSONObject) value, indentation + "-", buff); } else { if (buff != null) { buff.write(indentation + " " + key + " = " + jsonObject.get(key).toString()); buff.newLine(); } Timber.i(" " + indentation + key + " = " + jsonObject.get(key).toString()); } } catch (JSONException e) { Timber.e(e, "printJSONObject : JSONException"); } } } catch (IOException e1) { Timber.e(e1, "printJSONObject : IOException"); } }
From source file:com.linkedin.pinot.operator.OrOperatorTest.java
@Test public void testIntersectionForTwoLists() { int[] list1 = new int[] { 2, 3, 10, 15, 16, 28 }; int[] list2 = new int[] { 3, 6, 8, 20, 28 }; ;/* ww w . j a v a 2s . com*/ List<Operator> operators = new ArrayList<Operator>(); operators.add(makeFilterOperator(list1)); operators.add(makeFilterOperator(list2)); final OrOperator orOperator = new OrOperator(operators); orOperator.open(); Block block; TreeSet<Integer> set = new TreeSet<Integer>(); set.addAll(Lists.newArrayList(ArrayUtils.toObject(list1))); set.addAll(Lists.newArrayList(ArrayUtils.toObject(list2))); Iterator<Integer> expectedIterator = set.iterator(); while ((block = orOperator.nextBlock()) != null) { final BlockDocIdSet blockDocIdSet = block.getBlockDocIdSet(); final BlockDocIdIterator iterator = blockDocIdSet.iterator(); int docId; while ((docId = iterator.next()) != Constants.EOF) { Assert.assertEquals(expectedIterator.next().intValue(), docId); } } orOperator.close(); }
From source file:org.eclipse.skalli.view.component.PeopleSearchWindow.java
private void search(String searchText) { dataSource.removeAllItems();/*w w w .ja v a 2s. c o m*/ if (StringUtils.isNotEmpty(searchText)) { TreeSet<User> sorted = new TreeSet<User>(UserContainer.findUsers(searchText)); for (User user : sorted) { dataSource.addItem(user); } if (sorted.size() == 1) { list.select(sorted.iterator().next()); } } }
From source file:com.linkedin.pinot.operator.filter.OrOperatorTest.java
@Test public void testUnionForThreeLists() { int[] docIds1 = new int[] { 2, 3, 6, 10, 15, 16, 28 }; int[] docIds2 = new int[] { 3, 6, 8, 20, 28 }; int[] docIds3 = new int[] { 1, 2, 3, 6, 30 }; TreeSet<Integer> treeSet = new TreeSet<>(); treeSet.addAll(Arrays.asList(ArrayUtils.toObject(docIds1))); treeSet.addAll(Arrays.asList(ArrayUtils.toObject(docIds2))); treeSet.addAll(Arrays.asList(ArrayUtils.toObject(docIds3))); Iterator<Integer> expectedIterator = treeSet.iterator(); List<BaseFilterOperator> operators = new ArrayList<>(); operators.add(FilterOperatorTestUtils.makeFilterOperator(docIds1)); operators.add(FilterOperatorTestUtils.makeFilterOperator(docIds2)); operators.add(FilterOperatorTestUtils.makeFilterOperator(docIds3)); OrOperator orOperator = new OrOperator(operators); BlockDocIdIterator iterator = orOperator.nextBlock().getBlockDocIdSet().iterator(); int docId;/*from www .jav a2s . c o m*/ while ((docId = iterator.next()) != Constants.EOF) { Assert.assertEquals(docId, expectedIterator.next().intValue()); } }
From source file:org.apereo.portal.portlets.dynamicskin.FileSystemDynamicSkinService.java
@Override public String calculateTokenForCurrentSkin(PortletRequest request) { int hash = 0; PortletPreferences preferences = request.getPreferences(); // Add the list of preference names to an ordered list so we can get reliable hashcode calculations. Map<String, String[]> prefs = preferences.getMap(); TreeSet<String> orderedNames = new TreeSet<String>(prefs.keySet()); Iterator<String> iterator = orderedNames.iterator(); while (iterator.hasNext()) { String preferenceName = iterator.next(); if (preferenceName.startsWith(DynamicSkinService.CONFIGURABLE_PREFIX)) { hash = hash * 31 + preferences.getValue(preferenceName, "").trim().hashCode(); }//from w w w .ja va2s. c o m } return Integer.toString(hash); }
From source file:com.linkedin.pinot.operator.filter.OrOperatorTest.java
@Test public void testComplex() { int[] docIds1 = new int[] { 2, 3, 6, 10, 15, 16, 28 }; int[] docIds2 = new int[] { 3, 6, 8, 20, 28 }; int[] docIds3 = new int[] { 1, 2, 3, 6, 30 }; TreeSet<Integer> treeSet = new TreeSet<>(); treeSet.addAll(Arrays.asList(ArrayUtils.toObject(docIds1))); treeSet.addAll(Arrays.asList(ArrayUtils.toObject(docIds2))); treeSet.addAll(Arrays.asList(ArrayUtils.toObject(docIds3))); Iterator<Integer> expectedIterator = treeSet.iterator(); List<BaseFilterOperator> childOperators = new ArrayList<>(); childOperators.add(FilterOperatorTestUtils.makeFilterOperator(docIds1)); childOperators.add(FilterOperatorTestUtils.makeFilterOperator(docIds2)); OrOperator childOrOperator = new OrOperator(childOperators); List<BaseFilterOperator> operators = new ArrayList<>(); operators.add(childOrOperator);// ww w . j av a 2s. c o m operators.add(FilterOperatorTestUtils.makeFilterOperator(docIds3)); OrOperator orOperator = new OrOperator(operators); BlockDocIdIterator iterator = orOperator.nextBlock().getBlockDocIdSet().iterator(); int docId; while ((docId = iterator.next()) != Constants.EOF) { Assert.assertEquals(docId, expectedIterator.next().intValue()); } }
From source file:com.qspin.qtaste.testsuite.impl.TestDataImpl.java
@Override public String dump() { TreeSet<String> sortedKeys = new TreeSet<String>(hash.keySet()); String result = new String("{"); Iterator<String> iKey = sortedKeys.iterator(); for (int i = 0; i < sortedKeys.size(); i++) { if (i > 0) { result += ", "; }// w w w .j a v a 2s .com String key = iKey.next(); result += key + "=" + hash.get(key); } result += "}"; return result; }
From source file:gr.cti.android.experimentation.controller.api.HistoryController.java
private void fillMissingIntervals(TreeSet<Long> treeSet, String rollup, long toLong) { //TODO: add non existing intervals if (rollup.endsWith("d")) { DateTime firstDate = new DateTime(treeSet.iterator().next()); while (firstDate.isBefore(toLong)) { firstDate = firstDate.plusDays(1); if (!treeSet.contains(firstDate.getMillis())) { treeSet.add(firstDate.getMillis()); }//from w w w . jav a2 s. c o m } } else if (rollup.endsWith("h")) { DateTime firstDate = new DateTime(treeSet.iterator().next()); while (firstDate.isBefore(toLong)) { firstDate = firstDate.plusHours(1); if (!treeSet.contains(firstDate.getMillis())) { treeSet.add(firstDate.getMillis()); } } } else if (rollup.endsWith("m")) { DateTime firstDate = new DateTime(treeSet.iterator().next()); while (firstDate.isBefore(toLong)) { firstDate = firstDate.plusMinutes(1); if (!treeSet.contains(firstDate.getMillis())) { treeSet.add(firstDate.getMillis()); } } } }