diff options
Diffstat (limited to 'src/library/scalax/collection/generic/covartest/SequenceForwarder.scala')
-rw-r--r-- | src/library/scalax/collection/generic/covartest/SequenceForwarder.scala | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/src/library/scalax/collection/generic/covartest/SequenceForwarder.scala b/src/library/scalax/collection/generic/covartest/SequenceForwarder.scala new file mode 100644 index 0000000000..d5ba7ea063 --- /dev/null +++ b/src/library/scalax/collection/generic/covartest/SequenceForwarder.scala @@ -0,0 +1,50 @@ +/* __ *\ +** ________ ___ / / ___ Scala API ** +** / __/ __// _ | / / / _ | (c) 2003-2007, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** +** /____/\___/_/ |_/____/_/ | | ** +** |/ ** +\* */ + +// $Id: SeqProxy.scala 15458 2008-06-28 20:23:22Z stepancheg $ + + +package scalax.collection.generic.covartest + +/** This class implements a forwarder for sequences. It forwards + * all calls to a different sequence object except for + * + * - toString, hashCode, equals, stringPrefix + * - newBuilder, view, toSequence + * - all calls creating a new iterable objetc of the same kind + * + * The above methods are forwarded by subclass SequenceProxy + * + * @author Martin Odersky + * @version 2.8 + */ +trait SequenceForwarder[+A] extends Sequence[A] with IterableForwarder[A] { + + protected override def underlying: Sequence[A] + + // PartialFunction delegates + + override def apply(i: Int): A = underlying.apply(i) + override def isDefinedAt(x: Int): Boolean = underlying.isDefinedAt(x) + + // Sequence delegates + // Sequence methods could be printed by cat SequenceTemplate.scala | sed -n '/trait Seq/,$ p' | egrep '^ (override )?def' + + override def length: Int = underlying.length + override def lengthCompare(l: Int) = underlying lengthCompare l + override def segmentLength(p: A => Boolean, from: Int): Int = underlying.segmentLength(p, from) + override def prefixLength(p: A => Boolean) = underlying.prefixLength(p) + override def indexWhere(p: A => Boolean, from: Int): Int = underlying.indexWhere(p, from) + override def indexOf[B >: A](elem: B, from: Int): Int = underlying.indexOf(elem, from) + override def reversedElements: Iterator[A] = underlying.reversedElements + override def startsWith[B](that: Sequence[B], offset: Int): Boolean = underlying.startsWith(that, offset) + override def endsWith[B](that: Sequence[B]): Boolean = underlying.endsWith(that) + override def indexOf[B >: A](that: Sequence[B]): Int = underlying.indexOf(that) + override def contains(elem: Any): Boolean = underlying.contains(elem) + override def indices: Range = underlying.indices +} |