You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mahout.apache.org by sr...@apache.org on 2010/01/22 21:35:21 UTC

svn commit: r902259 - in /lucene/mahout/trunk/math: pom.xml src/main/java/org/apache/mahout/math/Arrays.java src/main/java/org/apache/mahout/math/Sorting.java

Author: srowen
Date: Fri Jan 22 20:35:21 2010
New Revision: 902259

URL: http://svn.apache.org/viewvc?rev=902259&view=rev
Log:
MAHOUT-264

Modified:
    lucene/mahout/trunk/math/pom.xml
    lucene/mahout/trunk/math/src/main/java/org/apache/mahout/math/Arrays.java
    lucene/mahout/trunk/math/src/main/java/org/apache/mahout/math/Sorting.java

Modified: lucene/mahout/trunk/math/pom.xml
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/math/pom.xml?rev=902259&r1=902258&r2=902259&view=diff
==============================================================================
--- lucene/mahout/trunk/math/pom.xml (original)
+++ lucene/mahout/trunk/math/pom.xml Fri Jan 22 20:35:21 2010
@@ -43,6 +43,14 @@
 
     <plugins>
       <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-compiler-plugin</artifactId>
+        <configuration>
+          <source>1.5</source>
+          <target>1.5</target>
+        </configuration>
+      </plugin>
+      <plugin>
         <groupId>org.apache.mahout</groupId>
         <artifactId>mahout-collection-codegen-plugin</artifactId>
         <version>${project.version}</version>

Modified: lucene/mahout/trunk/math/src/main/java/org/apache/mahout/math/Arrays.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/math/src/main/java/org/apache/mahout/math/Arrays.java?rev=902259&r1=902258&r2=902259&view=diff
==============================================================================
--- lucene/mahout/trunk/math/src/main/java/org/apache/mahout/math/Arrays.java (original)
+++ lucene/mahout/trunk/math/src/main/java/org/apache/mahout/math/Arrays.java Fri Jan 22 20:35:21 2010
@@ -596,4 +596,67 @@
     }
     return array;
   }
+
+  /**
+   * {@link java.util.Arrays#copyOf} compatibility with Java 1.5.
+   */
+  public static byte[] copyOf(byte[] src, int length) {
+      byte[] result = new byte [length];
+      System.arraycopy(src, 0, result, 0, Math.min(length, src.length));
+      return result;
+  }
+  
+  /**
+   * {@link java.util.Arrays#copyOf} compatibility with Java 1.5.
+   */
+  public static char[] copyOf(char[] src, int length) {
+      char[] result = new char [length];
+      System.arraycopy(src, 0, result, 0, Math.min(length, src.length));
+      return result;
+  }
+  
+  /**
+   * {@link java.util.Arrays#copyOf} compatibility with Java 1.5.
+   */
+  public static short[] copyOf(short[] src, int length) {
+      short[] result = new short [length];
+      System.arraycopy(src, 0, result, 0, Math.min(length, src.length));
+      return result;
+  }
+  
+  /**
+   * {@link java.util.Arrays#copyOf} compatibility with Java 1.5. 
+   */
+  public static int[] copyOf(int[] src, int length) {
+      int[] result = new int [length];
+      System.arraycopy(src, 0, result, 0, Math.min(length, src.length));
+      return result;
+  }
+  
+  /**
+   * {@link java.util.Arrays#copyOf} compatibility with Java 1.5.
+   */
+  public static float[] copyOf(float[] src, int length) {
+      float[] result = new float [length];
+      System.arraycopy(src, 0, result, 0, Math.min(length, src.length));
+      return result;
+  }
+
+  /**
+   * {@link java.util.Arrays#copyOf} compatibility with Java 1.5.
+   */
+  public static double[] copyOf(double[] src, int length) {
+      double[] result = new double [length];
+      System.arraycopy(src, 0, result, 0, Math.min(length, src.length));
+      return result;
+  }
+  
+  /**
+   * {@link java.util.Arrays#copyOf} compatibility with Java 1.5.
+   */
+  public static long[] copyOf(long[] src, int length) {
+      long[] result = new long [length];
+      System.arraycopy(src, 0, result, 0, Math.min(length, src.length));
+      return result;
+  }
 }

