summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBurak Emir <emir@epfl.ch>2006-11-20 16:20:31 +0000
committerBurak Emir <emir@epfl.ch>2006-11-20 16:20:31 +0000
commitf05f4846f1f290faac95b5ecef65b6876d9502cd (patch)
tree9837e71e3a497e25ca8eb11d94d1bc95ce3c9867 /src
parent4aeee87b5d4819cf419f8f402dc0ac523657d0f2 (diff)
downloadscala-f05f4846f1f290faac95b5ecef65b6876d9502cd.tar.gz
scala-f05f4846f1f290faac95b5ecef65b6876d9502cd.tar.bz2
scala-f05f4846f1f290faac95b5ecef65b6876d9502cd.zip
indexOf(fun) => indexOf(elem), moved indexOf(el...
indexOf(fun) => indexOf(elem), moved indexOf(elem) from seq to iterable
Diffstat (limited to 'src')
-rw-r--r--src/library/scala/Iterable.scala24
-rw-r--r--src/library/scala/Seq.scala22
2 files changed, 23 insertions, 23 deletions
diff --git a/src/library/scala/Iterable.scala b/src/library/scala/Iterable.scala
index 45b67e7550..600736fea2 100644
--- a/src/library/scala/Iterable.scala
+++ b/src/library/scala/Iterable.scala
@@ -130,7 +130,7 @@ trait Iterable[+A] {
* @return the index of the first element satisfying <code>p</code>,
* or -1 if such an element does not exist
*/
- def indexOf(p: A => Boolean): Int = {
+ def findIndexOf(p: A => Boolean): Int = {
val it = elements
var i = 0
while (it.hasNext)
@@ -141,6 +141,28 @@ trait Iterable[+A] {
return -1
}
+ /** Returns the index of the first occurence of the specified
+ * object in this iterable object.
+ *
+ * @param elem element to search for.
+ * @return the index in this sequence of the first occurence of the
+ * specified element, or -1 if the sequence does not contain
+ * this element.
+ */
+ def indexOf[B >: A](elem: B): Int = {
+ val it = elements
+ var i = 0
+ var found = false
+ while (!found && it.hasNext) {
+ if (it.next == elem) {
+ found = true
+ } else {
+ i = i + 1
+ }
+ }
+ if (found) i else -1
+ }
+
/** Combines the elements of this list together using the binary
* operator <code>op</code>, from left to right, and starting with
* the value <code>z</code>.
diff --git a/src/library/scala/Seq.scala b/src/library/scala/Seq.scala
index 264d1122dc..85a3b08f60 100644
--- a/src/library/scala/Seq.scala
+++ b/src/library/scala/Seq.scala
@@ -89,28 +89,6 @@ trait Seq[+A] extends AnyRef with PartialFunction[Int, A] with Iterable[A] {
*/
def isDefinedAt(x: Int): Boolean = (x >= 0) && (x < length)
- /** Returns the index of the first occurence of the specified
- * object in this sequence.
- *
- * @param elem element to search for.
- * @return the index in this sequence of the first occurence of the
- * specified element, or -1 if the sequence does not contain
- * this element.
- */
- def indexOf[B >: A](elem: B): Int = {
- val it = elements
- var i = 0
- var found = false
- while (!found && it.hasNext) {
- if (it.next == elem) {
- found = true
- } else {
- i = i + 1
- }
- }
- if (found) i else -1
- }
-
/** Returns the index of the last occurence of the specified element
* in this sequence, or -1 if the sequence does not contain this element.
*