@Test public void testSelectMinKeyValue() { logger.info("selectMaxKeyValue"); AssociativeArray keyValueMap = new AssociativeArray(); keyValueMap.put("1", 1); keyValueMap.put("2", 2); keyValueMap.put("5", 5); keyValueMap.put("3", 3); keyValueMap.put("4", 4); Map.Entry<Object, Object> expResult = new AbstractMap.SimpleEntry<>("1", 1); Map.Entry<Object, Object> result = MapMethods.selectMinKeyValue(keyValueMap); assertEquals(expResult, result); }
public static Map.Entry<Object, Object> selectMinKeyValue(AssociativeArray keyValueMap) { Double minValue=Double.POSITIVE_INFINITY; Object minValueKey = null; for(Map.Entry<Object, Object> entry : keyValueMap.entrySet()) { Double value = TypeInference.toDouble(entry.getValue()); if(value!=null && value<minValue) { minValue=value; minValueKey=entry.getKey(); } } return new AbstractMap.SimpleEntry<>(minValueKey, keyValueMap.get(minValueKey)); }
MapMethods { public static Map.Entry<Object, Object> selectMinKeyValue(AssociativeArray keyValueMap) { Double minValue=Double.POSITIVE_INFINITY; Object minValueKey = null; for(Map.Entry<Object, Object> entry : keyValueMap.entrySet()) { Double value = TypeInference.toDouble(entry.getValue()); if(value!=null && value<minValue) { minValue=value; minValueKey=entry.getKey(); } } return new AbstractMap.SimpleEntry<>(minValueKey, keyValueMap.get(minValueKey)); } }
MapMethods { public static Map.Entry<Object, Object> selectMinKeyValue(AssociativeArray keyValueMap) { Double minValue=Double.POSITIVE_INFINITY; Object minValueKey = null; for(Map.Entry<Object, Object> entry : keyValueMap.entrySet()) { Double value = TypeInference.toDouble(entry.getValue()); if(value!=null && value<minValue) { minValue=value; minValueKey=entry.getKey(); } } return new AbstractMap.SimpleEntry<>(minValueKey, keyValueMap.get(minValueKey)); }  }
MapMethods { public static Map.Entry<Object, Object> selectMinKeyValue(AssociativeArray keyValueMap) { Double minValue=Double.POSITIVE_INFINITY; Object minValueKey = null; for(Map.Entry<Object, Object> entry : keyValueMap.entrySet()) { Double value = TypeInference.toDouble(entry.getValue()); if(value!=null && value<minValue) { minValue=value; minValueKey=entry.getKey(); } } return new AbstractMap.SimpleEntry<>(minValueKey, keyValueMap.get(minValueKey)); }  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> selectMinKeyValue(AssociativeArray keyValueMap) { Double minValue=Double.POSITIVE_INFINITY; Object minValueKey = null; for(Map.Entry<Object, Object> entry : keyValueMap.entrySet()) { Double value = TypeInference.toDouble(entry.getValue()); if(value!=null && value<minValue) { minValue=value; minValueKey=entry.getKey(); } } return new AbstractMap.SimpleEntry<>(minValueKey, keyValueMap.get(minValueKey)); }  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);  }