blob: f5e8d545771bb53889d3aba3ef68e541472ec8a0 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
/* __ *\
** ________ ___ / / ___ Scala API **
** / __/ __// _ | / / / _ | (c) 2003, LAMP/EPFL **
** __\ \/ /__/ __ |/ /__/ __ | **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
** $Id$
\* */
package scala;
/** Class <code>Seq[A]</code> represents finite sequences of elements
* of type <code>A</code>.
*
* @author Martin Odersky
* @author Matthias Zenger
* @version 1.0, 16/07/2003
*/
trait Seq[+A] with PartialFunction[Int, A] with Iterable[A] {
/** Returns the length of the sequence.
*
* @return the sequence length.
*/
def length: Int;
/** Is this partial function defined for the index <code>x</code>?
*
* @return true, iff <code>x</code> is a legal sequence index.
*/
def isDefinedAt(x: Int): Boolean = (x >= 0) && (x < length);
/** Customizes the <code>toString</code> method.
*
* @return a string representation of this sequence.
*/
override def toString() = {
val iter = elements;
var res = "Seq(";
if (iter.hasNext) {
res = res + iter.next;
while (iter.hasNext)
res = res + ", " + iter.next;
}
res + ")"
}
}
|