@Test public void testSelectMaxKeyValue() { logger.info("selectMaxKeyValue"); AssociativeArray keyValueMap = new AssociativeArray(); keyValueMap.put("1", 1.0); keyValueMap.put("2", 2.0); keyValueMap.put("5", 5.0); keyValueMap.put("3", 3.0); keyValueMap.put("4", 4.0); Map.Entry<Object, Object> expResult = new AbstractMap.SimpleEntry<>("5", 5.0); Map.Entry<Object, Object> result = MapMethods.selectMaxKeyValue(keyValueMap); assertEquals(expResult, result); }
public static Map.Entry<Object, Object> selectMaxKeyValue(AssociativeArray keyValueMap) { Double maxValue=Double.NEGATIVE_INFINITY; Object maxValueKey = null; for(Map.Entry<Object, Object> entry : keyValueMap.entrySet()) { Double value = TypeInference.toDouble(entry.getValue()); if(value!=null && value>maxValue) { maxValue=value; maxValueKey=entry.getKey(); } } return new AbstractMap.SimpleEntry<>(maxValueKey, keyValueMap.get(maxValueKey)); }
MapMethods { public static Map.Entry<Object, Object> selectMaxKeyValue(AssociativeArray keyValueMap) { Double maxValue=Double.NEGATIVE_INFINITY; Object maxValueKey = null; for(Map.Entry<Object, Object> entry : keyValueMap.entrySet()) { Double value = TypeInference.toDouble(entry.getValue()); if(value!=null && value>maxValue) { maxValue=value; maxValueKey=entry.getKey(); } } return new AbstractMap.SimpleEntry<>(maxValueKey, keyValueMap.get(maxValueKey)); } }
MapMethods { public static Map.Entry<Object, Object> selectMaxKeyValue(AssociativeArray keyValueMap) { Double maxValue=Double.NEGATIVE_INFINITY; Object maxValueKey = null; for(Map.Entry<Object, Object> entry : keyValueMap.entrySet()) { Double value = TypeInference.toDouble(entry.getValue()); if(value!=null && value>maxValue) { maxValue=value; maxValueKey=entry.getKey(); } } return new AbstractMap.SimpleEntry<>(maxValueKey, keyValueMap.get(maxValueKey)); }  }
MapMethods { public static Map.Entry<Object, Object> selectMaxKeyValue(AssociativeArray keyValueMap) { Double maxValue=Double.NEGATIVE_INFINITY; Object maxValueKey = null; for(Map.Entry<Object, Object> entry : keyValueMap.entrySet()) { Double value = TypeInference.toDouble(entry.getValue()); if(value!=null && value>maxValue) { maxValue=value; maxValueKey=entry.getKey(); } } return new AbstractMap.SimpleEntry<>(maxValueKey, keyValueMap.get(maxValueKey)); }  static Map.Entry<Object, Object> selectMaxKeyValue(AssociativeArray keyValueMap); static Map.Entry<Object, Double> selectMaxKeyValue(Map<Object, Double> keyValueMap); static Map.Entry<Object, Object> selectMinKeyValue(AssociativeArray keyValueMap); static Map.Entry<Object, Double> selectMinKeyValue(Map<Object, Double> keyValueMap); static Map<K, V> sortNumberMapByKeyAscending(Map<K, V> map); static Map<K, V> sortNumberMapByKeyAscending(Set<Map.Entry<K, V>> entrySet); static Map<K, V> sortNumberMapByKeyDescending(Map<K, V> map); static Map<K, V> sortNumberMapByKeyDescending(Set<Map.Entry<K, V>> entrySet); static Map<K, V> sortNumberMapByValueAscending(Map<K, V> map); static Map<K, V> sortNumberMapByValueDescending(Map<K, V> map); static AssociativeArray sortAssociativeArrayByValueAscending(AssociativeArray associativeArray); static AssociativeArray sortAssociativeArrayByValueDescending(AssociativeArray associativeArray); }
MapMethods { public static Map.Entry<Object, Object> selectMaxKeyValue(AssociativeArray keyValueMap) { Double maxValue=Double.NEGATIVE_INFINITY; Object maxValueKey = null; for(Map.Entry<Object, Object> entry : keyValueMap.entrySet()) { Double value = TypeInference.toDouble(entry.getValue()); if(value!=null && value>maxValue) { maxValue=value; maxValueKey=entry.getKey(); } } return new AbstractMap.SimpleEntry<>(maxValueKey, keyValueMap.get(maxValueKey)); }  static Map.Entry<Object, Object> selectMaxKeyValue(AssociativeArray keyValueMap); static Map.Entry<Object, Double> selectMaxKeyValue(Map<Object, Double> keyValueMap); static Map.Entry<Object, Object> selectMinKeyValue(AssociativeArray keyValueMap); static Map.Entry<Object, Double> selectMinKeyValue(Map<Object, Double> keyValueMap); static Map<K, V> sortNumberMapByKeyAscending(Map<K, V> map); static Map<K, V> sortNumberMapByKeyAscending(Set<Map.Entry<K, V>> entrySet); static Map<K, V> sortNumberMapByKeyDescending(Map<K, V> map); static Map<K, V> sortNumberMapByKeyDescending(Set<Map.Entry<K, V>> entrySet); static Map<K, V> sortNumberMapByValueAscending(Map<K, V> map); static Map<K, V> sortNumberMapByValueDescending(Map<K, V> map); static AssociativeArray sortAssociativeArrayByValueAscending(AssociativeArray associativeArray); static AssociativeArray sortAssociativeArrayByValueDescending(AssociativeArray associativeArray);  }