harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From py...@apache.org
Subject svn commit: r586341 [1/2] - in /harmony/enhanced/classlib/branches/java6/modules/luni/src: main/java/java/lang/ main/java/java/util/ test/api/common/org/apache/harmony/luni/tests/java/util/
Date Fri, 19 Oct 2007 09:03:24 GMT
Author: pyang
Date: Fri Oct 19 02:03:23 2007
New Revision: 586341

URL: http://svn.apache.org/viewvc?rev=586341&view=rev
Log:
Format the code, fix a minor NPE difference with RI 6 in UnknownFormatConversionException

Modified:
    harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/lang/Math.java
    harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/util/Collections.java
    harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/util/EnumMap.java
    harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/util/GregorianCalendar.java
    harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/util/LinkedList.java
    harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/util/Stack.java
    harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/util/UnknownFormatConversionException.java
    harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/UnknownFormatConversionExceptionTest.java

Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/lang/Math.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/lang/Math.java?rev=586341&r1=586340&r2=586341&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/lang/Math.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/lang/Math.java Fri Oct 19 02:03:23 2007
@@ -17,14 +17,13 @@
 
 package java.lang;
 
-
 /**
  * Class math provides various floating point support routines and some standard
  * constants.
  */
 public final class Math {
-	
-	private static final int FLOAT_EXPONENT_BIAS = 127;
+
+    private static final int FLOAT_EXPONENT_BIAS = 127;
 
     private static final int FLOAT_EXPONENT_MASK = 0x7F800000;
 
@@ -47,115 +46,120 @@
     private static final long DOUBLE_MANTISSA_MASK = 0x000fffffffffffffL;
 
     private static final long DOUBLE_SIGN_MASK = 0x8000000000000000L;
-    
-	/**
-	 * Standard math constants.
-	 */
-	public static final double E = 2.718281828459045;
-
-	public static final double PI = 3.141592653589793;
-
-	private static java.util.Random random;
-
-	/**
-	 * Prevents this class from being instantiated.
-	 */
-	private Math() {
-	}
-
-	/**
-	 * Answers the absolute value of the argument.
-	 * 
-	 * @param d
-	 *            the value to be converted
-	 * @return the argument if it is positive, otherwise the negation of the
-	 *         argument.
-	 */
-	public static double abs(double d) {
-		long bits = Double.doubleToLongBits(d);
-		bits &= 0x7fffffffffffffffL;
-		return Double.longBitsToDouble(bits);
-	}
-
-	/**
-	 * Answers the absolute value of the argument.
-	 * 
-	 * @param f
-	 *            the value to be converted
-	 * @return the argument if it is positive, otherwise the negation of the
-	 *         argument.
-	 */
-	public static float abs(float f) {
-		int bits = Float.floatToIntBits(f);
-		bits &= 0x7fffffff;
-		return Float.intBitsToFloat(bits);
-	}
-
-	/**
-	 * Answers the absolute value of the argument.
-	 * 
-	 * @param i
-	 *            the value to be converted
-	 * @return the argument if it is positive, otherwise the negation of the
-	 *         argument.
-	 */
-	public static int abs(int i) {
-		return i >= 0 ? i : -i;
-	}
-
-	/**
-	 * Answers the absolute value of the argument.
-	 * 
-	 * @param l
-	 *            the value to be converted
-	 * @return the argument if it is positive, otherwise the negation of the
-	 *         argument.
-	 */
-	public static long abs(long l) {
-		return l >= 0 ? l : -l;
-	}
-
-	/**
-	 * Answers the closest double approximation of the arc cosine of the
-	 * argument
-	 * 
-	 * @param d
-	 *            the value to compute acos of
-	 * @return the arc cosine of the argument.
-	 */
-	public static native double acos(double d);
-
-	/**
-	 * Answers the closest double approximation of the arc sine of the argument
-	 * 
-	 * @param d
-	 *            the value to compute asin of
-	 * @return the arc sine of the argument.
-	 */
-	public static native double asin(double d);
-
-	/**
-	 * Answers the closest double approximation of the arc tangent of the
-	 * argument
-	 * 
-	 * @param d
-	 *            the value to compute atan of
-	 * @return the arc tangent of the argument.
-	 */
-	public static native double atan(double d);
-
-	/**
-	 * Answers the closest double approximation of the arc tangent of the result
-	 * of dividing the first argument by the second argument.
-	 * 
-	 * @param d1
-	 *            the numerator of the value to compute atan of
-	 * @param d2
-	 *            the denominator of the value to compute atan of
-	 * @return the arc tangent of d1/d2.
-	 */
-	public static native double atan2(double d1, double d2);
-    
+
+    /**
+     * Standard math constants.
+     */
+    public static final double E = 2.718281828459045;
+
+    /**
+     * Standard math constants: PI
+     * 
+     * @since 1.6
+     */
+    public static final double PI = 3.141592653589793;
+
+    private static java.util.Random random;
+
+    /**
+     * Prevents this class from being instantiated.
+     */
+    private Math() {
+    }
+
+    /**
+     * Answers the absolute value of the argument.
+     * 
+     * @param d
+     *            the value to be converted
+     * @return the argument if it is positive, otherwise the negation of the
+     *         argument.
+     */
+    public static double abs(double d) {
+        long bits = Double.doubleToLongBits(d);
+        bits &= 0x7fffffffffffffffL;
+        return Double.longBitsToDouble(bits);
+    }
+
+    /**
+     * Answers the absolute value of the argument.
+     * 
+     * @param f
+     *            the value to be converted
+     * @return the argument if it is positive, otherwise the negation of the
+     *         argument.
+     */
+    public static float abs(float f) {
+        int bits = Float.floatToIntBits(f);
+        bits &= 0x7fffffff;
+        return Float.intBitsToFloat(bits);
+    }
+
+    /**
+     * Answers the absolute value of the argument.
+     * 
+     * @param i
+     *            the value to be converted
+     * @return the argument if it is positive, otherwise the negation of the
+     *         argument.
+     */
+    public static int abs(int i) {
+        return i >= 0 ? i : -i;
+    }
+
+    /**
+     * Answers the absolute value of the argument.
+     * 
+     * @param l
+     *            the value to be converted
+     * @return the argument if it is positive, otherwise the negation of the
+     *         argument.
+     */
+    public static long abs(long l) {
+        return l >= 0 ? l : -l;
+    }
+
+    /**
+     * Answers the closest double approximation of the arc cosine of the
+     * argument
+     * 
+     * @param d
+     *            the value to compute acos of
+     * @return the arc cosine of the argument.
+     */
+    public static native double acos(double d);
+
+    /**
+     * Answers the closest double approximation of the arc sine of the argument
+     * 
+     * @param d
+     *            the value to compute asin of
+     * @return the arc sine of the argument.
+     */
+    public static native double asin(double d);
+
+    /**
+     * Answers the closest double approximation of the arc tangent of the
+     * argument
+     * 
+     * @param d
+     *            the value to compute atan of
+     * @return the arc tangent of the argument.
+     */
+    public static native double atan(double d);
+
+    /**
+     * Answers the closest double approximation of the arc tangent of the result
+     * of dividing the first argument by the second argument.
+     * 
+     * @param d1
+     *            the numerator of the value to compute atan of
+     * @param d2
+     *            the denominator of the value to compute atan of
+     * @return the arc tangent of d1/d2.
+     */
+    public static native double atan2(double d1, double d2);
+
     /**
      * Answers the closest double approximation of the cube root of the
      * argument. The final result should be within 1ulp of the real result.
@@ -166,25 +170,25 @@
      */
     public static native double cbrt(double d);
 
-	/**
-	 * Answers the double conversion of the most negative (i.e. closest to
-	 * negative infinity) integer value which is greater than the argument.
-	 * 
-	 * @param d
-	 *            the value to be converted
-	 * @return the ceiling of the argument.
-	 */
-	public static native double ceil(double d);
-
-	/**
-	 * Answers the closest double approximation of the cosine of the argument
-	 * 
-	 * @param d
-	 *            the value to compute cos of
-	 * @return the cosine of the argument.
-	 */
-	public static native double cos(double d);
-    
+    /**
+     * Answers the double conversion of the most negative (i.e. closest to
+     * negative infinity) integer value which is greater than the argument.
+     * 
+     * @param d
+     *            the value to be converted
+     * @return the ceiling of the argument.
+     */
+    public static native double ceil(double d);
+
+    /**
+     * Answers the closest double approximation of the cosine of the argument
+     * 
+     * @param d
+     *            the value to compute cos of
+     * @return the cosine of the argument.
+     */
+    public static native double cos(double d);
+
     /**
      * Answers the closest double approximation of the hyperbolic cosine of the
      * argument. The final result should be within 2.5ulps of the real result.
@@ -195,16 +199,16 @@
      */
     public static native double cosh(double d);
 
-	/**
-	 * Answers the closest double approximation of the raising "e" to the power
-	 * of the argument
-	 * 
-	 * @param d
-	 *            the value to compute the exponential of
-	 * @return the exponential of the argument.
-	 */
-	public static native double exp(double d);
-    
+    /**
+     * Answers the closest double approximation of the raising "e" to the power
+     * of the argument
+     * 
+     * @param d
+     *            the value to compute the exponential of
+     * @return the exponential of the argument.
+     */
+    public static native double exp(double d);
+
     /**
      * Answers the closest double approximation of <i>e</i><sup>d</sup> - 1.
      * If the argument is very close to 0, it is much more accurate to use
@@ -220,16 +224,16 @@
      */
     public static native double expm1(double d);
 
-	/**
-	 * Answers the double conversion of the most positive (i.e. closest to
-	 * positive infinity) integer value which is less than the argument.
-	 * 
-	 * @param d
-	 *            the value to be converted
-	 * @return the ceiling of the argument.
-	 */
-	public static native double floor(double d);
-    
+    /**
+     * Answers the double conversion of the most positive (i.e. closest to
+     * positive infinity) integer value which is less than the argument.
+     * 
+     * @param d
+     *            the value to be converted
+     * @return the ceiling of the argument.
+     */
+    public static native double floor(double d);
+
     /**
      * Answers sqrt(<i>x</i><sup>2</sup>+<i>y</i><sup>2</sup>). The
      * final result is without medium underflow or overflow.
@@ -246,27 +250,27 @@
      */
     public static native double hypot(double x, double y);
 
-	/**
-	 * Answers the remainder of dividing the first argument by the second using
-	 * the IEEE 754 rules.
-	 * 
-	 * @param d1
-	 *            the numerator of the operation
-	 * @param d2
-	 *            the denominator of the operation
-	 * @return the result of d1/d2.
-	 */
-	public static native double IEEEremainder(double d1, double d2);
-
-	/**
-	 * Answers the closest double approximation of the natural logarithm of the
-	 * argument
-	 * 
-	 * @param d
-	 *            the value to compute the log of
-	 * @return the natural logarithm of the argument.
-	 */
-	public static native double log(double d);
+    /**
+     * Answers the remainder of dividing the first argument by the second using
+     * the IEEE 754 rules.
+     * 
+     * @param d1
+     *            the numerator of the operation
+     * @param d2
+     *            the denominator of the operation
+     * @return the result of d1/d2.
+     */
+    public static native double IEEEremainder(double d1, double d2);
+
+    /**
+     * Answers the closest double approximation of the natural logarithm of the
+     * argument
+     * 
+     * @param d
+     *            the value to compute the log of
+     * @return the natural logarithm of the argument.
+     */
+    public static native double log(double d);
 
     /**
      * Answers the closest double approximation of the base 10 logarithm of the
@@ -277,7 +281,7 @@
      * @return the natural logarithm of the argument.
      */
     public static native double log10(double d);
-    
+
     /**
      * Answers the closest double approximation of the natural logarithm of the
      * sum of the argument and 1. If the argument is very close to 0, it is much
@@ -292,212 +296,212 @@
      */
     public static native double log1p(double d);
 
-	/**
-	 * Answers the most positive (i.e. closest to positive infinity) of the two
-	 * arguments.
-	 * 
-	 * @param d1
-	 *            the first argument to check
-	 * @param d2
-	 *            the second argument
-	 * @return the larger of d1 and d2.
-	 */
-	public static double max(double d1, double d2) {
-		if (d1 > d2)
-			return d1;
-		if (d1 < d2)
-			return d2;
-		/* if either arg is NaN, return NaN */
-		if (d1 != d2)
-			return Double.NaN;
-		/* max( +0.0,-0.0) == +0.0 */
-		if (d1 == 0.0
-				&& ((Double.doubleToLongBits(d1) & Double.doubleToLongBits(d2)) & 0x8000000000000000L) == 0)
-			return 0.0;
-		return d1;
-	}
-
-	/**
-	 * Answers the most positive (i.e. closest to positive infinity) of the two
-	 * arguments.
-	 * 
-	 * @param f1
-	 *            the first argument to check
-	 * @param f2
-	 *            the second argument
-	 * @return the larger of f1 and f2.
-	 */
-	public static float max(float f1, float f2) {
-		if (f1 > f2)
-			return f1;
-		if (f1 < f2)
-			return f2;
-		/* if either arg is NaN, return NaN */
-		if (f1 != f2)
-			return Float.NaN;
-		/* max( +0.0,-0.0) == +0.0 */
-		if (f1 == 0.0f
-				&& ((Float.floatToIntBits(f1) & Float.floatToIntBits(f2)) & 0x80000000) == 0)
-			return 0.0f;
-		return f1;
-	}
-
-	/**
-	 * Answers the most positive (i.e. closest to positive infinity) of the two
-	 * arguments.
-	 * 
-	 * @param i1
-	 *            the first argument to check
-	 * @param i2
-	 *            the second argument
-	 * @return the larger of i1 and i2.
-	 */
-	public static int max(int i1, int i2) {
-		return i1 > i2 ? i1 : i2;
-	}
-
-	/**
-	 * Answers the most positive (i.e. closest to positive infinity) of the two
-	 * arguments.
-	 * 
-	 * @param l1
-	 *            the first argument to check
-	 * @param l2
-	 *            the second argument
-	 * @return the larger of l1 and l2.
-	 */
-	public static long max(long l1, long l2) {
-		return l1 > l2 ? l1 : l2;
-	}
-
-	/**
-	 * Answers the most negative (i.e. closest to negative infinity) of the two
-	 * arguments.
-	 * 
-	 * @param d1
-	 *            the first argument to check
-	 * @param d2
-	 *            the second argument
-	 * @return the smaller of d1 and d2.
-	 */
-	public static double min(double d1, double d2) {
-		if (d1 > d2)
-			return d2;
-		if (d1 < d2)
-			return d1;
-		/* if either arg is NaN, return NaN */
-		if (d1 != d2)
-			return Double.NaN;
-		/* min( +0.0,-0.0) == -0.0 */
-		if (d1 == 0.0
-				&& ((Double.doubleToLongBits(d1) | Double.doubleToLongBits(d2)) & 0x8000000000000000l) != 0)
-			return 0.0 * (-1.0);
-		return d1;
-	}
-
-	/**
-	 * Answers the most negative (i.e. closest to negative infinity) of the two
-	 * arguments.
-	 * 
-	 * @param f1
-	 *            the first argument to check
-	 * @param f2
-	 *            the second argument
-	 * @return the smaller of f1 and f2.
-	 */
-	public static float min(float f1, float f2) {
-		if (f1 > f2)
-			return f2;
-		if (f1 < f2)
-			return f1;
-		/* if either arg is NaN, return NaN */
-		if (f1 != f2)
-			return Float.NaN;
-		/* min( +0.0,-0.0) == -0.0 */
-		if (f1 == 0.0f
-				&& ((Float.floatToIntBits(f1) | Float.floatToIntBits(f2)) & 0x80000000) != 0)
-			return 0.0f * (-1.0f);
-		return f1;
-	}
-
-	/**
-	 * Answers the most negative (i.e. closest to negative infinity) of the two
-	 * arguments.
-	 * 
-	 * @param i1
-	 *            the first argument to check
-	 * @param i2
-	 *            the second argument
-	 * @return the smaller of i1 and i2.
-	 */
-	public static int min(int i1, int i2) {
-		return i1 < i2 ? i1 : i2;
-	}
-
-	/**
-	 * Answers the most negative (i.e. closest to negative infinity) of the two
-	 * arguments.
-	 * 
-	 * @param l1
-	 *            the first argument to check
-	 * @param l2
-	 *            the second argument
-	 * @return the smaller of l1 and l2.
-	 */
-	public static long min(long l1, long l2) {
-		return l1 < l2 ? l1 : l2;
-	}
-
-	/**
-	 * Answers the closest double approximation of the result of raising the
-	 * first argument to the power of the second.
-	 * 
-	 * @param d1
-	 *            the base of the operation.
-	 * @param d2
-	 *            the exponent of the operation.
-	 * @return d1 to the power of d2
-	 */
-	public static native double pow(double d1, double d2);
-
-	/**
-	 * Answers the double conversion of the result of rounding the argument to
-	 * an integer.
-	 * 
-	 * @param d
-	 *            the value to be converted
-	 * @return the closest integer to the argument (as a double).
-	 */
-	public static native double rint(double d);
-
-	/**
-	 * Answers the result of rounding the argument to an integer.
-	 * 
-	 * @param d
-	 *            the value to be converted
-	 * @return the closest integer to the argument.
-	 */
-	public static long round(double d) {
-		// check for NaN
-		if (d != d)
-			return 0L;
-		return (long) floor(d + 0.5d);
-	}
-
-	/**
-	 * Answers the result of rounding the argument to an integer.
-	 * 
-	 * @param f
-	 *            the value to be converted
-	 * @return the closest integer to the argument.
-	 */
-	public static int round(float f) {
-		// check for NaN
-		if (f != f)
-			return 0;
-		return (int) floor(f + 0.5f);
-	}
-    
+    /**
+     * Answers the most positive (i.e. closest to positive infinity) of the two
+     * arguments.
+     * 
+     * @param d1
+     *            the first argument to check
+     * @param d2
+     *            the second argument
+     * @return the larger of d1 and d2.
+     */
+    public static double max(double d1, double d2) {
+        if (d1 > d2)
+            return d1;
+        if (d1 < d2)
+            return d2;
+        /* if either arg is NaN, return NaN */
+        if (d1 != d2)
+            return Double.NaN;
+        /* max( +0.0,-0.0) == +0.0 */
+        if (d1 == 0.0
+                && ((Double.doubleToLongBits(d1) & Double.doubleToLongBits(d2)) & 0x8000000000000000L) == 0)
+            return 0.0;
+        return d1;
+    }
+
+    /**
+     * Answers the most positive (i.e. closest to positive infinity) of the two
+     * arguments.
+     * 
+     * @param f1
+     *            the first argument to check
+     * @param f2
+     *            the second argument
+     * @return the larger of f1 and f2.
+     */
+    public static float max(float f1, float f2) {
+        if (f1 > f2)
+            return f1;
+        if (f1 < f2)
+            return f2;
+        /* if either arg is NaN, return NaN */
+        if (f1 != f2)
+            return Float.NaN;
+        /* max( +0.0,-0.0) == +0.0 */
+        if (f1 == 0.0f
+                && ((Float.floatToIntBits(f1) & Float.floatToIntBits(f2)) & 0x80000000) == 0)
+            return 0.0f;
+        return f1;
+    }
+
+    /**
+     * Answers the most positive (i.e. closest to positive infinity) of the two
+     * arguments.
+     * 
+     * @param i1
+     *            the first argument to check
+     * @param i2
+     *            the second argument
+     * @return the larger of i1 and i2.
+     */
+    public static int max(int i1, int i2) {
+        return i1 > i2 ? i1 : i2;
+    }
+
+    /**
+     * Answers the most positive (i.e. closest to positive infinity) of the two
+     * arguments.
+     * 
+     * @param l1
+     *            the first argument to check
+     * @param l2
+     *            the second argument
+     * @return the larger of l1 and l2.
+     */
+    public static long max(long l1, long l2) {
+        return l1 > l2 ? l1 : l2;
+    }
+
+    /**
+     * Answers the most negative (i.e. closest to negative infinity) of the two
+     * arguments.
+     * 
+     * @param d1
+     *            the first argument to check
+     * @param d2
+     *            the second argument
+     * @return the smaller of d1 and d2.
+     */
+    public static double min(double d1, double d2) {
+        if (d1 > d2)
+            return d2;
+        if (d1 < d2)
+            return d1;
+        /* if either arg is NaN, return NaN */
+        if (d1 != d2)
+            return Double.NaN;
+        /* min( +0.0,-0.0) == -0.0 */
+        if (d1 == 0.0
+                && ((Double.doubleToLongBits(d1) | Double.doubleToLongBits(d2)) & 0x8000000000000000l) != 0)
+            return 0.0 * (-1.0);
+        return d1;
+    }
+
+    /**
+     * Answers the most negative (i.e. closest to negative infinity) of the two
+     * arguments.
+     * 
+     * @param f1
+     *            the first argument to check
+     * @param f2
+     *            the second argument
+     * @return the smaller of f1 and f2.
+     */
+    public static float min(float f1, float f2) {
+        if (f1 > f2)
+            return f2;
+        if (f1 < f2)
+            return f1;
+        /* if either arg is NaN, return NaN */
+        if (f1 != f2)
+            return Float.NaN;
+        /* min( +0.0,-0.0) == -0.0 */
+        if (f1 == 0.0f
+                && ((Float.floatToIntBits(f1) | Float.floatToIntBits(f2)) & 0x80000000) != 0)
+            return 0.0f * (-1.0f);
+        return f1;
+    }
+
+    /**
+     * Answers the most negative (i.e. closest to negative infinity) of the two
+     * arguments.
+     * 
+     * @param i1
+     *            the first argument to check
+     * @param i2
+     *            the second argument
+     * @return the smaller of i1 and i2.
+     */
+    public static int min(int i1, int i2) {
+        return i1 < i2 ? i1 : i2;
+    }
+
+    /**
+     * Answers the most negative (i.e. closest to negative infinity) of the two
+     * arguments.
+     * 
+     * @param l1
+     *            the first argument to check
+     * @param l2
+     *            the second argument
+     * @return the smaller of l1 and l2.
+     */
+    public static long min(long l1, long l2) {
+        return l1 < l2 ? l1 : l2;
+    }
+
+    /**
+     * Answers the closest double approximation of the result of raising the
+     * first argument to the power of the second.
+     * 
+     * @param d1
+     *            the base of the operation.
+     * @param d2
+     *            the exponent of the operation.
+     * @return d1 to the power of d2
+     */
+    public static native double pow(double d1, double d2);
+
+    /**
+     * Answers the double conversion of the result of rounding the argument to
+     * an integer.
+     * 
+     * @param d
+     *            the value to be converted
+     * @return the closest integer to the argument (as a double).
+     */
+    public static native double rint(double d);
+
+    /**
+     * Answers the result of rounding the argument to an integer.
+     * 
+     * @param d
+     *            the value to be converted
+     * @return the closest integer to the argument.
+     */
+    public static long round(double d) {
+        // check for NaN
+        if (d != d)
+            return 0L;
+        return (long) floor(d + 0.5d);
+    }
+
+    /**
+     * Answers the result of rounding the argument to an integer.
+     * 
+     * @param f
+     *            the value to be converted
+     * @return the closest integer to the argument.
+     */
+    public static int round(float f) {
+        // check for NaN
+        if (f != f)
+            return 0;
+        return (int) floor(f + 0.5f);
+    }
+
     /**
      * Answers the signum function of the argument. If the argument is less than
      * zero, it answers -1.0. If greater than zero, 1.0 is returned. It returns
@@ -510,7 +514,7 @@
     public static double signum(double d) {
         return StrictMath.signum(d);
     }
-    
+
     /**
      * Answers the signum function of the argument. If the argument is less than
      * zero, it answers -1.0. If greater than zero, 1.0 is returned. It returns
@@ -524,15 +528,15 @@
         return StrictMath.signum(f);
     }
 
-	/**
-	 * Answers the closest double approximation of the sine of the argument
-	 * 
-	 * @param d
-	 *            the value to compute sin of
-	 * @return the sine of the argument.
-	 */
-	public static native double sin(double d);
-    
+    /**
+     * Answers the closest double approximation of the sine of the argument
+     * 
+     * @param d
+     *            the value to compute sin of
+     * @return the sine of the argument.
+     */
+    public static native double sin(double d);
+
     /**
      * Answers the closest double approximation of the hyperbolic sine of the
      * argument. The final result should be within 2.5ulps of the real result.
@@ -543,30 +547,30 @@
      */
     public static native double sinh(double d);
 
-	/**
-	 * Answers the closest double approximation of the square root of the
-	 * argument
-	 * 
-	 * @param d
-	 *            the value to compute sqrt of
-	 * @return the square root of the argument.
-	 */
-	public static native double sqrt(double d);
-
-	/**
-	 * Answers the closest double approximation of the tangent of the argument
-	 * 
-	 * @param d
-	 *            the value to compute tan of
-	 * @return the tangent of the argument.
-	 */
-	public static native double tan(double d);
-    
+    /**
+     * Answers the closest double approximation of the square root of the
+     * argument
+     * 
+     * @param d
+     *            the value to compute sqrt of
+     * @return the square root of the argument.
+     */
+    public static native double sqrt(double d);
+
+    /**
+     * Answers the closest double approximation of the tangent of the argument
+     * 
+     * @param d
+     *            the value to compute tan of
+     * @return the tangent of the argument.
+     */
+    public static native double tan(double d);
+
     /**
      * Answers the closest double approximation of the hyperbolic tangent of the
      * argument. The absolute value is always less than 1. The final result
-     * should be within 2.5ulps of the real result. If the real result is 
-     * within 0.5ulp of 1 or -1, it should answer exactly +1 or -1.
+     * should be within 2.5ulps of the real result. If the real result is within
+     * 0.5ulp of 1 or -1, it should answer exactly +1 or -1.
      * 
      * @param d
      *            the value to compute hyperbolic tangent of
@@ -574,44 +578,44 @@
      */
     public static native double tanh(double d);
 
-	/**
-	 * Returns a pseudo-random number between 0.0 and 1.0.
-	 * 
-	 * @return a pseudo-random number
-	 */
-	public static double random() {
-		if (random == null) {
-			random = new java.util.Random();
-		}
-		return random.nextDouble();
-	}
-
-	/**
-	 * Returns the measure in radians of the supplied degree angle
-	 * 
-	 * @param angdeg
-	 *            an angle in degrees
-	 * @return the radian measure of the angle.
-	 */
-	public static double toRadians(double angdeg) {
-		return angdeg / 180d * PI;
-	}
-
-	/**
-	 * Returns the measure in degrees of the supplied radian angle
-	 * 
-	 * @param angrad
-	 *            an angle in radians
-	 * @return the degree measure of the angle.
-	 */
-	public static double toDegrees(double angrad) {
-		return angrad * 180d / PI;
-	}
-	
-	/**
+    /**
+     * Returns a pseudo-random number between 0.0 and 1.0.
+     * 
+     * @return a pseudo-random number
+     */
+    public static double random() {
+        if (random == null) {
+            random = new java.util.Random();
+        }
+        return random.nextDouble();
+    }
+
+    /**
+     * Returns the measure in radians of the supplied degree angle
+     * 
+     * @param angdeg
+     *            an angle in degrees
+     * @return the radian measure of the angle.
+     */
+    public static double toRadians(double angdeg) {
+        return angdeg / 180d * PI;
+    }
+
+    /**
+     * Returns the measure in degrees of the supplied radian angle
+     * 
+     * @param angrad
+     *            an angle in radians
+     * @return the degree measure of the angle.
+     */
+    public static double toDegrees(double angrad) {
+        return angrad * 180d / PI;
+    }
+
+    /**
      * Answers the argument's ulp. The size of a ulp of a double value is the
-     * positive distance between this value and the double value next larger
-     * in magnitude. For non-NaN x, ulp(-x) == ulp(x).
+     * positive distance between this value and the double value next larger in
+     * magnitude. For non-NaN x, ulp(-x) == ulp(x).
      * 
      * @param d
      *            the floating-point value to compute ulp of
@@ -630,8 +634,8 @@
 
     /**
      * Answers the argument's ulp. The size of a ulp of a float value is the
-     * positive distance between this value and the float value next larger
-     * in magnitude. For non-NaN x, ulp(-x) == ulp(x).
+     * positive distance between this value and the float value next larger in
+     * magnitude. For non-NaN x, ulp(-x) == ulp(x).
      * 
      * @param f
      *            the floating-point value to compute ulp of
@@ -652,8 +656,8 @@
 
     private native static double nextafter(double x, double y);
 
-    private native static float nextafterf(float x, float y); 
-    
+    private native static float nextafterf(float x, float y);
+
     /**
      * Answers a result of the magnitude of the first given double value and the
      * sign of the second given double value.
@@ -693,7 +697,7 @@
         return Float.intBitsToFloat((mbits & ~FLOAT_SIGN_MASK)
                 | (sbits & FLOAT_SIGN_MASK));
     }
-    
+
     /**
      * Answers the exponent of a float.
      * 
@@ -722,8 +726,8 @@
         long bits = Double.doubleToRawLongBits(d);
         bits = (bits & DOUBLE_EXPONENT_MASK) >> DOUBLE_MANTISSA_BITS;
         return (int) bits - DOUBLE_EXPONENT_BIAS;
-    }    
-    
+    }
+
     /**
      * Answers a double next to the first given double value in the direction of
      * the second given double.
@@ -762,7 +766,7 @@
         if (Float.isNaN(start) || Double.isNaN(direction)) {
             return Float.NaN;
         }
-        if (0 == start && 0 == direction) {       	
+        if (0 == start && 0 == direction) {
             return new Float(direction);
         }
         if ((start == Float.MIN_VALUE && direction < start)
@@ -797,7 +801,7 @@
         }
         return new Float(direction);
     }
-    
+
     /**
      * Answers the next larger double value to d.
      * 
@@ -847,7 +851,7 @@
             return Float.intBitsToFloat(Float.floatToIntBits(f) - 1);
         }
     }
-    
+
     /**
      * Answers a double value of d * 2^scaleFactor, the result may be rounded.
      * 

Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/util/Collections.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/util/Collections.java?rev=586341&r1=586340&r2=586341&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/util/Collections.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/util/Collections.java Fri Oct 19 02:03:23 2007
@@ -1840,7 +1840,7 @@
         if (!(list instanceof RandomAccess)) {
             Object[] array = list.toArray();
             for (int i = array.length - 1; i > 0; i--) {
-                int index = random.nextInt() % (i + 1);
+                int index = random.nextInt(i + 1);
                 if (index < 0) {
                     index = -index;
                 }
@@ -1859,7 +1859,7 @@
         } else {
             List<Object> rawList = (List<Object>) list;
             for (int i = rawList.size() - 1; i > 0; i--) {
-                int index = random.nextInt() % (i + 1);
+                int index = random.nextInt(i + 1);
                 if (index < 0) {
                     index = -index;
                 }

Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/util/EnumMap.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/util/EnumMap.java?rev=586341&r1=586340&r2=586341&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/util/EnumMap.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/util/EnumMap.java Fri Oct 19 02:03:23 2007
@@ -23,8 +23,7 @@
 import java.lang.reflect.Array;
 
 public class EnumMap<K extends Enum<K>, V> extends AbstractMap<K, V> implements
-        Serializable, Cloneable {
-
+        Map<K, V>, Serializable, Cloneable {
     private static final long serialVersionUID = 458661240069192865L;
 
     private Class<K> keyType;
@@ -41,13 +40,13 @@
 
     private transient EnumMapEntrySet<K, V> entrySet = null;
 
-    private static class Entry<KT extends Enum<KT>, VT> extends
-            MapEntry<KT, VT> {
-        private final EnumMap<KT, VT> enumMap;
+    static class EnumMapEntry<K extends Enum<K>, V> extends
+            MapEntry<K, V> {
+        private final EnumMap<K, V> enumMap;
 
         private final int ordinal;
 
-        Entry(KT theKey, VT theValue, EnumMap<KT, VT> em) {
+        EnumMapEntry(K theKey, V theValue, EnumMap<K, V> em) {
             super(theKey, theValue);
             enumMap = em;
             ordinal = ((Enum) theKey).ordinal();
@@ -61,7 +60,7 @@
             }
             boolean isEqual = false;
             if (object instanceof Map.Entry) {
-                Map.Entry<KT, VT> entry = (Map.Entry<KT, VT>) object;
+                Map.Entry<K, V> entry = (Map.Entry<K, V>) object;
                 Object enumKey = entry.getKey();
                 if (key.equals(enumKey)) {
                     Object theValue = entry.getValue();
@@ -82,23 +81,23 @@
 
         @SuppressWarnings("unchecked")
         @Override
-        public KT getKey() {
+        public K getKey() {
             checkEntryStatus();
-            return (KT) enumMap.keys[ordinal];
+            return (K) enumMap.keys[ordinal];
         }
 
         @SuppressWarnings("unchecked")
         @Override
-        public VT getValue() {
+        public V getValue() {
             checkEntryStatus();
-            return (VT) enumMap.values[ordinal];
+            return (V) enumMap.values[ordinal];
         }
 
         @SuppressWarnings("unchecked")
         @Override
-        public VT setValue(VT value) {
+        public V setValue(V value) {
             checkEntryStatus();
-            return enumMap.put((KT) enumMap.keys[ordinal], value);
+            return enumMap.put((K) enumMap.keys[ordinal], value);
         }
 
         @Override
@@ -117,17 +116,17 @@
         }
     }
 
-    private static class EnumMapIterator<E, KT extends Enum<KT>, VT> implements
+    private static class EnumMapIterator<E, K extends Enum<K>, V> implements
             Iterator<E> {
         int position = 0;
 
         int prePosition = -1;
 
-        final EnumMap<KT, VT> enumMap;
+        final EnumMap<K, V> enumMap;
 
-        final MapEntry.Type<E, KT, VT> type;
+        final MapEntry.Type<E, K, V> type;
 
-        EnumMapIterator(MapEntry.Type<E, KT, VT> value, EnumMap<KT, VT> em) {
+        EnumMapIterator(MapEntry.Type<E, K, V> value, EnumMap<K, V> em) {
             enumMap = em;
             type = value;
         }
@@ -178,11 +177,11 @@
         }
     }
 
-    private static class EnumMapKeySet<KT extends Enum<KT>, VT> extends
-            AbstractSet<KT> {
-        private final EnumMap<KT, VT> enumMap;
+    private static class EnumMapKeySet<K extends Enum<K>, V> extends
+            AbstractSet<K> {
+        private final EnumMap<K, V> enumMap;
 
-        EnumMapKeySet(EnumMap<KT, VT> em) {
+        EnumMapKeySet(EnumMap<K, V> em) {
             enumMap = em;
         }
 
@@ -199,9 +198,9 @@
         @Override
         @SuppressWarnings("unchecked")
         public Iterator iterator() {
-            return new EnumMapIterator<KT, KT, VT>(
-                    new MapEntry.Type<KT, KT, VT>() {
-                        public KT get(MapEntry<KT, VT> entry) {
+            return new EnumMapIterator<K, K, V>(
+                    new MapEntry.Type<K, K, V>() {
+                        public K get(MapEntry<K, V> entry) {
                             return entry.key;
                         }
                     }, enumMap);
@@ -223,11 +222,11 @@
         }
     }
 
-    private static class EnumMapValueCollection<KT extends Enum<KT>, VT>
-            extends AbstractCollection<VT> {
-        private final EnumMap<KT, VT> enumMap;
+    private static class EnumMapValueCollection<K extends Enum<K>, V>
+            extends AbstractCollection<V> {
+        private final EnumMap<K, V> enumMap;
 
-        EnumMapValueCollection(EnumMap<KT, VT> em) {
+        EnumMapValueCollection(EnumMap<K, V> em) {
             enumMap = em;
         }
 
@@ -244,9 +243,9 @@
         @SuppressWarnings("unchecked")
         @Override
         public Iterator iterator() {
-            return new EnumMapIterator<VT, KT, VT>(
-                    new MapEntry.Type<VT, KT, VT>() {
-                        public VT get(MapEntry<KT, VT> entry) {
+            return new EnumMapIterator<V, K, V>(
+                    new MapEntry.Type<V, K, V>() {
+                        public V get(MapEntry<K, V> entry) {
                             return entry.value;
                         }
                     }, enumMap);
@@ -279,9 +278,9 @@
         }
     }
 
-    private static class EnumMapEntryIterator<E, KT extends Enum<KT>, VT>
-            extends EnumMapIterator<E, KT, VT> {
-        EnumMapEntryIterator(MapEntry.Type<E, KT, VT> value, EnumMap<KT, VT> em) {
+    private static class EnumMapEntryIterator<E, K extends Enum<K>, V>
+            extends EnumMapIterator<E, K, V> {
+        EnumMapEntryIterator(MapEntry.Type<E, K, V> value, EnumMap<K, V> em) {
             super(value, em);
         }
 
@@ -292,16 +291,16 @@
                 throw new NoSuchElementException();
             }
             prePosition = position++;
-            return type.get(new Entry<KT, VT>((KT) enumMap.keys[prePosition],
-                    (VT) enumMap.values[prePosition], enumMap));
+            return type.get(new EnumMapEntry<K, V>((K) enumMap.keys[prePosition],
+                    (V) enumMap.values[prePosition], enumMap));
         }
     }
 
-    private static class EnumMapEntrySet<KT extends Enum<KT>, VT> extends
-            AbstractSet<Map.Entry<KT, VT>> {
-        private final EnumMap<KT, VT> enumMap;
+    private static class EnumMapEntrySet<K extends Enum<K>, V> extends
+            AbstractSet<Map.Entry<K, V>> {
+        private final EnumMap<K, V> enumMap;
 
-        EnumMapEntrySet(EnumMap<KT, VT> em) {
+        EnumMapEntrySet(EnumMap<K, V> em) {
             enumMap = em;
         }
 
@@ -317,7 +316,7 @@
                 Object enumKey = ((Map.Entry) object).getKey();
                 Object enumValue = ((Map.Entry) object).getValue();
                 if (enumMap.containsKey(enumKey)) {
-                    VT value = enumMap.get(enumKey);
+                    V value = enumMap.get(enumKey);
                     isEqual = (value == null ? null == enumValue : value
                             .equals(enumValue));
                 }
@@ -326,10 +325,10 @@
         }
 
         @Override
-        public Iterator<Map.Entry<KT, VT>> iterator() {
-            return new EnumMapEntryIterator<Map.Entry<KT, VT>, KT, VT>(
-                    new MapEntry.Type<Map.Entry<KT, VT>, KT, VT>() {
-                        public Map.Entry<KT, VT> get(MapEntry<KT, VT> entry) {
+        public Iterator<Map.Entry<K, V>> iterator() {
+            return new EnumMapEntryIterator<Map.Entry<K, V>, K, V>(
+                    new MapEntry.Type<Map.Entry<K, V>, K, V>() {
+                        public Map.Entry<K, V> get(MapEntry<K, V> entry) {
                             return entry;
                         }
                     }, enumMap);
@@ -365,10 +364,10 @@
                 Class<?> clazz = array.getClass().getComponentType();
                 entryArray = (Object[]) Array.newInstance(clazz, size);
             }
-            Iterator<Map.Entry<KT, VT>> iter = iterator();
+            Iterator<Map.Entry<K, V>> iter = iterator();
             for (; index < size; index++) {
-                Map.Entry<KT, VT> entry = iter.next();
-                entryArray[index] = new MapEntry<KT, VT>(entry.getKey(), entry
+                Map.Entry<K, V> entry = iter.next();
+                entryArray[index] = new MapEntry<K, V>(entry.getKey(), entry
                         .getValue());
             }
             if (index < array.length) {

Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/util/GregorianCalendar.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/util/GregorianCalendar.java?rev=586341&r1=586340&r2=586341&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/util/GregorianCalendar.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/util/GregorianCalendar.java Fri Oct 19 02:03:23 2007
@@ -1153,10 +1153,10 @@
                 } else {
                     set(field, newWeek - 1);
                 }
-            } else if (newWeek == 1) {
-                int week = (fields[day] - ((fields[day] - 1) / 7 * 7) - 1 + mod) / 7 + 1;
-                if (week > 1) {
-                    set(field, 1);
+                } else if (newWeek == 1) {
+                    int week = (fields[day] - ((fields[day] - 1) / 7 * 7) - 1 + mod) / 7 + 1;
+                    if (week > 1) {
+                        set(field, 1);
                 } else {
                     set(field, newWeek);
                 }

Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/util/LinkedList.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/util/LinkedList.java?rev=586341&r1=586340&r2=586341&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/util/LinkedList.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/util/LinkedList.java Fri Oct 19 02:03:23 2007
@@ -17,7 +17,6 @@
 
 package java.util;
 
-
 import java.io.IOException;
 import java.io.ObjectInputStream;
 import java.io.ObjectOutputStream;
@@ -28,306 +27,308 @@
  * LinkedList is an implementation of List, backed by a linked list. All
  * optional operations are supported, adding, removing and replacing. The
  * elements can be any objects.
+ * 
  * @since 1.2
  */
 public class LinkedList<E> extends AbstractSequentialList<E> implements
-		List<E>, Deque<E>, Cloneable, Serializable {
+        List<E>, Deque<E>, Cloneable, Serializable {
 
-	
-	private static final long serialVersionUID = 876323262645176354L;
+    private static final long serialVersionUID = 876323262645176354L;
 
-	transient int size = 0;
+    transient int size = 0;
 
-	transient Link<E> voidLink;
+    transient Link<E> voidLink;
 
-	private static final class Link<ET> {
-		ET data;
+    private static final class Link<ET> {
+        ET data;
 
-		Link<ET> previous, next;
+        Link<ET> previous, next;
 
-		Link(ET o, Link<ET> p, Link<ET> n) {
-			data = o;
-			previous = p;
-			next = n;
-		}
-	}
+        Link(ET o, Link<ET> p, Link<ET> n) {
+            data = o;
+            previous = p;
+            next = n;
+        }
+    }
 
-	private static final class LinkIterator<ET> implements ListIterator<ET> {
-		int pos, expectedModCount;
+    private static final class LinkIterator<ET> implements ListIterator<ET> {
+        int pos, expectedModCount;
 
-		final LinkedList<ET> list;
+        final LinkedList<ET> list;
 
-		Link<ET> link, lastLink;
+        Link<ET> link, lastLink;
 
-		LinkIterator(LinkedList<ET> object, int location) {
-			list = object;
-			expectedModCount = list.modCount;
-			if (0 <= location && location <= list.size) {
-				// pos ends up as -1 if list is empty, it ranges from -1 to
-				// list.size - 1
-				// if link == voidLink then pos must == -1
-				link = list.voidLink;
-				if (location < list.size / 2) {
-					for (pos = -1; pos + 1 < location; pos++) {
+        LinkIterator(LinkedList<ET> object, int location) {
+            list = object;
+            expectedModCount = list.modCount;
+            if (0 <= location && location <= list.size) {
+                // pos ends up as -1 if list is empty, it ranges from -1 to
+                // list.size - 1
+                // if link == voidLink then pos must == -1
+                link = list.voidLink;
+                if (location < list.size / 2) {
+                    for (pos = -1; pos + 1 < location; pos++) {
                         link = link.next;
                     }
-				} else {
-					for (pos = list.size; pos >= location; pos--) {
+                } else {
+                    for (pos = list.size; pos >= location; pos--) {
                         link = link.previous;
                     }
-				}
-			} else {
+                }
+            } else {
                 throw new IndexOutOfBoundsException();
             }
-		}
+        }
 
-		public void add(ET object) {
-			if (expectedModCount == list.modCount) {
-				Link<ET> next = link.next;
-				Link<ET> newLink = new Link<ET>(object, link, next);
-				link.next = newLink;
-				next.previous = newLink;
-				link = newLink;
-				lastLink = null;
-				pos++;
-				expectedModCount++;
-				list.size++;
-				list.modCount++;
-			} else {
+        public void add(ET object) {
+            if (expectedModCount == list.modCount) {
+                Link<ET> next = link.next;
+                Link<ET> newLink = new Link<ET>(object, link, next);
+                link.next = newLink;
+                next.previous = newLink;
+                link = newLink;
+                lastLink = null;
+                pos++;
+                expectedModCount++;
+                list.size++;
+                list.modCount++;
+            } else {
                 throw new ConcurrentModificationException();
             }
-		}
+        }
+
+        public boolean hasNext() {
+            return link.next != list.voidLink;
+        }
 
-		public boolean hasNext() {
-			return link.next != list.voidLink;
-		}
-
-		public boolean hasPrevious() {
-			return link != list.voidLink;
-		}
-
-		public ET next() {
-			if (expectedModCount == list.modCount) {
-				LinkedList.Link<ET> next = link.next;
-				if (next != list.voidLink) {
-					lastLink = link = next;
-					pos++;
-					return link.data;
-				}
+        public boolean hasPrevious() {
+            return link != list.voidLink;
+        }
+
+        public ET next() {
+            if (expectedModCount == list.modCount) {
+                LinkedList.Link<ET> next = link.next;
+                if (next != list.voidLink) {
+                    lastLink = link = next;
+                    pos++;
+                    return link.data;
+                }
                 throw new NoSuchElementException();
-			}
+            }
             throw new ConcurrentModificationException();
-		}
+        }
+
+        public int nextIndex() {
+            return pos + 1;
+        }
 
-		public int nextIndex() {
-			return pos + 1;
-		}
-
-		public ET previous() {
-			if (expectedModCount == list.modCount) {
-				if (link != list.voidLink) {
-					lastLink = link;
-					link = link.previous;
-					pos--;
-					return lastLink.data;
-				}
+        public ET previous() {
+            if (expectedModCount == list.modCount) {
+                if (link != list.voidLink) {
+                    lastLink = link;
+                    link = link.previous;
+                    pos--;
+                    return lastLink.data;
+                }
                 throw new NoSuchElementException();
-			}
+            }
             throw new ConcurrentModificationException();
-		}
+        }
+
+        public int previousIndex() {
+            return pos;
+        }
 
-		public int previousIndex() {
-			return pos;
-		}
-
-		public void remove() {
-			if (expectedModCount == list.modCount) {
-				if (lastLink != null) {
-					Link<ET> next = lastLink.next;
-					Link<ET> previous = lastLink.previous;
-					next.previous = previous;
-					previous.next = next;
-					if (lastLink == link) {
-						pos--;
-					}
-					link = previous;
-					lastLink = null;
-					expectedModCount++;
-					list.size--;
-					list.modCount++;
-					return;
-				}
-				throw new IllegalStateException();
-			}
-			throw new ConcurrentModificationException();
-		}
-
-		public void set(ET object) {
-			if (expectedModCount == list.modCount) {
-				if (lastLink != null) {
+        public void remove() {
+            if (expectedModCount == list.modCount) {
+                if (lastLink != null) {
+                    Link<ET> next = lastLink.next;
+                    Link<ET> previous = lastLink.previous;
+                    next.previous = previous;
+                    previous.next = next;
+                    if (lastLink == link) {
+                        pos--;
+                    }
+                    link = previous;
+                    lastLink = null;
+                    expectedModCount++;
+                    list.size--;
+                    list.modCount++;
+                    return;
+                }
+                throw new IllegalStateException();
+            }
+            throw new ConcurrentModificationException();
+        }
+
+        public void set(ET object) {
+            if (expectedModCount == list.modCount) {
+                if (lastLink != null) {
                     lastLink.data = object;
                 } else {
                     throw new IllegalStateException();
                 }
-			} else {
+            } else {
                 throw new ConcurrentModificationException();
             }
-		}
-	}
+        }
+    }
+
+    /*
+     * NOTES:descendingIterator is not fail-fast, according to the documentation
+     * and test case.
+     */
+    private class ReverseLinkIterator<ET> implements Iterator<ET> {
+        private int expectedModCount;
+
+        private final LinkedList<ET> list;
+
+        private Link<ET> link;
+
+        private boolean canRemove;
+
+        ReverseLinkIterator(LinkedList<ET> linkedList) {
+            super();
+            list = linkedList;
+            expectedModCount = list.modCount;
+            link = list.voidLink;
+            canRemove = false;
+        }
+
+        public boolean hasNext() {
+            return link.previous != list.voidLink;
+        }
+
+        public ET next() {
+            if (expectedModCount == list.modCount) {
+                if (hasNext()) {
+                    link = link.previous;
+                    canRemove = true;
+                    return link.data;
+                }
+                throw new NoSuchElementException();
+            }
+            throw new ConcurrentModificationException();
+
+        }
+
+        public void remove() {
+            if (expectedModCount == list.modCount) {
+                if (canRemove) {
+                    Link<ET> next = link.previous;
+                    Link<ET> previous = link.next;
+                    next.next = previous;
+                    previous.previous = next;
+                    link = previous;
+                    list.size--;
+                    list.modCount++;
+                    expectedModCount++;
+                    canRemove = false;
+                    return;
+                }
+                throw new IllegalStateException();
+            }
+            throw new ConcurrentModificationException();
+        }
+    }
 
-	/*
-	 * NOTES:descendingIterator is not fail-fast, according to the documentation
-	 * and test case.
-	 */
-	private class ReverseLinkIterator<ET> implements Iterator<ET> {
-		private int expectedModCount;
-
-		private final LinkedList<ET> list;
-
-		private Link<ET> link;
-
-		private boolean canRemove;
-
-		ReverseLinkIterator(LinkedList<ET> linkedList) {
-			super();
-			list = linkedList;
-			expectedModCount = list.modCount;
-			link = list.voidLink;
-			canRemove = false;
-		}
-
-		public boolean hasNext() {
-			return link.previous != list.voidLink;
-		}
-
-		public ET next() {
-			if (expectedModCount == list.modCount) {
-				if (hasNext()) {
-					link = link.previous;
-					canRemove = true;
-					return link.data;
-				}
-				throw new NoSuchElementException();
-			}
-			throw new ConcurrentModificationException();
-
-		}
-
-		public void remove() {
-			if (expectedModCount == list.modCount) {
-				if (canRemove) {
-					Link<ET> next = link.previous;
-					Link<ET> previous = link.next;
-					next.next = previous;
-					previous.previous = next;
-					link = previous;
-					list.size--;
-					list.modCount++;
-					expectedModCount++;
-					canRemove = false;
-					return;
-				}
-				throw new IllegalStateException();
-			}
-			throw new ConcurrentModificationException();
-		}
-	}
-
-	/**
-	 * Constructs a new empty instance of LinkedList.
-	 * 
-	 */
-	public LinkedList() {
-		voidLink = new Link<E>(null, null, null);
-		voidLink.previous = voidLink;
-		voidLink.next = voidLink;
-	}
-
-	/**
-	 * Constructs a new instance of <code>LinkedList</code> that holds 
-	 * all of the elements contained in the supplied <code>collection</code>
-	 * argument. The order of the elements in this new <code>LinkedList</code> 
-	 * will be determined by the iteration order of <code>collection</code>. 
-	 * 
-	 * @param collection
-	 *            the collection of elements to add
-	 */
-	public LinkedList(Collection<? extends E> collection) {
-		this();
-		addAll(collection);
-	}
-
-	/**
-	 * Inserts the specified object into this LinkedList at the specified
-	 * location. The object is inserted before any previous element at the
-	 * specified location. If the location is equal to the size of this
-	 * LinkedList, the object is added at the end.
-	 * 
-	 * @param location
-	 *            the index at which to insert
-	 * @param object
-	 *            the object to add
-	 * 
-	 * @exception IndexOutOfBoundsException
-	 *                when <code>location < 0 || >= size()</code>
-	 */
-	@Override
+    /**
+     * Constructs a new empty instance of LinkedList.
+     * 
+     */
+    public LinkedList() {
+        voidLink = new Link<E>(null, null, null);
+        voidLink.previous = voidLink;
+        voidLink.next = voidLink;
+    }
+
+    /**
+     * Constructs a new instance of <code>LinkedList</code> that holds all of
+     * the elements contained in the supplied <code>collection</code>
+     * argument. The order of the elements in this new <code>LinkedList</code>
+     * will be determined by the iteration order of <code>collection</code>.
+     * 
+     * @param collection
+     *            the collection of elements to add
+     */
+    public LinkedList(Collection<? extends E> collection) {
+        this();
+        addAll(collection);
+    }
+
+    /**
+     * Inserts the specified object into this LinkedList at the specified
+     * location. The object is inserted before any previous element at the
+     * specified location. If the location is equal to the size of this
+     * LinkedList, the object is added at the end.
+     * 
+     * @param location
+     *            the index at which to insert
+     * @param object
+     *            the object to add
+     * 
+     * @exception IndexOutOfBoundsException
+     *                when <code>location < 0 || >= size()</code>
+     */
+    @Override
     public void add(int location, E object) {
-		if (0 <= location && location <= size) {
-			Link<E> link = voidLink;
-			if (location < (size / 2)) {
-				for (int i = 0; i <= location; i++) {
+        if (0 <= location && location <= size) {
+            Link<E> link = voidLink;
+            if (location < (size / 2)) {
+                for (int i = 0; i <= location; i++) {
                     link = link.next;
                 }
-			} else {
-				for (int i = size; i > location; i--) {
+            } else {
+                for (int i = size; i > location; i--) {
                     link = link.previous;
                 }
-			}
-			Link<E> previous = link.previous;
-			Link<E> newLink = new Link<E>(object, previous, link);
-			previous.next = newLink;
-			link.previous = newLink;
-			size++;
-			modCount++;
-		} else {
+            }
+            Link<E> previous = link.previous;
+            Link<E> newLink = new Link<E>(object, previous, link);
+            previous.next = newLink;
+            link.previous = newLink;
+            size++;
+            modCount++;
+        } else {
             throw new IndexOutOfBoundsException();
         }
-	}
+    }
 
-	/**
-	 * Adds the specified object at the end of this LinkedList.
-	 * 
-	 * @param object
-	 *            the object to add
-	 * @return true
-	 */
-	@Override
+    /**
+     * Adds the specified object at the end of this LinkedList.
+     * 
+     * @param object
+     *            the object to add
+     * @return true
+     */
+    @Override
     public boolean add(E object) {
-		return addLastImpl(object);
-	}
+        return addLastImpl(object);
+    }
 
-	private boolean addLastImpl(E object) {
-		Link<E> oldLast = voidLink.previous;
-		Link<E> newLink = new Link<E>(object, oldLast, voidLink);
-		voidLink.previous = newLink;
-		oldLast.next = newLink;
-		size++;
-		modCount++;
-		return true;
-	}
+    private boolean addLastImpl(E object) {
+        Link<E> oldLast = voidLink.previous;
+        Link<E> newLink = new Link<E>(object, oldLast, voidLink);
+        voidLink.previous = newLink;
+        oldLast.next = newLink;
+        size++;
+        modCount++;
+        return true;
+    }
 
-	/**
+    /**
      * Inserts the objects in the specified Collection at the specified location
      * in this LinkedList. The objects are added in the order they are returned
      * from the <code>Collection</code> iterator.
      * 
-     * @param location the index at which to insert
-     * @param collection the Collection of objects
+     * @param location
+     *            the index at which to insert
+     * @param collection
+     *            the Collection of objects
      * @return true if this LinkedList is modified, false otherwise
      * 
-     * @exception IndexOutOfBoundsException when
-     *            <code>location < 0 || > size()</code>
+     * @exception IndexOutOfBoundsException
+     *                when <code>location < 0 || > size()</code>
      */
     @Override
     public boolean addAll(int location, Collection<? extends E> collection) {
@@ -361,88 +362,87 @@
         return true;
     }
 
-
-	/**
-	 * Adds the objects in the specified Collection to this LinkedList.
-	 * 
-	 * @param collection
-	 *            the Collection of objects
-	 * @return true if this LinkedList is modified, false otherwise
-	 */
-	@Override
+    /**
+     * Adds the objects in the specified Collection to this LinkedList.
+     * 
+     * @param collection
+     *            the Collection of objects
+     * @return true if this LinkedList is modified, false otherwise
+     */
+    @Override
     public boolean addAll(Collection<? extends E> collection) {
-		int adding = collection.size();
-		if (adding == 0) {
+        int adding = collection.size();
+        if (adding == 0) {
             return false;
         }
-		Link<E> previous = voidLink.previous;
+        Link<E> previous = voidLink.previous;
         for (E e : collection) {
-			Link<E> newLink = new Link<E>(e, previous, null);
-			previous.next = newLink;
-			previous = newLink;
-		}
-		previous.next = voidLink;
-		voidLink.previous = previous;
-		size += adding;
-		modCount++;
-		return true;
-	}
-
-	/**
-	 * Adds the specified object at the beginning of this LinkedList.
-	 * 
-	 * @param object
-	 *            the object to add
-	 */
-	public void addFirst(E object) {
-		addFirstImpl(object);
-	}
-
-	private boolean addFirstImpl(E object) {
-		Link<E> oldFirst = voidLink.next;
-		Link<E> newLink = new Link<E>(object, voidLink, oldFirst);
-		voidLink.next = newLink;
-		oldFirst.previous = newLink;
-		size++;
-		modCount++;
-		return true;
-	}
-
-	/**
-	 * Adds the specified object at the end of this LinkedList.
-	 * 
-	 * @param object
-	 *            the object to add
-	 */
-	public void addLast(E object) {
-		addLastImpl(object);
-	}
-
-	/**
-	 * Removes all elements from this LinkedList, leaving it empty.
-	 * 
-	 * @see List#isEmpty
-	 * @see #size
-	 */
-	@Override
+            Link<E> newLink = new Link<E>(e, previous, null);
+            previous.next = newLink;
+            previous = newLink;
+        }
+        previous.next = voidLink;
+        voidLink.previous = previous;
+        size += adding;
+        modCount++;
+        return true;
+    }
+
+    /**
+     * Adds the specified object at the beginning of this LinkedList.
+     * 
+     * @param object
+     *            the object to add
+     */
+    public void addFirst(E object) {
+        addFirstImpl(object);
+    }
+
+    private boolean addFirstImpl(E object) {
+        Link<E> oldFirst = voidLink.next;
+        Link<E> newLink = new Link<E>(object, voidLink, oldFirst);
+        voidLink.next = newLink;
+        oldFirst.previous = newLink;
+        size++;
+        modCount++;
+        return true;
+    }
+
+    /**
+     * Adds the specified object at the end of this LinkedList.
+     * 
+     * @param object
+     *            the object to add
+     */
+    public void addLast(E object) {
+        addLastImpl(object);
+    }
+
+    /**
+     * Removes all elements from this LinkedList, leaving it empty.
+     * 
+     * @see List#isEmpty
+     * @see #size
+     */
+    @Override
     public void clear() {
-		if (size > 0) {
-			size = 0;
-			voidLink.next = voidLink;
-			voidLink.previous = voidLink;
-			modCount++;
-		}
-	}
-
-	/**
-	 * Answers a new LinkedList with the same elements and size as this
-	 * LinkedList.
-	 * 
-	 * @return a shallow copy of this LinkedList
-	 * 
-	 * @see java.lang.Cloneable
-	 */
-	@SuppressWarnings("unchecked")
+        if (size > 0) {
+            size = 0;
+            voidLink.next = voidLink;
+            voidLink.previous = voidLink;
+            modCount++;
+        }
+    }
+
+    /**
+     * Answers a new LinkedList with the same elements and size as this
+     * LinkedList.
+     * 
+     * @return a shallow copy of this LinkedList
+     * 
+     * @see java.lang.Cloneable
+     */
+    @SuppressWarnings("unchecked")
     @Override
     public Object clone() {
         try {
@@ -456,532 +456,532 @@
         } catch (CloneNotSupportedException e) {
             return null;
         }
-	}
+    }
 
-	/**
-	 * Searches this LinkedList for the specified object.
-	 * 
-	 * @param object
-	 *            the object to search for
-	 * @return true if <code>object</code> is an element of this LinkedList,
-	 *         false otherwise
-	 */
-	@Override
+    /**
+     * Searches this LinkedList for the specified object.
+     * 
+     * @param object
+     *            the object to search for
+     * @return true if <code>object</code> is an element of this LinkedList,
+     *         false otherwise
+     */
+    @Override
     public boolean contains(Object object) {
-		Link<E> link = voidLink.next;
-		if (object != null) {
-			while (link != voidLink) {
-				if (object.equals(link.data)) {
+        Link<E> link = voidLink.next;
+        if (object != null) {
+            while (link != voidLink) {
+                if (object.equals(link.data)) {
                     return true;
                 }
-				link = link.next;
-			}
-		} else {
-			while (link != voidLink) {
-				if (link.data == null) {
+                link = link.next;
+            }
+        } else {
+            while (link != voidLink) {
+                if (link.data == null) {
                     return true;
                 }
-				link = link.next;
-			}
-		}
-		return false;
-	}
+                link = link.next;
+            }
+        }
+        return false;
+    }
 
-	@Override
+    @Override
     public E get(int location) {
-		if (0 <= location && location < size) {
-			Link<E> link = voidLink;
-			if (location < (size / 2)) {
-				for (int i = 0; i <= location; i++) {
+        if (0 <= location && location < size) {
+            Link<E> link = voidLink;
+            if (location < (size / 2)) {
+                for (int i = 0; i <= location; i++) {
                     link = link.next;
                 }
-			} else {
-				for (int i = size; i > location; i--) {
+            } else {
+                for (int i = size; i > location; i--) {
                     link = link.previous;
                 }
-			}
-			return link.data;
-		}
+            }
+            return link.data;
+        }
         throw new IndexOutOfBoundsException();
-	}
+    }
 
-	/**
-	 * Answers the first element in this LinkedList.
-	 * 
-	 * @return the first element
-	 * 
-	 * @exception NoSuchElementException
-	 *                when this LinkedList is empty
-	 */
-	public E getFirst() {
-		return getFirstImpl();
-	}
-
-	private E getFirstImpl() {
-		Link<E> first = voidLink.next;
-		if (first != voidLink) {
+    /**
+     * Answers the first element in this LinkedList.
+     * 
+     * @return the first element
+     * 
+     * @exception NoSuchElementException
+     *                when this LinkedList is empty
+     */
+    public E getFirst() {
+        return getFirstImpl();
+    }
+
+    private E getFirstImpl() {
+        Link<E> first = voidLink.next;
+        if (first != voidLink) {
             return first.data;
         }
-		throw new NoSuchElementException();
-	}
+        throw new NoSuchElementException();
+    }
 
-	/**
-	 * Answers the last element in this LinkedList.
-	 * 
-	 * @return the last element
-	 * 
-	 * @exception NoSuchElementException
-	 *                when this LinkedList is empty
-	 */
-	public E getLast() {
-		Link<E> last = voidLink.previous;
-		if (last != voidLink) {
+    /**
+     * Answers the last element in this LinkedList.
+     * 
+     * @return the last element
+     * 
+     * @exception NoSuchElementException
+     *                when this LinkedList is empty
+     */
+    public E getLast() {
+        Link<E> last = voidLink.previous;
+        if (last != voidLink) {
             return last.data;
         }
-		throw new NoSuchElementException();
-	}
+        throw new NoSuchElementException();
+    }
 
-	/**
-	 * Searches this LinkedList for the specified object and returns the index
-	 * of the first occurrence.
-	 * 
-	 * @param object
-	 *            the object to search for
-	 * @return the index of the first occurrence of the object
-	 */
-	@Override
+    /**
+     * Searches this LinkedList for the specified object and returns the index
+     * of the first occurrence.
+     * 
+     * @param object
+     *            the object to search for
+     * @return the index of the first occurrence of the object
+     */
+    @Override
     public int indexOf(Object object) {
-		int pos = 0;
-		Link<E> link = voidLink.next;
-		if (object != null) {
-			while (link != voidLink) {
-				if (object.equals(link.data)) {
+        int pos = 0;
+        Link<E> link = voidLink.next;
+        if (object != null) {
+            while (link != voidLink) {
+                if (object.equals(link.data)) {
                     return pos;
                 }
-				link = link.next;
-				pos++;
-			}
-		} else {
-			while (link != voidLink) {
-				if (link.data == null) {
+                link = link.next;
+                pos++;
+            }
+        } else {
+            while (link != voidLink) {
+                if (link.data == null) {
                     return pos;
                 }
-				link = link.next;
-				pos++;
-			}
-		}
-		return -1;
-	}
-
-	/**
-	 * Searches this LinkedList for the specified object and returns the index
-	 * of the last occurrence.
-	 * 
-	 * @param object
-	 *            the object to search for
-	 * @return the index of the last occurrence of the object
-	 */
-	@Override
+                link = link.next;
+                pos++;
+            }
+        }
+        return -1;
+    }
+
+    /**
+     * Searches this LinkedList for the specified object and returns the index
+     * of the last occurrence.
+     * 
+     * @param object
+     *            the object to search for
+     * @return the index of the last occurrence of the object
+     */
+    @Override
     public int lastIndexOf(Object object) {
-		int pos = size;
-		Link<E> link = voidLink.previous;
-		if (object != null) {
-			while (link != voidLink) {
-				pos--;
-				if (object.equals(link.data)) {
+        int pos = size;
+        Link<E> link = voidLink.previous;
+        if (object != null) {
+            while (link != voidLink) {
+                pos--;
+                if (object.equals(link.data)) {
                     return pos;
                 }
-				link = link.previous;
-			}
-		} else {
-			while (link != voidLink) {
-				pos--;
-				if (link.data == null) {
+                link = link.previous;
+            }
+        } else {
+            while (link != voidLink) {
+                pos--;
+                if (link.data == null) {
                     return pos;
                 }
-				link = link.previous;
-			}
-		}
-		return -1;
-	}
-
-	/**
-	 * Answers a ListIterator on the elements of this LinkedList. The elements
-	 * are iterated in the same order that they occur in the LinkedList. The
-	 * iteration starts at the specified location.
-	 * 
-	 * @param location
-	 *            the index at which to start the iteration
-	 * @return a ListIterator on the elements of this LinkedList
-	 * 
-	 * @exception IndexOutOfBoundsException
-	 *                when <code>location < 0 || >= size()</code>
-	 * 
-	 * @see ListIterator
-	 */
-	@Override
+                link = link.previous;
+            }
+        }
+        return -1;
+    }
+
+    /**
+     * Answers a ListIterator on the elements of this LinkedList. The elements
+     * are iterated in the same order that they occur in the LinkedList. The
+     * iteration starts at the specified location.
+     * 
+     * @param location
+     *            the index at which to start the iteration
+     * @return a ListIterator on the elements of this LinkedList
+     * 
+     * @exception IndexOutOfBoundsException
+     *                when <code>location < 0 || >= size()</code>
+     * 
+     * @see ListIterator
+     */
+    @Override
     public ListIterator<E> listIterator(int location) {
-		return new LinkIterator<E>(this, location);
-	}
+        return new LinkIterator<E>(this, location);
+    }
 
-	/**
-	 * Removes the object at the specified location from this LinkedList.
-	 * 
-	 * @param location
-	 *            the index of the object to remove
-	 * @return the removed object
-	 * 
-	 * @exception IndexOutOfBoundsException
-	 *                when <code>location < 0 || >= size()</code>
-	 */
-	@Override
+    /**
+     * Removes the object at the specified location from this LinkedList.
+     * 
+     * @param location
+     *            the index of the object to remove
+     * @return the removed object
+     * 
+     * @exception IndexOutOfBoundsException
+     *                when <code>location < 0 || >= size()</code>
+     */
+    @Override
     public E remove(int location) {
-		if (0 <= location && location < size) {
-			Link<E> link = voidLink;
-			if (location < (size / 2)) {
-				for (int i = 0; i <= location; i++) {
+        if (0 <= location && location < size) {
+            Link<E> link = voidLink;
+            if (location < (size / 2)) {
+                for (int i = 0; i <= location; i++) {
                     link = link.next;
                 }
-			} else {
-				for (int i = size; i > location; i--) {
+            } else {
+                for (int i = size; i > location; i--) {
                     link = link.previous;
                 }
-			}
-			Link<E> previous = link.previous;
-			Link<E> next = link.next;
-			previous.next = next;
-			next.previous = previous;
-			size--;
-			modCount++;
-			return link.data;
-		}
+            }
+            Link<E> previous = link.previous;
+            Link<E> next = link.next;
+            previous.next = next;
+            next.previous = previous;
+            size--;
+            modCount++;
+            return link.data;
+        }
         throw new IndexOutOfBoundsException();
-	}
+    }
 
-	@Override
+    @Override
     public boolean remove(Object object) {
-		return removeFirstOccurrenceImpl(object);
-	}
+        return removeFirstOccurrenceImpl(object);
+    }
+
+    /**
+     * Removes the first object from this LinkedList.
+     * 
+     * @return the removed object
+     * 
+     * @exception NoSuchElementException
+     *                when this LinkedList is empty
+     */
+    public E removeFirst() {
+        return removeFirstImpl();
+    }
 
-	/**
-	 * Removes the first object from this LinkedList.
-	 * 
-	 * @return the removed object
-	 * 
-	 * @exception NoSuchElementException
-	 *                when this LinkedList is empty
-	 */
-	public E removeFirst() {
-		return removeFirstImpl();
-	}
-
-	private E removeFirstImpl() {
-		Link<E> first = voidLink.next;
-		if (first != voidLink) {
-			Link<E> next = first.next;
-			voidLink.next = next;
-			next.previous = voidLink;
-			size--;
-			modCount++;
-			return first.data;
-		}
+    private E removeFirstImpl() {
+        Link<E> first = voidLink.next;
+        if (first != voidLink) {
+            Link<E> next = first.next;
+            voidLink.next = next;
+            next.previous = voidLink;
+            size--;
+            modCount++;
+            return first.data;
+        }
         throw new NoSuchElementException();
-	}
+    }
 
-	/**
-	 * Removes the last object from this LinkedList.
-	 * 
-	 * @return the removed object
-	 * 
-	 * @exception NoSuchElementException
-	 *                when this LinkedList is empty
-	 */
-	public E removeLast() {
-		return removeLastImpl();
-	}
-
-	private E removeLastImpl() {
-		Link<E> last = voidLink.previous;
-		if (last != voidLink) {
-			Link<E> previous = last.previous;
-			voidLink.previous = previous;
-			previous.next = voidLink;
-			size--;
-			modCount++;
-			return last.data;
-		}
+    /**
+     * Removes the last object from this LinkedList.
+     * 
+     * @return the removed object
+     * 
+     * @exception NoSuchElementException
+     *                when this LinkedList is empty
+     */
+    public E removeLast() {
+        return removeLastImpl();
+    }
+
+    private E removeLastImpl() {
+        Link<E> last = voidLink.previous;
+        if (last != voidLink) {
+            Link<E> previous = last.previous;
+            voidLink.previous = previous;
+            previous.next = voidLink;
+            size--;
+            modCount++;
+            return last.data;
+        }
         throw new NoSuchElementException();
-	}
+    }
+
+    /**
+     * {@inheritDoc}
+     * 
+     * @see java.util.Deque#descendingIterator()
+     * @since 1.6
+     */
+    public Iterator<E> descendingIterator() {
+        return new ReverseLinkIterator<E>(this);
+    }
+
+    /**
+     * {@inheritDoc}
+     * 
+     * @see java.util.Deque#offerFirst(java.lang.Object)
+     * @since 1.6
+     */
+    public boolean offerFirst(E e) {
+        return addFirstImpl(e);
+    }
+
+    /**
+     * {@inheritDoc}
+     * 
+     * @see java.util.Deque#offerLast(java.lang.Object)
+     * @since 1.6
+     */
+    public boolean offerLast(E e) {
+        return addLastImpl(e);
+    }
 
-	/**
-	 * {@inheritDoc}
-	 * 
-	 * @see java.util.Deque#descendingIterator()
-	 * @since 1.6
-	 */
-	public Iterator<E> descendingIterator() {
-		return new ReverseLinkIterator<E>(this);
-	}
-
-	/**
-	 * {@inheritDoc}
-	 * 
-	 * @see java.util.Deque#offerFirst(java.lang.Object)
-	 * @since 1.6
-	 */
-	public boolean offerFirst(E e) {
-		return addFirstImpl(e);
-	}
-
-	/**
-	 * {@inheritDoc}
-	 * 
-	 * @see java.util.Deque#offerLast(java.lang.Object)
-	 * @since 1.6
-	 */
-	public boolean offerLast(E e) {
-		return addLastImpl(e);
-	}
-
-	/**
-	 * {@inheritDoc}
-	 * 
-	 * @see java.util.Deque#peekFirst()
-	 * @since 1.6
-	 */
-	public E peekFirst() {
-		return peekFirstImpl();
-	}
-
-	/**
-	 * {@inheritDoc}
-	 * 
-	 * @see java.util.Deque#peekLast()
-	 * @since 1.6
-	 */
-	public E peekLast() {
-		Link<E> last = voidLink.previous;
-		return (last == voidLink) ? null : last.data;
-	}
-
-	/**
-	 * {@inheritDoc}
-	 * 
-	 * @see java.util.Deque#pollFirst()
-	 * @since 1.6
-	 */
-	public E pollFirst() {
-		return (size == 0) ? null : removeFirstImpl();
-	}
-
-	/**
-	 * {@inheritDoc}
-	 * 
-	 * @see java.util.Deque#pollLast()
-	 * @since 1.6
-	 */
-	public E pollLast() {
-		return (size == 0) ? null : removeLastImpl();
-	}
-
-	/**
-	 * {@inheritDoc}
-	 * 
-	 * @see java.util.Deque#pop()
-	 * @since 1.6
-	 */
-	public E pop() {
-		return removeFirstImpl();
-	}
-
-	/**
-	 * {@inheritDoc}
-	 * 
-	 * @see java.util.Deque#push(java.lang.Object)
-	 * @since 1.6
-	 */
-	public void push(E e) {
-		addFirstImpl(e);
-	}
-
-	/**
-	 * {@inheritDoc}
-	 * 
-	 * @see java.util.Deque#removeFirstOccurrence(java.lang.Object)
-	 * @since 1.6
-	 */
-	public boolean removeFirstOccurrence(Object o) {
-		return removeFirstOccurrenceImpl(o);
-	}
-
-	/**
-	 * {@inheritDoc}
-	 * 
-	 * @see java.util.Deque#removeLastOccurrence(java.lang.Object)
-	 * @since 1.6
-	 */
-	public boolean removeLastOccurrence(Object o) {
-		Iterator<E> iter = new ReverseLinkIterator<E>(this);
-		return removeOneOccurrence(o, iter);
-	}
-
-	private boolean removeFirstOccurrenceImpl(Object o) {
-		Iterator<E> iter = new LinkIterator<E>(this, 0);
-		return removeOneOccurrence(o, iter);
-	}
-
-	private boolean removeOneOccurrence(Object o, Iterator<E> iter) {
-		while (iter.hasNext()) {
-			E element = iter.next();
-			if (o == null ? element == null : o.equals(element)) {
-				iter.remove();
-				return true;
-			}
-		}
-		return false;
-	}
-
-	/**
-	 * Replaces the element at the specified location in this LinkedList with
-	 * the specified object.
-	 * 
-	 * @param location
-	 *            the index at which to put the specified object
-	 * @param object
-	 *            the object to add
-	 * @return the previous element at the index
-	 * 
-	 * @exception IndexOutOfBoundsException
-	 *                when <code>location < 0 || >= size()</code>
-	 */
-	@Override
+    /**
+     * {@inheritDoc}
+     * 
+     * @see java.util.Deque#peekFirst()
+     * @since 1.6
+     */
+    public E peekFirst() {
+        return peekFirstImpl();
+    }
+
+    /**
+     * {@inheritDoc}
+     * 
+     * @see java.util.Deque#peekLast()
+     * @since 1.6
+     */
+    public E peekLast() {
+        Link<E> last = voidLink.previous;
+        return (last == voidLink) ? null : last.data;
+    }
+
+    /**
+     * {@inheritDoc}
+     * 
+     * @see java.util.Deque#pollFirst()
+     * @since 1.6
+     */
+    public E pollFirst() {
+        return (size == 0) ? null : removeFirstImpl();
+    }
+
+    /**
+     * {@inheritDoc}
+     * 
+     * @see java.util.Deque#pollLast()
+     * @since 1.6
+     */
+    public E pollLast() {
+        return (size == 0) ? null : removeLastImpl();
+    }
+
+    /**
+     * {@inheritDoc}
+     * 
+     * @see java.util.Deque#pop()
+     * @since 1.6
+     */
+    public E pop() {
+        return removeFirstImpl();
+    }
+
+    /**
+     * {@inheritDoc}
+     * 
+     * @see java.util.Deque#push(java.lang.Object)
+     * @since 1.6
+     */
+    public void push(E e) {
+        addFirstImpl(e);
+    }
+
+    /**
+     * {@inheritDoc}
+     * 
+     * @see java.util.Deque#removeFirstOccurrence(java.lang.Object)
+     * @since 1.6
+     */
+    public boolean removeFirstOccurrence(Object o) {
+        return removeFirstOccurrenceImpl(o);
+    }
+
+    /**
+     * {@inheritDoc}
+     * 
+     * @see java.util.Deque#removeLastOccurrence(java.lang.Object)
+     * @since 1.6
+     */
+    public boolean removeLastOccurrence(Object o) {
+        Iterator<E> iter = new ReverseLinkIterator<E>(this);
+        return removeOneOccurrence(o, iter);
+    }
+
+    private boolean removeFirstOccurrenceImpl(Object o) {
+        Iterator<E> iter = new LinkIterator<E>(this, 0);
+        return removeOneOccurrence(o, iter);
+    }
+
+    private boolean removeOneOccurrence(Object o, Iterator<E> iter) {
+        while (iter.hasNext()) {
+            E element = iter.next();
+            if (o == null ? element == null : o.equals(element)) {
+                iter.remove();
+                return true;
+            }
+        }
+        return false;
+    }
+
+    /**
+     * Replaces the element at the specified location in this LinkedList with
+     * the specified object.
+     * 
+     * @param location
+     *            the index at which to put the specified object
+     * @param object
+     *            the object to add
+     * @return the previous element at the index
+     * 
+     * @exception IndexOutOfBoundsException
+     *                when <code>location < 0 || >= size()</code>
+     */
+    @Override
     public E set(int location, E object) {
-		if (0 <= location && location < size) {
-			Link<E> link = voidLink;
-			if (location < (size / 2)) {
-				for (int i = 0; i <= location; i++) {
+        if (0 <= location && location < size) {
+            Link<E> link = voidLink;
+            if (location < (size / 2)) {
+                for (int i = 0; i <= location; i++) {
                     link = link.next;
                 }
-			} else {
-				for (int i = size; i > location; i--) {
+            } else {
+                for (int i = size; i > location; i--) {
                     link = link.previous;
                 }
-			}
-			E result = link.data;
-			link.data = object;
-			return result;
-		}
+            }
+            E result = link.data;
+            link.data = object;
+            return result;
+        }
         throw new IndexOutOfBoundsException();
-	}
+    }
 
-	/**
-	 * Answers the number of elements in this LinkedList.
-	 * 
-	 * @return the number of elements in this LinkedList
-	 */
-	@Override
+    /**
+     * Answers the number of elements in this LinkedList.
+     * 
+     * @return the number of elements in this LinkedList
+     */
+    @Override
     public int size() {
-		return size;
-	}
-    
+        return size;
+    }
+
     public boolean offer(E o) {
-		return addLastImpl(o);
+        return addLastImpl(o);
     }
 
     public E poll() {
-		return (size == 0) ? null : removeFirstImpl();
+        return (size == 0) ? null : removeFirstImpl();
     }
 
     public E remove() {
-		return removeFirstImpl();
+        return removeFirstImpl();
     }
 
     public E peek() {
-		return peekFirstImpl();
-	}
+        return peekFirstImpl();
+    }
 
-	private E peekFirstImpl() {
+    private E peekFirstImpl() {
         Link<E> first = voidLink.next;
         return first == voidLink ? null : first.data;
     }
 
     public E element() {
-		return getFirstImpl();
+        return getFirstImpl();
     }
 
-	/**
-	 * Answers a new array containing all elements contained in this LinkedList.
-	 * 
-	 * @return an array of the elements from this LinkedList
-	 */
-	@Override
+    /**
+     * Answers a new array containing all elements contained in this LinkedList.
+     * 
+     * @return an array of the elements from this LinkedList
+     */
+    @Override
     public Object[] toArray() {
-		int index = 0;
-		Object[] contents = new Object[size];
-		Link<E> link = voidLink.next;
-		while (link != voidLink) {
-			contents[index++] = link.data;
-			link = link.next;
-		}
-		return contents;
-	}
-
-	/**
-	 * Answers an array containing all elements contained in this LinkedList. If
-	 * the specified array is large enough to hold the elements, the specified
-	 * array is used, otherwise an array of the same type is created. If the
-	 * specified array is used and is larger than this LinkedList, the array
-	 * element following the collection elements is set to null.
-	 * 
-	 * @param contents
-	 *            the array
-	 * @return an array of the elements from this LinkedList
-	 * 
-	 * @exception ArrayStoreException
-	 *                when the type of an element in this LinkedList cannot be
-	 *                stored in the type of the specified array
-	 */
-	@Override
+        int index = 0;
+        Object[] contents = new Object[size];
+        Link<E> link = voidLink.next;
+        while (link != voidLink) {
+            contents[index++] = link.data;
+            link = link.next;
+        }
+        return contents;
+    }
+
+    /**
+     * Answers an array containing all elements contained in this LinkedList. If
+     * the specified array is large enough to hold the elements, the specified
+     * array is used, otherwise an array of the same type is created. If the
+     * specified array is used and is larger than this LinkedList, the array
+     * element following the collection elements is set to null.
+     * 
+     * @param contents
+     *            the array
+     * @return an array of the elements from this LinkedList
+     * 
+     * @exception ArrayStoreException
+     *                when the type of an element in this LinkedList cannot be
+     *                stored in the type of the specified array
+     */
+    @Override
     @SuppressWarnings("unchecked")
     public <T> T[] toArray(T[] contents) {
-		int index = 0;
-		if (size > contents.length) {
+        int index = 0;
+        if (size > contents.length) {
             Class<?> ct = contents.getClass().getComponentType();
             contents = (T[]) Array.newInstance(ct, size);
         }
-		Link<E> link = voidLink.next;
-		while (link != voidLink) {
-			contents[index++] = (T)link.data;
-			link = link.next;
-		}
-		if (index < contents.length) {
+        Link<E> link = voidLink.next;
+        while (link != voidLink) {
+            contents[index++] = (T) link.data;
+            link = link.next;
+        }
+        if (index < contents.length) {
             contents[index] = null;
         }
-		return contents;
-	}
+        return contents;
+    }
 
-	private void writeObject(ObjectOutputStream stream) throws IOException {
-		stream.defaultWriteObject();
-		stream.writeInt(size);
-		Iterator<E> it = iterator();
-		while (it.hasNext()) {
+    private void writeObject(ObjectOutputStream stream) throws IOException {
+        stream.defaultWriteObject();
+        stream.writeInt(size);
+        Iterator<E> it = iterator();
+        while (it.hasNext()) {
             stream.writeObject(it.next());
         }
-	}
+    }
 
-	@SuppressWarnings("unchecked")
+    @SuppressWarnings("unchecked")
     private void readObject(ObjectInputStream stream) throws IOException,
-			ClassNotFoundException {
-		stream.defaultReadObject();
-		size = stream.readInt();
-		voidLink = new Link<E>(null, null, null);
-		Link<E> link = voidLink;
-		for (int i = size; --i >= 0;) {
-			Link<E> nextLink = new Link<E>((E)stream.readObject(), link, null);
-			link.next = nextLink;
-			link = nextLink;
-		}
-		link.next = voidLink;
-		voidLink.previous = link;
-	}
+            ClassNotFoundException {
+        stream.defaultReadObject();
+        size = stream.readInt();
+        voidLink = new Link<E>(null, null, null);
+        Link<E> link = voidLink;
+        for (int i = size; --i >= 0;) {
+            Link<E> nextLink = new Link<E>((E) stream.readObject(), link, null);
+            link.next = nextLink;
+            link = nextLink;
+        }
+        link.next = voidLink;
+        voidLink.previous = link;
+    }
 }



Mime
View raw message