scala

trait SeqProxy

[source: scala/SeqProxy.scala]

trait SeqProxy[+A]
extends Seq[A] with CollectionProxy[A]
This class implements a proxy for sequences. It forwards all calls to a different sequence object.
Author
Martin Odersky
Matthias Zenger
Version
2.0, 31/12/2006
Direct Known Subclasses:
RandomAccessSeqProxy, QueueProxy, StackProxy, ListView.selection.items

Method Summary
override def ++ [B >: A](that : Iterable[B]) : Seq[B]
Appends two iterable objects.
override def apply (i : Int) : A
override def concat [B >: A](that : Iterable[B]) : Seq[B]
Appends two iterable objects.
override def contains (elem : Any) : Boolean
Tests if the given value elem is a member of this sequence.
override def containsSlice [B](that : Seq[B]) : Boolean
Is that a slice in this?
override def drop (n : Int) : Seq[A]
Returns this sequence without its n first elements If this sequence has less than n elements, the empty sequence is returned. (non-strict)
override def dropWhile (p : (A) => Boolean) : Seq[A]
Returns the longest suffix of this sequence whose first element does not satisfy the predicate p.
override def endsWith [B](that : Seq[B]) : Boolean
override def equalsWith [B](that : Seq[B])(f : (A, B) => Boolean) : Boolean
override def filter (p : (A) => Boolean) : Seq[A]
Returns all the elements of this sequence that satisfy the predicate p. The order of the elements is preserved.
override def findIndexOf (p : (A) => Boolean) : Int
Returns index of the first element satisying a predicate, or -1.
override def first : A
Returns the first element of this list.
override def firstOption : Option[A]
Returns as an option the first element of this list or None if list is empty.
override def flatMap [B](f : (A) => Iterable[B]) : Seq[B]
Applies the given function f to each element of this sequence, then concatenates the results.
override def headOption : Option[A]
override def indexOf [B >: A](elem : B) : Int
Returns the index of the first occurence of the specified object in this iterable object.
override def indexOf [B >: A](that : Seq[B]) : Int
Searches for the argument sequence in the receiver object, returning the smallest index where a match occurs. If the receiver object, this, is an infinite sequence this method will not terminate if there is no match. Similarly, if the both the receiver object and the argument, that are infinite sequences this method will not terminate. Because both the receiver object and the argument can both potentially be an infinite sequences, we do not attempt to use an optimized searching algorithm. Therefore, the running time will be proportional to the length of the receiver object and the argument. Subclasses and traits can potentially provide an optimized implementation.
override def isDefinedAt (x : Int) : Boolean
Is this partial function defined for the index x?
override def isEmpty : Boolean
Returns true if length == 0
override def last : A
Returns the last element of this list.
override def lastIndexOf [B >: A](elem : B) : Int
Returns the index of the last occurence of the specified element in this sequence, or -1 if the sequence does not contain this element.
override def lastOption : Option[A]
Returns as an option the last element of this list or None if list is empty.
override def length : Int
Returns the length of the sequence.
override def lengthCompare (l : Int) : Int
Result of comparing length with operand l. returns x where x < 0 iff this.length < l x == 0 iff this.length == l x > 0 iff this.length > that. This method is used by matching streams against right-ignoring (...,_*) patterns. Lazy sequences should override this method if length forces evaluation of the stream.
override def map [B](f : (A) => B) : Seq[B]
Returns the sequence resulting from applying the given function f to each element of this sequence.
override def projection : Projection[A]
returns a projection that can be used to call non-strict filter, map, and flatMap methods that build projections of the collection.
override def reverse : Seq[A]
A sequence consisting of all elements of this sequence in reverse order.
override abstract def self : Seq[A]
override def size : Int
should always be length
override def slice (from : Int, len : Int) : Seq[A]
A sub-sequence starting at index from and ending (non-inclusive) at index until (non-strict)
override def slice (from : Int) : Seq[A]
A sub-sequence starting at index from and extending up to the length of the current sequence (non-strict)
override def startsWith [B](that : Seq[B]) : Boolean
Check whether the receiver object starts with the argument sequence.
override def subseq (from : Int, end : Int) : Seq[A]
Returns a subsequence starting from index from consisting of len elements.
override def take (n : Int) : Seq[A]
Returns a sequence consisting only over the first n elements of this sequence, or else the whole sequence, if it has less than n elements. (non-strict)
override def takeWhile (p : (A) => Boolean) : Seq[A]
Returns the longest prefix of this sequence whose elements satisfy the predicate p.
override def toArray [B >: A] : Array[B]
Converts this sequence to a fresh Array with length elements.
override def toSeq : Seq[A]
Overridden for efficiency.
Methods inherited from IterableProxy
elements, partition, foreach, forall, exists, find, foldLeft, foldRight, /:, :\, reduceLeft, reduceRight, copyToBuffer, sameElements, toList, toStream, mkString, mkString, mkString, addString, addString, addString, copyToArray, hasDefiniteSize
Methods inherited from Proxy
hashCode, equals, toString
Methods inherited from Seq
startsWith
Methods inherited from Collection
stringPrefix
Methods inherited from PartialFunction
orElse, andThen
Methods inherited from Function1
compose
Methods inherited from AnyRef
getClass, clone, notify, notifyAll, wait, wait, wait, finalize, ==, !=, eq, ne, synchronized
Methods inherited from Any
==, !=, isInstanceOf, asInstanceOf
Method Details
override abstract def self : Seq[A]
Overrides
CollectionProxy.self

