summaryrefslogtreecommitdiff
path: root/src/library
diff options
context:
space:
mode:
Diffstat (limited to 'src/library')
-rw-r--r--src/library/scala/annotation/experimental.scala16
-rw-r--r--src/library/scala/collection/generic/TraversableTemplate.scala14
2 files changed, 30 insertions, 0 deletions
diff --git a/src/library/scala/annotation/experimental.scala b/src/library/scala/annotation/experimental.scala
new file mode 100644
index 0000000000..b33d9ea246
--- /dev/null
+++ b/src/library/scala/annotation/experimental.scala
@@ -0,0 +1,16 @@
+/* __ *\
+** ________ ___ / / ___ Scala API **
+** / __/ __// _ | / / / _ | (c) 2002-2009, LAMP/EPFL **
+** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
+** /____/\___/_/ |_/____/_/ | | **
+** |/ **
+\* */
+package scala.annotation
+
+/** <p>
+ * An annotation for experimental features.
+ * </p>
+ */
+final class experimental(message: String) extends StaticAnnotation {
+ def this() = this("")
+} \ No newline at end of file
diff --git a/src/library/scala/collection/generic/TraversableTemplate.scala b/src/library/scala/collection/generic/TraversableTemplate.scala
index 64017b06aa..e053ab4cb4 100644
--- a/src/library/scala/collection/generic/TraversableTemplate.scala
+++ b/src/library/scala/collection/generic/TraversableTemplate.scala
@@ -13,6 +13,7 @@ package scala.collection.generic
// import immutable.{List, Stream, Nil} //!!!
import mutable.{Buffer, ArrayBuffer, ListBuffer}
+import annotation.experimental
/** A template trait for traversable collections.
* This is a base trait of all kinds of Scala collections. It implements
@@ -180,6 +181,19 @@ self =>
b.result
}
+ /** Returns a new traversable based on the partial function <code>pf</code>,
+ * containing pf(x) for all the elements which are defined on pf.
+ * The order of the elements is preserved.
+ * @param pf the partial function which filters and maps the traversable.
+ * @return the new traversable.
+ */
+ @experimental
+ def filterMap[B, That](pf: PartialFunction[Any, B])(implicit bf: BuilderFactory[B, That, This]): That = {
+ val b = bf(thisCollection)
+ for (x <- this) if (pf.isDefinedAt(x)) b += pf(x)
+ b.result
+ }
+
/** Returns a traversable with all elements of this traversable which do not satisfy the predicate
* <code>p</code>.
*