@@ -1777,33 +1777,61 @@ public static <E> int lastIndexOf(final E[] array, final E value) {
17771777 /*
17781778 * Documented, #range
17791779 */
1780- public static int [] range (int stop ) {
1780+ public static List < Integer > range (int stop ) {
17811781 return range (0 , stop , 1 );
17821782 }
17831783
1784- public static int [] range (int start , int stop ) {
1784+ public static List < Integer > range (int start , int stop ) {
17851785 return range (start , stop , start < stop ? 1 : -1 );
17861786 }
17871787
1788- public static int [] range (int start , int stop , int step ) {
1789- int [] array = new int [Math .abs (stop - start ) / Math .abs (step )];
1788+ public static List <Integer > range (int start , int stop , int step ) {
1789+ List <Integer > list = U .newArrayList ();
1790+ if (step == 0 ) {
1791+ return list ;
1792+ }
17901793 if (start < stop ) {
1791- for (int index = start , index2 = 0 ; index < stop ; index += step , index2 += 1 ) {
1792- array [ index2 ] = index ;
1794+ for (int value = start ; value < stop ; value += step ) {
1795+ list . add ( value ) ;
17931796 }
17941797 } else {
1795- for (int index = start , index2 = 0 ; index > stop ; index += step , index2 += 1 ) {
1796- array [ index2 ] = index ;
1798+ for (int value = start ; value > stop ; value += step ) {
1799+ list . add ( value ) ;
17971800 }
17981801 }
1799- return array ;
1802+ return list ;
1803+ }
1804+
1805+ public static List <Character > range (char stop ) {
1806+ return range ('a' , stop , 1 );
1807+ }
1808+
1809+ public static List <Character > range (char start , char stop ) {
1810+ return range (start , stop , start < stop ? 1 : -1 );
1811+ }
1812+
1813+ public static List <Character > range (char start , char stop , int step ) {
1814+ List <Character > list = U .newArrayList ();
1815+ if (step == 0 ) {
1816+ return list ;
1817+ }
1818+ if (start < stop ) {
1819+ for (char value = start ; value < stop ; value += step ) {
1820+ list .add (value );
1821+ }
1822+ } else {
1823+ for (char value = start ; value > stop ; value += step ) {
1824+ list .add (value );
1825+ }
1826+ }
1827+ return list ;
18001828 }
18011829
18021830 public static <T > List <List <T >> chunk (final Iterable <T > iterable , final int size ) {
18031831 if (size <= 0 ) {
18041832 return newArrayList ();
18051833 }
1806- return chunk (iterable , size , size );
1834+ return chunk (iterable , size , size );
18071835 }
18081836
18091837 public static <T > List <List <T >> chunk (final Iterable <T > iterable , final int size , final int step ) {
@@ -2920,15 +2948,15 @@ public Chain<T> difference(final List<T> ... lists) {
29202948 }
29212949
29222950 public Chain <Integer > range (final int stop ) {
2923- return new Chain <Integer >(newIntegerList ( U .range (stop ) ));
2951+ return new Chain <Integer >(U .range (stop ));
29242952 }
29252953
29262954 public Chain <Integer > range (final int start , final int stop ) {
2927- return new Chain <Integer >(newIntegerList ( U .range (start , stop ) ));
2955+ return new Chain <Integer >(U .range (start , stop ));
29282956 }
29292957
29302958 public Chain <Integer > range (final int start , final int stop , final int step ) {
2931- return new Chain <Integer >(newIntegerList ( U .range (start , stop , step ) ));
2959+ return new Chain <Integer >(U .range (start , stop , step ));
29322960 }
29332961
29342962 public Chain <List <T >> chunk (final int size ) {
0 commit comments