Java Code Examples for java.util.Collections#synchronizedSortedMap()
The following examples show how to use
java.util.Collections#synchronizedSortedMap() .
These examples are extracted from open source projects.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: ReactionDecoder File: MCSPlusMapper.java License: GNU Lesser General Public License v3.0 | 6 votes |
private synchronized void setAllMapping(List<Map<Integer, Integer>> solutions) { try { int counter = 0; int bestSolSize = 0; for (Map<Integer, Integer> solution : solutions) { // System.out.println("Number of MCS solution: " + solution); Map<Integer, Integer> validSolution = Collections.synchronizedSortedMap(new TreeMap<>()); solution.entrySet().stream().forEach((map) -> { validSolution.put(map.getKey(), map.getValue()); }); if (validSolution.size() > bestSolSize) { bestSolSize = validSolution.size(); counter = 0; allMCS.clear(); } if (validSolution.size() == bestSolSize) { allMCS.add(counter++, validSolution); } } } catch (Exception ex) { } }
Example 2
Source Project: tutorials File: SynchronizedSortedMapUnitTest.java License: MIT License | 6 votes |
@Test public void givenSynchronizedSorteMap_whenTwoThreadsAddElements_thenCorrectSortedMapSize() throws InterruptedException { Map<Integer, String> syncSortedMap = Collections.synchronizedSortedMap(new TreeMap<>()); Runnable sortedMapOperations = () -> { syncSortedMap.put(1, "One"); syncSortedMap.put(2, "Two"); syncSortedMap.put(3, "Three"); }; Thread thread1 = new Thread(sortedMapOperations); Thread thread2 = new Thread(sortedMapOperations); thread1.start(); thread2.start(); thread1.join(); thread2.join(); assertThat(syncSortedMap.size()).isEqualTo(3); }
Example 3
Source Project: ReactionDecoder File: BondEnergies.java License: GNU Lesser General Public License v3.0 | 6 votes |
protected BondEnergies() { int key = 1; bondEngergies = Collections.synchronizedSortedMap(new TreeMap<Integer, BondEnergy>()); // =========Hydrogen Block============== key = setHydrogenBlock(key); // ==================Group 13================= key = setGroup13(key); // ===================Group 14 Part 1================= key = setGroup14Part1(key); // ===================Group 14 Part 2================= key = setGroup14Part2(key); // ===================Group 15================= key = setGroup15(key); // ===================Group 16================= key = setGroup16(key); // ===================Group 17================= key = setGroup17(key); // ===================Group 18================= key = setGroup18(key); }
Example 4
Source Project: j2objc File: OldCollectionsTest.java License: Apache License 2.0 | 5 votes |
/** * java.util.Collections#synchronizedSortedMap(java.util.SortedMap) */ public void test_synchronizedSortedMapLjava_util_SortedMap() { try { // Regression for HARMONY-93 Collections.synchronizedSortedMap(null); fail("Assert 0: synchronizedSortedMap(null) must throw NPE"); } catch (NullPointerException e) { // expected } }
Example 5
Source Project: ReactionDecoder File: ChemicalFilters.java License: GNU Lesser General Public License v3.0 | 5 votes |
/** * Sort MCS solution by bond breaking energy. * * @throws CDKException */ public synchronized void sortResultsByEnergies() throws CDKException { Map<Integer, AtomAtomMapping> allEnergyAtomMCS = Collections.synchronizedSortedMap(new TreeMap<>()); Map<Integer, Double> stereoScoreMap = Collections.synchronizedSortedMap(new TreeMap<>()); Map<Integer, Integer> fragmentScoreMap = Collections.synchronizedSortedMap(new TreeMap<>()); Map<Integer, Double> energySelectionMap = Collections.synchronizedSortedMap(new TreeMap<>()); initializeMaps(allEnergyAtomMCS, stereoScoreMap, fragmentScoreMap, energySelectionMap); double lowestEnergyScore = energyFilter.sortResults(allEnergyAtomMCS, energySelectionMap); clear(); int counter = 0; for (Map.Entry<Integer, Double> map : energySelectionMap.entrySet()) { if (lowestEnergyScore == map.getValue()) { addSolution(counter, map.getKey(), allEnergyAtomMCS, stereoScoreMap, energySelectionMap, fragmentScoreMap); counter++; } } if (lowestEnergyScore != EnergyFilter.MAX_ENERGY) { clear(allEnergyAtomMCS, stereoScoreMap, fragmentScoreMap, energySelectionMap); } }
Example 6
Source Project: netbeans File: SaasGroup.java License: Apache License 2.0 | 5 votes |
public List<SaasGroup> getChildrenGroups() { if (children == null) { children = Collections.synchronizedSortedMap(new TreeMap<String,SaasGroup>()); for (Group g : delegate.getGroup()) { SaasGroup sg = new SaasGroup(this, g); children.put(sg.getName(), sg); } } return new ArrayList<SaasGroup>(children.values()); }
Example 7
Source Project: dragonwell8_jdk File: java_util_Collections_SynchronizedSortedMap.java License: GNU General Public License v2.0 | 4 votes |
protected SortedMap<String, String> getAnotherObject() { SortedMap<String, String> map = new TreeMap<String, String>(); return Collections.synchronizedSortedMap(map); }
Example 8
Source Project: TencentKona-8 File: java_util_Collections_SynchronizedSortedMap.java License: GNU General Public License v2.0 | 4 votes |
protected SortedMap<String, String> getObject() { SortedMap<String, String> map = new TreeMap<String, String>(); map.put("key", "value"); return Collections.synchronizedSortedMap(map); }
Example 9
Source Project: openjdk-8-source File: java_util_Collections_SynchronizedSortedMap.java License: GNU General Public License v2.0 | 4 votes |
protected SortedMap<String, String> getObject() { SortedMap<String, String> map = new TreeMap<String, String>(); map.put("key", "value"); return Collections.synchronizedSortedMap(map); }
Example 10
Source Project: hottub File: java_util_Collections_SynchronizedSortedMap.java License: GNU General Public License v2.0 | 4 votes |
protected SortedMap<String, String> getAnotherObject() { SortedMap<String, String> map = new TreeMap<String, String>(); return Collections.synchronizedSortedMap(map); }
Example 11
Source Project: jdk8u-dev-jdk File: java_util_Collections_SynchronizedSortedMap.java License: GNU General Public License v2.0 | 4 votes |
protected SortedMap<String, String> getObject() { SortedMap<String, String> map = new TreeMap<String, String>(); map.put("key", "value"); return Collections.synchronizedSortedMap(map); }
Example 12
Source Project: jdk8u-dev-jdk File: java_util_Collections_SynchronizedSortedMap.java License: GNU General Public License v2.0 | 4 votes |
protected SortedMap<String, String> getAnotherObject() { SortedMap<String, String> map = new TreeMap<String, String>(); return Collections.synchronizedSortedMap(map); }
Example 13
Source Project: openjdk-jdk8u-backup File: java_util_Collections_SynchronizedSortedMap.java License: GNU General Public License v2.0 | 4 votes |
protected SortedMap<String, String> getObject() { SortedMap<String, String> map = new TreeMap<String, String>(); map.put("key", "value"); return Collections.synchronizedSortedMap(map); }
Example 14
Source Project: openjdk-jdk8u-backup File: java_util_Collections_SynchronizedSortedMap.java License: GNU General Public License v2.0 | 4 votes |
protected SortedMap<String, String> getAnotherObject() { SortedMap<String, String> map = new TreeMap<String, String>(); return Collections.synchronizedSortedMap(map); }
Example 15
Source Project: openjdk-jdk9 File: java_util_Collections_SynchronizedSortedMap.java License: GNU General Public License v2.0 | 4 votes |
protected SortedMap<String, String> getObject() { SortedMap<String, String> map = new TreeMap<String, String>(); map.put("key", "value"); return Collections.synchronizedSortedMap(map); }
Example 16
Source Project: openjdk-8 File: java_util_Collections_SynchronizedSortedMap.java License: GNU General Public License v2.0 | 4 votes |
protected SortedMap<String, String> getObject() { SortedMap<String, String> map = new TreeMap<String, String>(); map.put("key", "value"); return Collections.synchronizedSortedMap(map); }
Example 17
Source Project: openhab1-addons File: TellstickBinding.java License: Eclipse Public License 2.0 | 4 votes |
public TellstickBinding() { messageQue = Collections.synchronizedSortedMap(new TreeMap<TellstickDevice, TellstickSendEvent>()); controller = new TellstickController(messageQue); controllerThread = new Thread(controller); }
Example 18
Source Project: jdk8u-jdk File: java_util_Collections_SynchronizedSortedMap.java License: GNU General Public License v2.0 | 4 votes |
protected SortedMap<String, String> getAnotherObject() { SortedMap<String, String> map = new TreeMap<String, String>(); return Collections.synchronizedSortedMap(map); }
Example 19
Source Project: Iron File: SynchronizedCollectionsSerializer.java License: Apache License 2.0 | 4 votes |
@Override public Object create(final Object sourceCollection) { return Collections.synchronizedSortedMap((SortedMap<?, ?>) sourceCollection); }
Example 20
Source Project: Penetration_Testing_POC File: MapUtils.java License: Apache License 2.0 | 2 votes |
/** * Returns a synchronized sorted map backed by the given sorted map. * <p> * You must manually synchronize on the returned buffer's iterator to * avoid non-deterministic behavior: * * <pre> * Map m = MapUtils.synchronizedSortedMap(myMap); * Set s = m.keySet(); // outside synchronized block * synchronized (m) { // synchronized on MAP! * Iterator i = s.iterator(); * while (i.hasNext()) { * process (i.next()); * } * } * </pre> * * This method uses the implementation in {@link java.util.Collections Collections}. * * @param map the map to synchronize, must not be null * @return a synchronized map backed by the given map * @throws IllegalArgumentException if the map is null */ public static Map synchronizedSortedMap(SortedMap map) { return Collections.synchronizedSortedMap(map); }