override def apply(i : Int) : A

override def length : Int
Returns the length of the sequence.
Returns
the sequence length.
Overrides
Seq.length

override def lengthCompare(l : Int) : Int
Result of comparing length with operand l. returns x where x < 0 iff this.length < l x == 0 iff this.length == l x > 0 iff this.length > that. This method is used by matching streams against right-ignoring (...,_*) patterns. Lazy sequences should override this method if length forces evaluation of the stream.
Overrides
Seq.lengthCompare

override def size : Int
should always be length
Overrides
Seq.size, CollectionProxy.size

override def isEmpty : Boolean
Returns true if length == 0
Overrides
Seq.isEmpty

@deprecated

override def concat[B >: A](that : Iterable[B]) : Seq[B]
Appends two iterable objects.
Returns
the new iterable object
Deprecated
use ++ instead
Overrides
Seq.concat

override def last : A
Returns the last element of this list.
Returns
the last element of the list.
Throws
Predef.NoSuchElementException - if the list is empty.
Overrides
Seq.last

override def lastOption : Option[A]
Returns as an option the last element of this list or None if list is empty.
Returns
the last element as an option.
Overrides
Seq.lastOption

override def first : A
Returns the first element of this list.
Returns
the first element of the list.
Throws
Predef.UnsupportedOperationException - if the list is empty.
Overrides
Seq.first

override def firstOption : Option[A]
Returns as an option the first element of this list or None if list is empty.
Returns
the first element as an option.
Overrides
Seq.firstOption

override def headOption : Option[A]
Overrides
Seq.headOption

override def ++[B >: A](that : Iterable[B]) : Seq[B]
Appends two iterable objects.
Overrides
Seq.++

override def isDefinedAt(x : Int) : Boolean
Is this partial function defined for the index x?
Parameters
x - ..
Returns
true, iff x is a legal sequence index.
Overrides
Seq.isDefinedAt

override def lastIndexOf[B >: A](elem : B) : Int
Returns the index of the last occurence of the specified element in this sequence, or -1 if the sequence does not contain this element.
Parameters
elem - element to search for.
Returns
the index in this sequence of the last occurence of the specified element, or -1 if the sequence does not contain this element.
Overrides
Seq.lastIndexOf

override def findIndexOf(p : (A) => Boolean) : Int
Returns index of the first element satisying a predicate, or -1.
Notes
may not terminate for infinite-sized collections.
Parameters
p - the predicate
Returns
the index of the first element satisfying p, or -1 if such an element does not exist
Overrides
Seq.findIndexOf

override def indexOf[B >: A](elem : B) : Int
Returns the index of the first occurence of the specified object in this iterable object.
Notes
may not terminate for infinite-sized collections.
Parameters
elem - element to search for.
Returns
the index in this sequence of the first occurence of the specified element, or -1 if the sequence does not contain this element.
Overrides
Seq.indexOf

override def map[B](f : (A) => B) : Seq[B]
Returns the sequence resulting from applying the given function f to each element of this sequence.
Parameters
f - function to apply to each element.
Returns
f(a0), ..., f(an) if this sequence is a0, ..., an.
Overrides
Seq.map

override def flatMap[B](f : (A) => Iterable[B]) : Seq[B]
Applies the given function f to each element of this sequence, then concatenates the results.
Parameters
f - the function to apply on each element.
Returns
f(a0) ::: ... ::: f(an) if this sequence is a0, ..., an.
Overrides
Seq.flatMap

