diff src/org/tmatesoft/hg/internal/ArrayHelper.java @ 311:b9592e21176a

Tests for array sort and reverse index building helper
author Artem Tikhomirov <tikhomirov.artem@gmail.com>
date Mon, 26 Sep 2011 04:06:04 +0200
parents 237de162be28
children 6334b0267103
line wrap: on
line diff
--- a/src/org/tmatesoft/hg/internal/ArrayHelper.java	Sat Sep 24 13:25:33 2011 +0200
+++ b/src/org/tmatesoft/hg/internal/ArrayHelper.java	Mon Sep 26 04:06:04 2011 +0200
@@ -17,6 +17,7 @@
 package org.tmatesoft.hg.internal;
 
 /**
+ * Internal alternative to Arrays.sort to build reversed index along with sorting
  * 
  * @author Artem Tikhomirov
  * @author TMate Software Ltd.
@@ -32,13 +33,17 @@
 		for (int i = 0; i < reverse.length; i++) {
 			// element that was not moved don't have an index in reverse.
 			// perhaps, can do it inside sort alg?
-			// TODO tests!
+			// Alternatively, may start with filling reverse[] array with initial indexes and
+			// avoid != 0 comparisons in #swap altogether?
 			if (reverse[i] == 0) {
 				reverse[i] = i+1;
 			}
 		}
 	}
-	
+
+	/**
+	 * Slightly modified version of Arrays.sort1(int[], int, int) quicksort alg (just to deal with Object[])
+	 */
     private void sort1(Comparable<Object> x[], int off, int len) {
     	// Insertion sort on smallest arrays
     	if (len < 7) {