@@ -312,8 +312,8 @@ public Boolean apply(E arg) {
312312 }).isPresent ();
313313 }
314314
315- public static <E > boolean all (final Iterable <E > set , final Predicate <E > pred ) {
316- return every (set , pred );
315+ public static <E > boolean all (final Iterable <E > iterable , final Predicate <E > pred ) {
316+ return every (iterable , pred );
317317 }
318318
319319 public static <E > boolean some (final Iterable <E > iterable , final Predicate <E > pred ) {
@@ -483,13 +483,7 @@ public static <E> Set<E> sample(final List<E> list, final int howMany) {
483483 }
484484
485485 public static <E , T extends Comparable <? super T >> List <E > sortBy (final List <E > list , final Function1 <E , T > func ) {
486- final List <E > sortedList = newArrayList ();
487- each (list , new Block <E >() {
488- @ Override
489- public void apply (E arg ) {
490- sortedList .add (arg );
491- }
492- });
486+ final List <E > sortedList = newArrayList (list );
493487 Collections .sort (sortedList , new Comparator <E >() {
494488 @ Override
495489 public int compare (E o1 , E o2 ) {
@@ -500,13 +494,7 @@ public int compare(E o1, E o2) {
500494 }
501495
502496 public static <K , V extends Comparable <? super V >> List <Map <K , V >> sortBy (final List <Map <K , V >> list , final K key ) {
503- final List <Map <K , V >> sortedList = newArrayList ();
504- each (list , new Block <Map <K , V >>() {
505- @ Override
506- public void apply (Map <K , V > arg ) {
507- sortedList .add (arg );
508- }
509- });
497+ final List <Map <K , V >> sortedList = newArrayList (list );
510498 Collections .sort (sortedList , new Comparator <Map <K , V >>() {
511499 @ Override
512500 public int compare (Map <K , V > o1 , Map <K , V > o2 ) {
@@ -1784,16 +1772,16 @@ public static <T> List<T> concat(final Iterable<T> first, final Iterable<T> ...
17841772 }
17851773
17861774
1787- public List <T > concatTo (final Iterable <T > ... other ) {
1775+ public List <T > concatWith (final Iterable <T > ... other ) {
17881776 return concat (iterable , other );
17891777 }
17901778
1791- public static <T > List <T > slice (final Iterable <T > list , final int start ) {
1779+ public static <T > List <T > slice (final Iterable <T > iterable , final int start ) {
17921780 final List <T > result ;
17931781 if (start > 0 ) {
1794- result = newArrayList (list ).subList (start , size (list ));
1782+ result = newArrayList (iterable ).subList (start , size (iterable ));
17951783 } else {
1796- result = newArrayList (list ).subList (size (list ) + start , size (list ));
1784+ result = newArrayList (iterable ).subList (size (iterable ) + start , size (iterable ));
17971785 }
17981786 return result ;
17991787 }
@@ -1806,19 +1794,19 @@ public List<T> slice(final int start) {
18061794 return slice (iterable , start );
18071795 }
18081796
1809- public static <T > List <T > slice (final Iterable <T > list , final int start , final int end ) {
1797+ public static <T > List <T > slice (final Iterable <T > iterable , final int start , final int end ) {
18101798 final List <T > result ;
18111799 if (start > 0 ) {
18121800 if (end > 0 ) {
1813- result = newArrayList (list ).subList (start , end );
1801+ result = newArrayList (iterable ).subList (start , end );
18141802 } else {
1815- result = newArrayList (list ).subList (start , size (list ) + end );
1803+ result = newArrayList (iterable ).subList (start , size (iterable ) + end );
18161804 }
18171805 } else {
18181806 if (end > 0 ) {
1819- result = newArrayList (list ).subList (size (list ) + start , end );
1807+ result = newArrayList (iterable ).subList (size (iterable ) + start , end );
18201808 } else {
1821- result = newArrayList (list ).subList (size (list ) + start , size (list ) + end );
1809+ result = newArrayList (iterable ).subList (size (iterable ) + start , size (iterable ) + end );
18221810 }
18231811 }
18241812 return result ;
@@ -1832,8 +1820,8 @@ public List<T> slice(final int start, final int end) {
18321820 return slice (iterable , start , end );
18331821 }
18341822
1835- public static <T > List <T > reverse (final Iterable <T > list ) {
1836- final List <T > result = (List <T >) clone (newArrayList (list ));
1823+ public static <T > List <T > reverse (final Iterable <T > iterable ) {
1824+ final List <T > result = (List <T >) clone (newArrayList (iterable ));
18371825 Collections .reverse (result );
18381826 return result ;
18391827 }
@@ -1863,17 +1851,17 @@ private static <T> List<T> newArrayList() {
18631851 }
18641852 }
18651853
1866- protected static <T > List <T > newArrayList (Iterable <T > list ) {
1854+ protected static <T > List <T > newArrayList (Iterable <T > iterable ) {
18671855 try {
18681856 final Class <?> listsClass = classForName ("com.google.common.collect.Lists" );
1869- return (List <T >) listsClass .getDeclaredMethod ("newArrayList" , Iterable .class ).invoke (null , list );
1857+ return (List <T >) listsClass .getDeclaredMethod ("newArrayList" , Iterable .class ).invoke (null , iterable );
18701858 } catch (Exception e ) {
18711859 final List <T > result ;
1872- if (list instanceof Collection ) {
1873- result = new ArrayList <T >((Collection ) list );
1860+ if (iterable instanceof Collection ) {
1861+ result = new ArrayList <T >((Collection ) iterable );
18741862 } else {
18751863 result = new ArrayList <T >();
1876- for (final T item : list ) {
1864+ for (final T item : iterable ) {
18771865 result .add (item );
18781866 }
18791867 }
@@ -1900,13 +1888,13 @@ private static <T> Set<T> newLinkedHashSet() {
19001888 }
19011889 }
19021890
1903- private static <T > Set <T > newHashSet (Iterable <T > list ) {
1891+ private static <T > Set <T > newHashSet (Iterable <T > iterable ) {
19041892 try {
19051893 final Class <?> setsClass = classForName ("com.google.common.collect.Sets" );
1906- return (Set <T >) setsClass .getDeclaredMethod ("newHashSet" , Iterable .class ).invoke (null , list );
1894+ return (Set <T >) setsClass .getDeclaredMethod ("newHashSet" , Iterable .class ).invoke (null , iterable );
19071895 } catch (Exception e ) {
19081896 final Set <T > result = new HashSet <T >();
1909- for (final T item : list ) {
1897+ for (final T item : iterable ) {
19101898 result .add (item );
19111899 }
19121900 return result ;
0 commit comments