@Test public void testArray_flip() { logger.info("array_flip"); Map<String, Integer> original = new HashMap<>(); original.put("1", 10); original.put("2", 11); original.put("3", 12); Map<Integer, String> expResult = new HashMap<>(); expResult.put(10, "1"); expResult.put(11, "2"); expResult.put(12, "3"); Map<Integer, String> result = PHPMethods.array_flip(original); assertEquals(expResult, result); }
public static <K,V> Map<V,K> array_flip(Map<K,V> map) { Map<V,K> flipped = new HashMap<>(); for(Map.Entry<K,V> entry : map.entrySet()) { flipped.put(entry.getValue(), entry.getKey()); } return flipped; }
PHPMethods { public static <K,V> Map<V,K> array_flip(Map<K,V> map) { Map<V,K> flipped = new HashMap<>(); for(Map.Entry<K,V> entry : map.entrySet()) { flipped.put(entry.getValue(), entry.getKey()); } return flipped; } }
PHPMethods { public static <K,V> Map<V,K> array_flip(Map<K,V> map) { Map<V,K> flipped = new HashMap<>(); for(Map.Entry<K,V> entry : map.entrySet()) { flipped.put(entry.getValue(), entry.getKey()); } return flipped; }  }
PHPMethods { public static <K,V> Map<V,K> array_flip(Map<K,V> map) { Map<V,K> flipped = new HashMap<>(); for(Map.Entry<K,V> entry : map.entrySet()) { flipped.put(entry.getValue(), entry.getKey()); } return flipped; }  static String ltrim(String s); static String rtrim(String s); static int substr_count(final String string, final String substring); static int substr_count(final String string, final char character); static String preg_replace(String regex, String replacement, String subject); static String preg_replace(Pattern pattern, String replacement, String subject); static int preg_match(String regex, String subject); static int preg_match(Pattern pattern, String subject); static double round(double d, int i); static double log(double d, double base); static int mt_rand(); static int mt_rand(int min, int max); static double mt_rand(double min, double max); static Map<V,K> array_flip(Map<K,V> map); static void shuffle(T[] array); static void shuffle(T[] array, Random rnd); static Integer[] asort(T[] array); static Integer[] arsort(T[] array); static void arrangeByIndex(T[] array, Integer[] indexes); static double[] array_clone(double[] a); static double[][] array_clone(double[][] a); }
PHPMethods { public static <K,V> Map<V,K> array_flip(Map<K,V> map) { Map<V,K> flipped = new HashMap<>(); for(Map.Entry<K,V> entry : map.entrySet()) { flipped.put(entry.getValue(), entry.getKey()); } return flipped; }  static String ltrim(String s); static String rtrim(String s); static int substr_count(final String string, final String substring); static int substr_count(final String string, final char character); static String preg_replace(String regex, String replacement, String subject); static String preg_replace(Pattern pattern, String replacement, String subject); static int preg_match(String regex, String subject); static int preg_match(Pattern pattern, String subject); static double round(double d, int i); static double log(double d, double base); static int mt_rand(); static int mt_rand(int min, int max); static double mt_rand(double min, double max); static Map<V,K> array_flip(Map<K,V> map); static void shuffle(T[] array); static void shuffle(T[] array, Random rnd); static Integer[] asort(T[] array); static Integer[] arsort(T[] array); static void arrangeByIndex(T[] array, Integer[] indexes); static double[] array_clone(double[] a); static double[][] array_clone(double[][] a);  }