Cleaning up in scala.runtime.*. Removing unused methods.
Fixed toArray to copy more than one element into the new one. Added sameElements to Iterator to further simplify the case class support logic, and because it should be there anyway. git-svn-id: http://lampsvn.epfl.ch/svn-repos/scala/scala/trunk@19872 5e8d7ff9-d8ef-0310-90f0-a4852d11357a
This commit is contained in:
parent
0d59136f64
commit
0c7759bff3
|
@ -280,7 +280,6 @@ trait StdNames {
|
||||||
val eq = newTermName("eq")
|
val eq = newTermName("eq")
|
||||||
val equals_ = newTermName("equals")
|
val equals_ = newTermName("equals")
|
||||||
val _equals = newTermName("_equals")
|
val _equals = newTermName("_equals")
|
||||||
val _equalsWithVarArgs = newTermName("_equalsWithVarArgs")
|
|
||||||
val inlinedEquals = newTermName("inlinedEquals")
|
val inlinedEquals = newTermName("inlinedEquals")
|
||||||
val error = newTermName("error")
|
val error = newTermName("error")
|
||||||
val ex = newTermName("ex")
|
val ex = newTermName("ex")
|
||||||
|
|
|
@ -14,7 +14,6 @@ package scala.collection
|
||||||
import mutable.{Buffer, ArrayBuffer, ListBuffer, StringBuilder}
|
import mutable.{Buffer, ArrayBuffer, ListBuffer, StringBuilder}
|
||||||
import immutable.{List, Stream}
|
import immutable.{List, Stream}
|
||||||
import annotation.{ tailrec }
|
import annotation.{ tailrec }
|
||||||
// import immutable.{List, Nil, ::, Stream}
|
|
||||||
|
|
||||||
/** The <code>Iterator</code> object provides various functions for
|
/** The <code>Iterator</code> object provides various functions for
|
||||||
* creating specialized iterators.
|
* creating specialized iterators.
|
||||||
|
@ -1031,6 +1030,20 @@ trait Iterator[+A] { self =>
|
||||||
buffer
|
buffer
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Checks if the other iterator contains the same elements as this one.
|
||||||
|
*
|
||||||
|
* @note will not terminate for infinite-sized iterators.
|
||||||
|
* @param that the other iterator
|
||||||
|
* @return true, iff both iterators contain the same elements in the same order.
|
||||||
|
*/
|
||||||
|
def sameElements(that: Iterator[_]): Boolean = {
|
||||||
|
while (hasNext && that.hasNext)
|
||||||
|
if (next != that.next)
|
||||||
|
return false
|
||||||
|
|
||||||
|
!hasNext && !that.hasNext
|
||||||
|
}
|
||||||
|
|
||||||
/** Returns a string representation of the elements in this iterator. The resulting string
|
/** Returns a string representation of the elements in this iterator. The resulting string
|
||||||
* begins with the string <code>start</code> and is finished by the string
|
* begins with the string <code>start</code> and is finished by the string
|
||||||
* <code>end</code>. Inside, the string representations of elements (w.r.t.
|
* <code>end</code>. Inside, the string representations of elements (w.r.t.
|
||||||
|
|
|
@ -52,7 +52,10 @@ object ScalaRunTime {
|
||||||
def toArray[T](xs: scala.collection.Seq[T]) = {
|
def toArray[T](xs: scala.collection.Seq[T]) = {
|
||||||
val arr = new Array[AnyRef](xs.length)
|
val arr = new Array[AnyRef](xs.length)
|
||||||
var i = 0
|
var i = 0
|
||||||
for (x <- xs) arr(i) = x.asInstanceOf[AnyRef]
|
for (x <- xs) {
|
||||||
|
arr(i) = x.asInstanceOf[AnyRef]
|
||||||
|
i += 1
|
||||||
|
}
|
||||||
arr
|
arr
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -87,16 +90,8 @@ object ScalaRunTime {
|
||||||
throw exception
|
throw exception
|
||||||
}
|
}
|
||||||
|
|
||||||
def caseFields(x: Product): List[Any] = {
|
|
||||||
val arity = x.productArity
|
|
||||||
def fields(from: Int): List[Any] =
|
|
||||||
if (from == arity) List()
|
|
||||||
else x.productElement(from) :: fields(from + 1)
|
|
||||||
fields(0)
|
|
||||||
}
|
|
||||||
|
|
||||||
def _toString(x: Product): String =
|
def _toString(x: Product): String =
|
||||||
caseFields(x).mkString(x.productPrefix + "(", ",", ")")
|
x.productIterator.mkString(x.productPrefix + "(", ",", ")")
|
||||||
|
|
||||||
def _hashCodeJenkins(x: Product): Int =
|
def _hashCodeJenkins(x: Product): Int =
|
||||||
scala.util.JenkinsHash.hashSeq(x.productPrefix.toSeq ++ x.productIterator.toSeq)
|
scala.util.JenkinsHash.hashSeq(x.productPrefix.toSeq ++ x.productIterator.toSeq)
|
||||||
|
@ -122,36 +117,10 @@ object ScalaRunTime {
|
||||||
else x.equals(y)
|
else x.equals(y)
|
||||||
|
|
||||||
def _equals(x: Product, y: Any): Boolean = y match {
|
def _equals(x: Product, y: Any): Boolean = y match {
|
||||||
case y1: Product if x.productArity == y1.productArity =>
|
case y: Product if x.productArity == y.productArity => x.productIterator sameElements y.productIterator
|
||||||
val arity = x.productArity
|
case _ => false
|
||||||
var i = 0
|
|
||||||
while (i < arity && x.productElement(i) == y1.productElement(i))
|
|
||||||
i += 1
|
|
||||||
i == arity
|
|
||||||
case _ =>
|
|
||||||
false
|
|
||||||
}
|
}
|
||||||
|
|
||||||
def _equalsWithVarArgs(x: Product, y: Any): Boolean = y match {
|
|
||||||
case y1: Product if x.productArity == y1.productArity =>
|
|
||||||
val arity = x.productArity
|
|
||||||
var i = 0
|
|
||||||
while (i < arity - 1 && x.productElement(i) == y1.productElement(i))
|
|
||||||
i += 1
|
|
||||||
i == arity - 1 && {
|
|
||||||
x.productElement(i) match {
|
|
||||||
case xs: Seq[_] =>
|
|
||||||
y1.productElement(i) match {
|
|
||||||
case ys: Seq[_] => xs sameElements ys
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
case _ =>
|
|
||||||
false
|
|
||||||
}
|
|
||||||
|
|
||||||
def Seq[a](xs: a*): Seq[a] = null // interpreted specially by new backend.
|
|
||||||
|
|
||||||
/** Given any Scala value, convert it to a String.
|
/** Given any Scala value, convert it to a String.
|
||||||
*
|
*
|
||||||
* The primary motivation for this method is to provide a means for
|
* The primary motivation for this method is to provide a means for
|
||||||
|
|
Loading…
Reference in New Issue