/[classpath]/classpath/java/util/Arrays.java
ViewVC logotype

Diff of /classpath/java/util/Arrays.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.21 by gnu_andrew, Tue Aug 17 22:19:56 2004 UTC revision 1.22 by mark, Fri Aug 27 22:41:02 2004 UTC
# Line 1  Line 1 
1  /* Arrays.java -- Utility class with methods to operate on arrays  /* Arrays.java -- Utility class with methods to operate on arrays
2     Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 Free Software Foundation, Inc.     Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004
3       Free Software Foundation, Inc.
4    
5  This file is part of GNU Classpath.  This file is part of GNU Classpath.
6    
# Line 968  public class Arrays Line 969  public class Arrays
969    {    {
970      if (fromIndex > toIndex)      if (fromIndex > toIndex)
971        throw new IllegalArgumentException();        throw new IllegalArgumentException();
972        if (fromIndex < 0)
973          throw new ArrayIndexOutOfBoundsException();
974      qsort(a, fromIndex, toIndex - fromIndex);      qsort(a, fromIndex, toIndex - fromIndex);
975    }    }
976    
# Line 1028  public class Arrays Line 1031  public class Arrays
1031      if (count <= 7)      if (count <= 7)
1032        {        {
1033          for (int i = from + 1; i < from + count; i++)          for (int i = from + 1; i < from + count; i++)
1034            for (int j = i; j > 0 && array[j - 1] > array[j]; j--)            for (int j = i; j > from && array[j - 1] > array[j]; j--)
1035              swap(j, j - 1, array);              swap(j, j - 1, array);
1036          return;          return;
1037        }        }
# Line 1130  public class Arrays Line 1133  public class Arrays
1133    {    {
1134      if (fromIndex > toIndex)      if (fromIndex > toIndex)
1135        throw new IllegalArgumentException();        throw new IllegalArgumentException();
1136        if (fromIndex < 0)
1137          throw new ArrayIndexOutOfBoundsException();
1138      qsort(a, fromIndex, toIndex - fromIndex);      qsort(a, fromIndex, toIndex - fromIndex);
1139    }    }
1140    
# Line 1190  public class Arrays Line 1195  public class Arrays
1195      if (count <= 7)      if (count <= 7)
1196        {        {
1197          for (int i = from + 1; i < from + count; i++)          for (int i = from + 1; i < from + count; i++)
1198            for (int j = i; j > 0 && array[j - 1] > array[j]; j--)            for (int j = i; j > from && array[j - 1] > array[j]; j--)
1199              swap(j, j - 1, array);              swap(j, j - 1, array);
1200          return;          return;
1201        }        }
# Line 1292  public class Arrays Line 1297  public class Arrays
1297    {    {
1298      if (fromIndex > toIndex)      if (fromIndex > toIndex)
1299        throw new IllegalArgumentException();        throw new IllegalArgumentException();
1300        if (fromIndex < 0)
1301          throw new ArrayIndexOutOfBoundsException();
1302      qsort(a, fromIndex, toIndex - fromIndex);      qsort(a, fromIndex, toIndex - fromIndex);
1303    }    }
1304    
# Line 1352  public class Arrays Line 1359  public class Arrays
1359      if (count <= 7)      if (count <= 7)
1360        {        {
1361          for (int i = from + 1; i < from + count; i++)          for (int i = from + 1; i < from + count; i++)
1362            for (int j = i; j > 0 && array[j - 1] > array[j]; j--)            for (int j = i; j > from && array[j - 1] > array[j]; j--)
1363              swap(j, j - 1, array);              swap(j, j - 1, array);
1364          return;          return;
1365        }        }
1366    
# Line 1454  public class Arrays Line 1461  public class Arrays
1461    {    {
1462      if (fromIndex > toIndex)      if (fromIndex > toIndex)
1463        throw new IllegalArgumentException();        throw new IllegalArgumentException();
1464        if (fromIndex < 0)
1465          throw new ArrayIndexOutOfBoundsException();
1466      qsort(a, fromIndex, toIndex - fromIndex);      qsort(a, fromIndex, toIndex - fromIndex);
1467    }    }
1468    
# Line 1526  public class Arrays Line 1535  public class Arrays
1535      if (count <= 7)      if (count <= 7)
1536        {        {
1537          for (int i = from + 1; i < from + count; i++)          for (int i = from + 1; i < from + count; i++)
1538            for (int j = i; j > 0 && array[j - 1] > array[j]; j--)            for (int j = i; j > from && array[j - 1] > array[j]; j--)
1539              swap(j, j - 1, array);              swap(j, j - 1, array);
1540          return;          return;
1541        }        }
# Line 1628  public class Arrays Line 1637  public class Arrays
1637    {    {
1638      if (fromIndex > toIndex)      if (fromIndex > toIndex)
1639        throw new IllegalArgumentException();        throw new IllegalArgumentException();
1640        if (fromIndex < 0)
1641          throw new ArrayIndexOutOfBoundsException();
1642      qsort(a, fromIndex, toIndex - fromIndex);      qsort(a, fromIndex, toIndex - fromIndex);
1643    }    }
1644    
# Line 1700  public class Arrays Line 1711  public class Arrays
1711      if (count <= 7)      if (count <= 7)
1712        {        {
1713          for (int i = from + 1; i < from + count; i++)          for (int i = from + 1; i < from + count; i++)
1714            for (int j = i; j > 0 && array[j - 1] > array[j]; j--)            for (int j = i; j > from && array[j - 1] > array[j]; j--)
1715              swap(j, j - 1, array);              swap(j, j - 1, array);
1716          return;          return;
1717        }        }
# Line 1802  public class Arrays Line 1813  public class Arrays
1813    {    {
1814      if (fromIndex > toIndex)      if (fromIndex > toIndex)
1815        throw new IllegalArgumentException();        throw new IllegalArgumentException();
1816        if (fromIndex < 0)
1817          throw new ArrayIndexOutOfBoundsException();
1818      qsort(a, fromIndex, toIndex - fromIndex);      qsort(a, fromIndex, toIndex - fromIndex);
1819    }    }
1820    
# Line 1865  public class Arrays Line 1878  public class Arrays
1878        {        {
1879          for (int i = from + 1; i < from + count; i++)          for (int i = from + 1; i < from + count; i++)
1880            for (int j = i;            for (int j = i;
1881                 j > 0 && Float.compare(array[j - 1], array[j]) > 0;                 j > from && Float.compare(array[j - 1], array[j]) > 0;
1882                 j--)                 j--)
1883              {              {
1884                swap(j, j - 1, array);                swap(j, j - 1, array);
# Line 1970  public class Arrays Line 1983  public class Arrays
1983    {    {
1984      if (fromIndex > toIndex)      if (fromIndex > toIndex)
1985        throw new IllegalArgumentException();        throw new IllegalArgumentException();
1986        if (fromIndex < 0)
1987          throw new ArrayIndexOutOfBoundsException();
1988      qsort(a, fromIndex, toIndex - fromIndex);      qsort(a, fromIndex, toIndex - fromIndex);
1989    }    }
1990    
# Line 2033  public class Arrays Line 2048  public class Arrays
2048        {        {
2049          for (int i = from + 1; i < from + count; i++)          for (int i = from + 1; i < from + count; i++)
2050            for (int j = i;            for (int j = i;
2051                 j > 0 && Double.compare(array[j - 1], array[j]) > 0;                 j > from && Double.compare(array[j - 1], array[j]) > 0;
2052                 j--)                 j--)
2053              {              {
2054                swap(j, j - 1, array);                swap(j, j - 1, array);
# Line 2203  public class Arrays Line 2218  public class Arrays
2218      if (fromIndex > toIndex)      if (fromIndex > toIndex)
2219        throw new IllegalArgumentException("fromIndex " + fromIndex        throw new IllegalArgumentException("fromIndex " + fromIndex
2220                                           + " > toIndex " + toIndex);                                           + " > toIndex " + toIndex);
2221        if (fromIndex < 0)
2222          throw new ArrayIndexOutOfBoundsException();
2223    
2224      // In general, the code attempts to be simple rather than fast, the      // In general, the code attempts to be simple rather than fast, the
2225      // idea being that a good optimising JIT will be able to optimise it      // idea being that a good optimising JIT will be able to optimise it

Legend:
Removed from v.1.21  
changed lines
  Added in v.1.22

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26