Java Code Examples for java.util.concurrent.ConcurrentHashMap#reduceKeys()
The following examples show how to use
java.util.concurrent.ConcurrentHashMap#reduceKeys() .
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 File: Main.java From Java-Coding-Problems with MIT License | 8 votes |
public static void main(String[] args) { ConcurrentHashMap<Integer, String> map = new ConcurrentHashMap<>(); map.put(1, "Tylor"); map.put(2, "Jenny"); map.put(3, "Tymmy"); map.put(4, "Anna"); map.put(5, "Tysha"); map.put(6, "Maria"); System.out.println("Map: \n" + map); String result = map.reduce(2, (k, v) -> v = v + " ", (t, v) -> t + v); System.out.println("\nNames concatenated and separated by tab via reduce():\n" + result); Integer maxKey = map.reduceKeys(2, (k1, k2) -> k1.compareTo(k2) > 0 ? k1 : k2); System.out.println("\nMaximum key via reduceKeys(): " + maxKey); String resultValue = map.reduceValues(2, (v) -> v = v + " ", (t, v) -> t + v); System.out.println("\nNames concatenated and separated by tab via reduceValues():\n" + resultValue); }
Example 2
Source File: ConcurrentHashMap8Test.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
/** * reduceKeysSequentially accumulates across all keys, */ public void testReduceKeysSequentially() { ConcurrentHashMap<Long, Long> m = longMap(); Long r; r = m.reduceKeys(Long.MAX_VALUE, (Long x, Long y) -> Long.valueOf(x.longValue() + y.longValue())); assertEquals((long)r, (long)SIZE * (SIZE - 1) / 2); }
Example 3
Source File: ConcurrentHashMap8Test.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
/** * reduceValuesSequentially accumulates across all values */ public void testReduceValuesSequentially() { ConcurrentHashMap<Long, Long> m = longMap(); Long r; r = m.reduceKeys(Long.MAX_VALUE, (Long x, Long y) -> Long.valueOf(x.longValue() + y.longValue())); assertEquals((long)r, (long)SIZE * (SIZE - 1) / 2); }
Example 4
Source File: ConcurrentHashMap8Test.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
/** * reduceKeysInParallel accumulates across all keys */ public void testReduceKeysInParallel() { ConcurrentHashMap<Long, Long> m = longMap(); Long r; r = m.reduceKeys(1L, (Long x, Long y) -> Long.valueOf(x.longValue() + y.longValue())); assertEquals((long)r, (long)SIZE * (SIZE - 1) / 2); }
Example 5
Source File: ConcurrentHashMap8Test.java From j2objc with Apache License 2.0 | 5 votes |
/** * reduceKeysSequentially accumulates across all keys, */ public void testReduceKeysSequentially() { ConcurrentHashMap<Long, Long> m = longMap(); Long r; r = m.reduceKeys(Long.MAX_VALUE, (Long x, Long y) -> Long.valueOf(x.longValue() + y.longValue())); assertEquals((long)r, (long)SIZE * (SIZE - 1) / 2); }
Example 6
Source File: ConcurrentHashMap8Test.java From j2objc with Apache License 2.0 | 5 votes |
/** * reduceValuesSequentially accumulates across all values */ public void testReduceValuesSequentially() { ConcurrentHashMap<Long, Long> m = longMap(); Long r; r = m.reduceKeys(Long.MAX_VALUE, (Long x, Long y) -> Long.valueOf(x.longValue() + y.longValue())); assertEquals((long)r, (long)SIZE * (SIZE - 1) / 2); }
Example 7
Source File: ConcurrentHashMap8Test.java From j2objc with Apache License 2.0 | 5 votes |
/** * reduceKeysInParallel accumulates across all keys */ public void testReduceKeysInParallel() { ConcurrentHashMap<Long, Long> m = longMap(); Long r; r = m.reduceKeys(1L, (Long x, Long y) -> Long.valueOf(x.longValue() + y.longValue())); assertEquals((long)r, (long)SIZE * (SIZE - 1) / 2); }