override def filter(p : (A) => Boolean) : Seq[A]
Returns all the elements of this sequence that satisfy the predicate p. The order of the elements is preserved.
Parameters
p - the predicate used to filter the list.
Returns
the elements of this list satisfying p.
Overrides
Seq.filter

override def take(n : Int) : Seq[A]
Returns a sequence consisting only over the first n elements of this sequence, or else the whole sequence, if it has less than n elements. (non-strict)
Parameters
n - the number of elements to take
Returns
a possibly projected sequence
Overrides
Seq.take

override def drop(n : Int) : Seq[A]
Returns this sequence without its n first elements If this sequence has less than n elements, the empty sequence is returned. (non-strict)
Parameters
n - the number of elements to drop
Returns
the new sequence
Overrides
Seq.drop

override def slice(from : Int, len : Int) : Seq[A]
A sub-sequence starting at index from and ending (non-inclusive) at index until (non-strict)
Parameters
from - The index of the first element of the slice
until - The index of the element following the slice
Throws
IndexOutOfBoundsException - if from < 0 or length < from + len
Overrides
Seq.slice

override def slice(from : Int) : Seq[A]
A sub-sequence starting at index from and extending up to the length of the current sequence (non-strict)
Parameters
from - The index of the first element of the slice
Throws
IndexOutOfBoundsException - if from < 0
Deprecated
Use drop(n: Int): Seq[A] instead.
Overrides
Seq.slice

override def takeWhile(p : (A) => Boolean) : Seq[A]
Returns the longest prefix of this sequence whose elements satisfy the predicate p.
Parameters
p - the test predicate.
Returns
the longest prefix of this sequence whose elements satisfy the predicate p.
Overrides
Seq.takeWhile

override def dropWhile(p : (A) => Boolean) : Seq[A]
Returns the longest suffix of this sequence whose first element does not satisfy the predicate p.
Parameters
p - the test predicate.
Returns
the longest suffix of the sequence whose first element does not satisfy the predicate p.
Overrides
Seq.dropWhile

override def reverse : Seq[A]
A sequence consisting of all elements of this sequence in reverse order.
Overrides
Seq.reverse

override def contains(elem : Any) : Boolean
Tests if the given value elem is a member of this sequence.
Parameters
elem - element whose membership has to be tested.
Returns
true iff there is an element of this sequence which is equal (w.r.t. ==) to elem.
Overrides
Seq.contains

override def subseq(from : Int, end : Int) : Seq[A]
Returns a subsequence starting from index from consisting of len elements.
Deprecated
use slice instead
Overrides
Seq.subseq

override def toArray[B >: A] : Array[B]
Converts this sequence to a fresh Array with length elements.
Overrides
Seq.toArray, CollectionProxy.toArray

override def toSeq : Seq[A]
Overridden for efficiency.
Returns
the sequence itself
Overrides
Seq.toSeq

override def projection : Projection[A]
returns a projection that can be used to call non-strict filter, map, and flatMap methods that build projections of the collection.
Overrides
Seq.projection

override def equalsWith[B](that : Seq[B])(f : (A, B) => Boolean) : Boolean
Overrides
Seq.equalsWith

override def startsWith[B](that : Seq[B]) : Boolean
Check whether the receiver object starts with the argument sequence.
Returns
true if that is a prefix of this, otherwise false
See Also
Seq.startsWith
Overrides
Seq.startsWith

override def endsWith[B](that : Seq[B]) : Boolean
Returns
true if this sequence end with that sequence
See Also
String.endsWith
Overrides
Seq.endsWith

override def indexOf[B >: A](that : Seq[B]) : Int
Searches for the argument sequence in the receiver object, returning the smallest index where a match occurs. If the receiver object, this, is an infinite sequence this method will not terminate if there is no match. Similarly, if the both the receiver object and the argument, that are infinite sequences this method will not terminate. Because both the receiver object and the argument can both potentially be an infinite sequences, we do not attempt to use an optimized searching algorithm. Therefore, the running time will be proportional to the length of the receiver object and the argument. Subclasses and traits can potentially provide an optimized implementation.
Returns
-1 if that not contained in this, otherwise the smallest index where that is found.
See Also
String.indexOf
Overrides
Seq.indexOf

override def containsSlice[B](that : Seq[B]) : Boolean
Is that a slice in this?
Overrides
Seq.containsSlice