harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ton...@apache.org
Subject svn commit: r612362 - in /harmony/enhanced/classlib/trunk/modules/luni/src: main/java/java/util/Collections.java test/api/common/org/apache/harmony/luni/tests/java/util/CollectionsTest.java
Date Wed, 16 Jan 2008 06:08:19 GMT
Author: tonywu
Date: Tue Jan 15 22:08:12 2008
New Revision: 612362

URL: http://svn.apache.org/viewvc?rev=612362&view=rev
Log:
correct the sequence returned by shuffle

Modified:
    harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/Collections.java
    harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/CollectionsTest.java

Modified: harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/Collections.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/Collections.java?rev=612362&r1=612361&r2=612362&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/Collections.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/Collections.java
Tue Jan 15 22:08:12 2008
@@ -1839,7 +1839,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;
                 }
@@ -1858,7 +1858,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/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/CollectionsTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/CollectionsTest.java?rev=612362&r1=612361&r2=612362&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/CollectionsTest.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/CollectionsTest.java
Tue Jan 15 22:08:12 2008
@@ -629,6 +629,13 @@
 		LinkedList ll2 = new LinkedList();
 		ll2.addAll(ll);
 		testShuffle(ll2, "Random Access", true);
+        
+        List l = new ArrayList();
+        l.add('a');
+        l.add('b');
+        l.add('c');
+        Collections.shuffle(l, new Random(12345678921L));
+        assertEquals("acb", l.get(0).toString()+l.get(1)+l.get(2));
 	}
 
 	/**



Mime
View raw message