@@ -1245,37 +1245,33 @@ public static <K, V> Set<K> keys(final Map<K, V> object) {
12451245 return object .keySet ();
12461246 }
12471247
1248- public static <K , V > List <V > values (final Map <K , V > object ) {
1249- final List <V > result = newArrayList ();
1250- for (final Map .Entry <K , V > entry : object .entrySet ()) {
1251- result .add (entry .getValue ());
1252- }
1253- return result ;
1248+ public static <K , V > Collection <V > values (final Map <K , V > object ) {
1249+ return object .values ();
12541250 }
12551251
12561252 public static <K , V > List <Tuple <K , V >> mapObject (final Map <K , V > object , final Function1 <? super V , V > func ) {
1257- return map (newArrayList (object .keySet ()), new Function1 <K , Tuple <K , V >>() {
1253+ return map (newArrayList (object .entrySet ()), new Function1 <Map . Entry < K , V > , Tuple <K , V >>() {
12581254 @ Override
1259- public Tuple <K , V > apply (K key ) {
1260- return Tuple .create (key , func .apply (object . get ( key )));
1255+ public Tuple <K , V > apply (Map . Entry < K , V > entry ) {
1256+ return Tuple .create (entry . getKey () , func .apply (entry . getValue ( )));
12611257 }
12621258 });
12631259 }
12641260
12651261 public static <K , V > List <Tuple <K , V >> pairs (final Map <K , V > object ) {
1266- return map (newArrayList (object .keySet ()), new Function1 <K , Tuple <K , V >>() {
1262+ return map (newArrayList (object .entrySet ()), new Function1 <Map . Entry < K , V > , Tuple <K , V >>() {
12671263 @ Override
1268- public Tuple <K , V > apply (K key ) {
1269- return Tuple .create (key , object . get ( key ));
1264+ public Tuple <K , V > apply (Map . Entry < K , V > entry ) {
1265+ return Tuple .create (entry . getKey (), entry . getValue ( ));
12701266 }
12711267 });
12721268 }
12731269
12741270 public static <K , V > List <Tuple <V , K >> invert (final Map <K , V > object ) {
1275- return map (newArrayList (object .keySet ()), new Function1 <K , Tuple <V , K >>() {
1271+ return map (newArrayList (object .entrySet ()), new Function1 <Map . Entry < K , V > , Tuple <V , K >>() {
12761272 @ Override
1277- public Tuple <V , K > apply (K key ) {
1278- return Tuple .create (object . get ( key ), key );
1273+ public Tuple <V , K > apply (Map . Entry < K , V > entry ) {
1274+ return Tuple .create (entry . getValue ( ), entry . getKey () );
12791275 }
12801276 });
12811277 }
0 commit comments