<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -72,8 +72,37 @@ class Random(val self: java.util.Random) {
 }
 
 /** The object &lt;code&gt;Random&lt;/code&gt; offers a default implementation
- *  of scala.util.Random.
+ *  of scala.util.Random and random-related convenience methods.
  *
  *  @since 2.8
  */
 object Random extends Random
+{
+  import collection.Sequence
+  
+  /** Returns a new sequence in random order.
+   *  @param  seq   the sequence to shuffle
+   *  @return       the shuffled sequence
+   */
+  def shuffle[T](seq: Sequence[T]): Sequence[T] = {
+    // It would be better if this preserved the shape of its container, but I have
+    // again been defeated by the lack of higher-kinded type inference.  I can
+    // only make it work that way if it's called like
+    //   shuffle[Int,List](List.range(0,100))
+    // which nicely defeats the &quot;convenience&quot; portion of &quot;convenience method&quot;.
+    val buf: Array[T] = seq.toArray
+        
+    def swap(i1: Int, i2: Int) {
+      val tmp = buf(i1)
+      buf(i1) = buf(i2)
+      buf(i2) = tmp
+    }
+    
+    for (n &lt;- buf.length to 2 by -1) {
+      val k = nextInt(n)
+      swap(n - 1, k)
+    }
+    
+    buf.toSeq
+  }
+}</diff>
      <filename>src/library/scala/util/Random.scala</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>c416256772c6ced49b9ef954d20e2449e5de6222</id>
    </parent>
  </parents>
  <author>
    <name>extempore</name>
    <email>extempore@5e8d7ff9-d8ef-0310-90f0-a4852d11357a</email>
  </author>
  <url>http://github.com/jorgeortiz85/scala/commit/4133571d758fd4ff2511b2bafa031eba625f87c3</url>
  <id>4133571d758fd4ff2511b2bafa031eba625f87c3</id>
  <committed-date>2009-05-28T08:51:07-07:00</committed-date>
  <authored-date>2009-05-28T08:51:07-07:00</authored-date>
  <message>Added a sequence shuffling method to scala.util.Random.

git-svn-id: http://lampsvn.epfl.ch/svn-repos/scala/scala/trunk@17884 5e8d7ff9-d8ef-0310-90f0-a4852d11357a</message>
  <tree>b7e2bf06a12a61af7069244eb5b9c4f36616d738</tree>
  <committer>
    <name>extempore</name>
    <email>extempore@5e8d7ff9-d8ef-0310-90f0-a4852d11357a</email>
  </committer>
</commit>
