scala.collection.immutable

Stream

object Stream extends SeqFactory[Stream[A][A]]

The object Stream provides helper functions to manipulate streams.

Inherits

  1. SeqFactory
  2. TraversableFactory
  3. GenericCompanion
  4. AnyRef
  5. Any

Type Members

  1. type Coll = CC[_]

    The underlying collection type with unknown element type

    The underlying collection type with unknown element type

    definition classes: GenericCompanion
  2. class Cons[+A] extends Stream[A]

    A lazy cons cell, from which streams are built

  3. class ConsWrapper[A] extends AnyRef

    A wrapper class that adds #:: for cons and #::: for concat as operations to streams

  4. class GenericCanBuildFrom[A] extends CanBuildFrom[CC[_], A, CC[A]]

    A generic implementation of the CanBuildFrom trait, which forwards all calls to apply(from) to the genericBuilder methof of collection from, and which forwards all calls of apply() to the newBuilder method of this factory

  5. class StreamBuilder[A] extends LazyBuilder[A, Stream[A]]

    A builder for streams

  6. class StreamCanBuildFrom[A] extends GenericCanBuildFrom[A]

    The factory for streams

Value Members

  1. object #:: extends AnyRef

    An extractor that allows to pattern match streams with #::

  2. object Empty extends Stream[Nothing]

  3. def apply[A](xs: A*): Stream[A]

    A stream consisting of given elements @return a new collection with elements elems

    A stream consisting of given elements @return a new collection with elements elems

    definition classes: StreamGenericCompanion
  4. def canBuildFrom[A]: CanBuildFrom[scala.collection.immutable.Stream[_], A, Stream[A]]

  5. def concat[A](xs: Iterator[Stream[A]]): Stream[A]

    The concatenation of all streams returned by an iterator

    The concatenation of all streams returned by an iterator

  6. def concat[A](xs: Iterable[Stream[A]]): Stream[A]

    The concatenation of a sequence of streams

    The concatenation of a sequence of streams

  7. def concat[A](xss: Traversable[A]*): CC[A]

    Concatenates all argument collections into a single collection

    Concatenates all argument collections into a single collection.

    xss

    the collections that are to be concatenated.

    returns

    the concatenation of all the collections.

    definition classes: TraversableFactory
  8. object cons extends AnyRef

    An alternative way of building and matching Streams using Stream

  9. def consWrapper[A](stream: ⇒ Stream[A]): ConsWrapper[A]

    A wrapper method that adds #:: for cons and #::: for concat as operations to streams

    A wrapper method that adds #:: for cons and #::: for concat as operations to streams.

    attributes: implicit
  10. def const[A](elem: A): Stream[A]

    Create an infinite stream containing the given element

    Create an infinite stream containing the given element.

    elem

    the element composing the resulting stream

    returns

    the stream containing an infinite number of elem

  11. def continually[A](elem: ⇒ A): Stream[A]

    Create an infinite stream containing the given element expression (which is computed for each occurrence)

    Create an infinite stream containing the given element expression (which is computed for each occurrence)

    elem

    the element composing the resulting stream

    returns

    the stream containing an infinite number of elem

  12. def empty[A]: Stream[A]

    The empty stream

    The empty stream

    definition classes: StreamGenericCompanion
  13. def equals(arg0: Any): Boolean

    This method is used to compare the receiver object (this) with the argument object (arg0) for equivalence

    This method is used to compare the receiver object (this) with the argument object (arg0) for equivalence.

    The default implementations of this method is an equivalence relation:

    • It is reflexive: for any instance x of type Any, x.equals(x) should return true.
    • It is symmetric: for any instances x and y of type Any, x.equals(y) should return true if and only if y.equals(x) returns true.
    • It is transitive: for any instances x, y, and z of type AnyRef if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true.

    If you override this method, you should verify that your implementation remains an equivalence relation. Additionally, when overriding this method it is often necessary to override hashCode to ensure that objects that are "equal" (o1.equals(o2) returns true) hash to the same Int (o1.hashCode.equals(o2.hashCode)).

    arg0

    the object to compare against this object for equality.

    returns

    true if the receiver object is equivalent to the argument; false otherwise.

    definition classes: AnyRef ⇐ Any
  14. def fill[A](n: Int)(elem: ⇒ A): Stream[A]

    Produces a collection containing the results of some element computation a number of times

    Produces a collection containing the results of some element computation a number of times.

    n

    the number of elements contained in the collection.

    elem

    the element computation

    returns

    A collection that contains the results of n evaluations of elem.

    definition classes: StreamTraversableFactory
  15. def fill[A](n1: Int, n2: Int, n3: Int, n4: Int, n5: Int)(elem: ⇒ A): CC[CC[CC[CC[CC[A]]]]]

    Produces a five-dimensional collection containing the results of some element computation a number of times

    Produces a five-dimensional collection containing the results of some element computation a number of times.

    n1

    the number of elements in the 1st dimension

    n2

    the number of elements in the 2nd dimension

    n3

    the number of elements in the 3nd dimension

    n4

    the number of elements in the 4th dimension

    n5

    the number of elements in the 5th dimension

    elem

    the element computation

    returns

    A collection that contains the results of n1 x n2 x n3 x n4 x n5 evaluations of elem.

    definition classes: TraversableFactory
  16. def fill[A](n1: Int, n2: Int, n3: Int, n4: Int)(elem: ⇒ A): CC[CC[CC[CC[A]]]]

    Produces a four-dimensional collection containing the results of some element computation a number of times

    Produces a four-dimensional collection containing the results of some element computation a number of times.

    n1

    the number of elements in the 1st dimension

    n2

    the number of elements in the 2nd dimension

    n3

    the number of elements in the 3nd dimension

    n4

    the number of elements in the 4th dimension

    elem

    the element computation

    returns

    A collection that contains the results of n1 x n2 x n3 x n4 evaluations of elem.

    definition classes: TraversableFactory
  17. def fill[A](n1: Int, n2: Int, n3: Int)(elem: ⇒ A): CC[CC[CC[A]]]

    Produces a three-dimensional collection containing the results of some element computation a number of times

    Produces a three-dimensional collection containing the results of some element computation a number of times.

    n1

    the number of elements in the 1st dimension

    n2

    the number of elements in the 2nd dimension

    n3

    the number of elements in the 3nd dimension

    elem

    the element computation

    returns

    A collection that contains the results of n1 x n2 x n3 evaluations of elem.

    definition classes: TraversableFactory
  18. def fill[A](n1: Int, n2: Int)(elem: ⇒ A): CC[CC[A]]

    Produces a two-dimensional collection containing the results of some element computation a number of times

    Produces a two-dimensional collection containing the results of some element computation a number of times.

    n1

    the number of elements in the 1st dimension

    n2

    the number of elements in the 2nd dimension

    elem

    the element computation

    returns

    A collection that contains the results of n1 x n2 evaluations of elem.

    definition classes: TraversableFactory
  19. def from(start: Int): Stream[Int]

    Create an infinite stream starting at start and incrementing by 1

    Create an infinite stream starting at start and incrementing by 1.

    start

    the start value of the stream

    returns

    the stream starting at value start.

  20. def from(start: Int, step: Int): Stream[Int]

    Create an infinite stream starting at start and incrementing by step step

    Create an infinite stream starting at start and incrementing by step step

    start

    the start value of the stream

    step

    the increment value of the stream

    returns

    the stream starting at value start.

  21. def fromIterator[A](it: Iterator[A]): Stream[A]

    A stream containing all elements of a given iterator, in the order they are produced

    A stream containing all elements of a given iterator, in the order they are produced.

    it

    The iterator producing the stream's elements

  22. def hashCode(): Int

    Returns a hash code value for the object

    Returns a hash code value for the object.

    The default hashing algorithm is platform dependent.

    Note that it is allowed for two objects to have identical hash codes (o1.hashCode.equals(o2.hashCode)) yet not be equal (o1.equals(o2) returns false). A degenerate implementation could always return 0. However, it is required that if two objects are equal (o1.equals(o2) returns true) that they have identical hash codes (o1.hashCode.equals(o2.hashCode)). Therefore, when overriding this method, be sure to verify that the behavior is consistent with the equals method.

    definition classes: AnyRef ⇐ Any
  23. def iterate[A](start: A, len: Int)(f: (A) ⇒ A): Stream[A]

    Produces a collection containing repeated applications of a function to a start value

    Produces a collection containing repeated applications of a function to a start value.

    start

    the start value of the collection

    len

    the number of elements contained inthe collection

    f

    the function that's repeatedly applied

    returns

    a collection with len values in the sequence start, f(start), f(f(start)), ...

    definition classes: StreamTraversableFactory
  24. def iterate[A](start: A)(f: (A) ⇒ A): Stream[A]

    An infinite stream that repeatedly applies a given function to a start value

    An infinite stream that repeatedly applies a given function to a start value.

    start

    the start value of the stream

    f

    the function that's repeatedly applied

    returns

    the stream returning the infinite sequence of values start, f(start), f(f(start)), ...

  25. var lazy_::: #::

  26. def make[A](n: Int, elem: A): Stream[A]

    Create a stream containing several copies of an element

    Create a stream containing several copies of an element.

    n

    the length of the resulting stream

    elem

    the element composing the resulting stream

    returns

    the stream composed of n elements all equal to elem

  27. def newBuilder[A]: Builder[A, Stream[A]]

    Creates a new builder for a stream

    Creates a new builder for a stream

    definition classes: StreamGenericCompanion
  28. def range(start: Int, end: Int, step: (Int) ⇒ Int): Stream[Int]

    Create a stream with element values vn+1 = step(vn) where v0 = start and elements are in the range between start (inclusive) and end (exclusive)

    Create a stream with element values vn+1 = step(vn) where v0 = start and elements are in the range between start (inclusive) and end (exclusive)

    start

    the start value of the stream

    end

    the end value of the stream

    step

    the increment function of the stream, must be monotonically increasing or decreasing

    returns

    the stream starting at value start.

  29. def range(start: Int, end: Int, step: Int): Stream[Int]

    Produces a collection containing equally spaced values in some integer interval

    Produces a collection containing equally spaced values in some integer interval.

    start

    the start value of the collection

    end

    the end value of the collection (the first value NOT contained)

    step

    the difference between successive elements of the collection (must be positive or negative)

    returns

    a collection with values start, start + step, ... up to, but excluding end

    definition classes: StreamTraversableFactory
  30. def range(start: Int, end: Int): CC[Int]

    Produces a collection containing a sequence of increasing of integers

    Produces a collection containing a sequence of increasing of integers.

    end

    the end value of the collection (the first value NOT contained)

    returns

    a collection with values start, start + 1, ..., end - 1

    definition classes: TraversableFactory
  31. def tabulate[A](n: Int)(f: (Int) ⇒ A): Stream[A]

    Produces a collection containing values of a given function over a range of integer values starting from 0

    Produces a collection containing values of a given function over a range of integer values starting from 0.

    n

    The number of elements in the collection

    f

    The function computing element values

    returns

    A collection consisting of elements f(0), ..., f(n -1)

    definition classes: StreamTraversableFactory
  32. def tabulate[A](n1: Int, n2: Int, n3: Int, n4: Int, n5: Int)(f: (Int, Int, Int, Int, Int) ⇒ A): CC[CC[CC[CC[CC[A]]]]]

    Produces a five-dimensional collection containing values of a given function over ranges of integer values starting from 0

    Produces a five-dimensional collection containing values of a given function over ranges of integer values starting from 0.

    n1

    the number of elements in the 1st dimension

    n2

    the number of elements in the 2nd dimension

    n3

    the number of elements in the 3nd dimension

    n4

    the number of elements in the 4th dimension

    n5

    the number of elements in the 5th dimension

    f

    The function computing element values

    returns

    A collection consisting of elements f(i1, i2, i3, i4, i5) for 0 <= i1 < n1, 0 <= i2 < n2, 0 <= i3 < n3, 0 <= i4 < n4, and 0 <= i5 < n5.

    definition classes: TraversableFactory
  33. def tabulate[A](n1: Int, n2: Int, n3: Int, n4: Int)(f: (Int, Int, Int, Int) ⇒ A): CC[CC[CC[CC[A]]]]

    Produces a four-dimensional collection containing values of a given function over ranges of integer values starting from 0

    Produces a four-dimensional collection containing values of a given function over ranges of integer values starting from 0.

    n1

    the number of elements in the 1st dimension

    n2

    the number of elements in the 2nd dimension

    n3

    the number of elements in the 3nd dimension

    n4

    the number of elements in the 4th dimension

    f

    The function computing element values

    returns

    A collection consisting of elements f(i1, i2, i3, i4) for 0 <= i1 < n1, 0 <= i2 < n2, 0 <= i3 < n3, and 0 <= i4 < n4.

    definition classes: TraversableFactory
  34. def tabulate[A](n1: Int, n2: Int, n3: Int)(f: (Int, Int, Int) ⇒ A): CC[CC[CC[A]]]

    Produces a three-dimensional collection containing values of a given function over ranges of integer values starting from 0

    Produces a three-dimensional collection containing values of a given function over ranges of integer values starting from 0.

    n1

    the number of elements in the 1st dimension

    n2

    the number of elements in the 2nd dimension

    n3

    the number of elements in the 3nd dimension

    f

    The function computing element values

    returns

    A collection consisting of elements f(i1, i2, i3) for 0 <= i1 < n1, 0 <= i2 < n2, and 0 <= i3 < n3.

    definition classes: TraversableFactory
  35. def tabulate[A](n1: Int, n2: Int)(f: (Int, Int) ⇒ A): CC[CC[A]]

    Produces a two-dimensional collection containing values of a given function over ranges of integer values starting from 0

    Produces a two-dimensional collection containing values of a given function over ranges of integer values starting from 0.

    n1

    the number of elements in the 1st dimension

    n2

    the number of elements in the 2nd dimension

    f

    The function computing element values

    returns

    A collection consisting of elements f(i1, i2) for 0 <= i1 < n1 and 0 <= i2 < n2.

    definition classes: TraversableFactory
  36. def toString(): String

    Returns a string representation of the object

    Returns a string representation of the object.

    The default representation is platform dependent.

    definition classes: AnyRef ⇐ Any
  37. def unapplySeq[A](x: CC[A]): Some[CC[A]]

    This method is called in a pattern match { case Seq(

    This method is called in a pattern match { case Seq(...) => }.

    x

    the selector value

    returns

    sequence wrapped in an option, if this is a Seq, otherwise none

    definition classes: SeqFactory