Modified: lucene/mahout/trunk/math/src/main/java/org/apache/mahout/math/Sorting.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/math/src/main/java/org/apache/mahout/math/Sorting.java?rev=902259&r1=902258&r2=902259&view=diff
==============================================================================
--- lucene/mahout/trunk/math/src/main/java/org/apache/mahout/math/Sorting.java (original)
+++ lucene/mahout/trunk/math/src/main/java/org/apache/mahout/math/Sorting.java Fri Jan 22 20:35:21 2010
@@ -1734,7 +1734,7 @@
    */
   public static void mergeSort(byte[] array, int start, int end, ByteComparator comp) {
     checkBounds(array.length, start, end);
-    byte[] out = java.util.Arrays.copyOf(array, array.length);
+    byte[] out = Arrays.copyOf(array, array.length);
     mergeSort(out, array, start, end, comp);
   }
 
@@ -1850,7 +1850,7 @@
    */
   public static void mergeSort(char[] array, int start, int end, CharComparator comp) {
     checkBounds(array.length, start, end);
-    char[] out = java.util.Arrays.copyOf(array, array.length);
+    char[] out = Arrays.copyOf(array, array.length);
     mergeSort(out, array, start, end, comp);
   }
 
@@ -1959,17 +1959,17 @@
   
   public static void mergeSort(short[] array, int start, int end, ShortComparator comp) {
     checkBounds(array.length, start, end);
-    short[] out = java.util.Arrays.copyOf(array, array.length);
+    short[] out = Arrays.copyOf(array, array.length);
     mergeSort(out, array, start, end, comp);
   }
 
   
   /**
    * Perform a merge sort on a range of a short array using a specified ordering.
-   * @param array the array.
+   * @param in the array.
    * @param start the first index.
    * @param end the last index (exclusive).
-   * @param comp the comparator object.
+   * @param c the comparator object.
    */
   private static void mergeSort(short[] in, short[] out, int start, int end,
       ShortComparator c) {
@@ -2077,16 +2077,16 @@
    */
   public static void mergeSort(int[] array, int start, int end, IntComparator comp) {
     checkBounds(array.length, start, end);
-    int[] out = java.util.Arrays.copyOf(array, array.length);
+    int[] out = Arrays.copyOf(array, array.length);
     mergeSort(out, array, start, end, comp);
   }
 
   /**
    * Perform a merge sort on a range of a int array using a specified ordering.
-   * @param array the array.
+   * @param in the array.
    * @param start the first index.
    * @param end the last index (exclusive).
-   * @param comp the comparator object.
+   * @param c the comparator object.
    */
   private static void mergeSort(int[] in, int[] out, int start, int end,
       IntComparator c) {
@@ -2187,7 +2187,6 @@
      * @param array the array.
      * @param start the first index.
      * @param end the last index (exclusive).
-     * @param comp the comparator object.
      */
   public static void mergeSort(long[] array, int start, int end) {
     mergeSort(array, start, end, naturalLongComparison);
@@ -2202,7 +2201,7 @@
    */
   public static void mergeSort(long[] array, int start, int end, LongComparator comp) {
     checkBounds(array.length, start, end);
-    long[] out = java.util.Arrays.copyOf(array, array.length);
+    long[] out = Arrays.copyOf(array, array.length);
     mergeSort(out, array, start, end, comp);
   }
 
@@ -2304,7 +2303,6 @@
      * @param array the array.
      * @param start the first index.
      * @param end the last index (exclusive).
-     * @param comp the comparator object.
      */
   public static void mergeSort(float[] array, int start, int end) {
     mergeSort(array, start, end, naturalFloatComparison);
@@ -2319,7 +2317,7 @@
    */
   public static void mergeSort(float[] array, int start, int end, FloatComparator comp) {
     checkBounds(array.length, start, end);
-    float[] out = java.util.Arrays.copyOf(array, array.length);
+    float[] out = Arrays.copyOf(array, array.length);
     mergeSort(out, array, start, end, comp);
   }
 
@@ -2422,7 +2420,6 @@
      * @param array the array.
      * @param start the first index.
      * @param end the last index (exclusive).
-     * @param comp the comparator object.
      */
   public static void mergeSort(double[] array, int start, int end) {
     mergeSort(array, start, end, naturalDoubleComparison);
@@ -2437,7 +2434,7 @@
    */
   public static void mergeSort(double[] array, int start, int end, DoubleComparator comp) {
     checkBounds(array.length, start, end);
-    double[] out = java.util.Arrays.copyOf(array, array.length);
+    double[] out = Arrays.copyOf(array, array.length);
     mergeSort(out, array, start, end, comp);
   }