scala.collection.JavaConversions
A flexible iterator for transforming an Iterator[A]
into an
Iterator[Seq[A]], with configurable sequence size, step, and
strategy for dealing with elements which don't fit evenly
[use case] Concatenates this iterator with another
Concatenates this iterator with another
Applies a binary operator to a start value and all values produced by this iterator, going left to right
Applies a binary operator to a start value and all values produced by this iterator, going left to right.
Note: /:
is alternate syntax for foldLeft
; z /: it
is the same as it foldLeft z
.
Note: will not terminate for infinite iterators.
the result type of the binary operator.
the start value.
the binary operator.
the result of inserting op
between consecutive values produced by this iterator
going left to right with the start value z
on the left:
{{{
op(...op(z, x1), x2, ..., xn)
}}}
where x,,1,,, ..., x,,n,,
are the values produced by this iterator.
Applies a binary operator to all values produced by this iterator and a start value, going right to left
Applies a binary operator to all values produced by this iterator and a start value, going right to left.
Note: :\
is alternate syntax for foldRight
; it :\ z
is the same as it foldRight z
.
Note: will not terminate for infinite iterators.
the result type of the binary operator.
the start value.
the binary operator.
the result of inserting op
between consecutive values produced by this iterator
going right to left with the start value z
on the right:
{{{
op(x1, op(x2, ... op(xn, z)...))
}}}
where x,,1,,, ..., x,,n,,
are the values produced by this iterator.
Appends all values produced by this iterator to a string builder
Appends all values produced by this iterator to a string builder using a separator string
Appends all values produced by this iterator to a string builder using a separator string.
The written text consists of the string representations (w.r.t. the method toString
)
of all values produced by this iterator, separated by the string sep
.
the separator string.
the string builder b
to which elements were appended.
Appends all values produced by this iterator to a string builder using start, end, and separator strings
Appends all values produced by this iterator to a string builder using start, end, and separator strings.
The written text begins with the string start
and ends with the string
end
. Inside, the string representations (w.r.t. the method toString
)
of all values produced by this iterator are separated by the string sep
.
the starting string.
the separator string.
the ending string.
the string builder b
to which elements were appended.
Returns a new iterator that first yields the elements of this
iterator followed by the elements provided by iterator that
Creates a buffered iterator from this iterator
A method that should be called from every well-designed equals method that is open to be overridden in a subclass
A method that should be called from every well-designed equals method that is open to be overridden in a subclass. See Programming in Scala, Chapter 28 for discussion and design.
Collect elements into a seq
Tests whether this iterator contains a given value as an element
[use case] Copies values produced by this iterator to an array
Copies values produced by this iterator to an array.
Fills the given array xs
with values produced by this iterator.
Copying will stop once either the end of the current iterator is reached,
or the end of the array is reached.
the array to fill.
Copies values produced by this iterator to an array
Copies values produced by this iterator to an array.
Fills the given array xs
with values produced by this iterator.
Copying will stop once either the end of the current iterator is reached,
or the end of the array is reached.
Note: will not terminate for infinite iterators.
the type of the elements of the array.
the array to fill.
[use case] Copies values produced by this iterator to an array
Copies values produced by this iterator to an array.
Fills the given array xs
with values produced by this iterator, after skipping start
values.
Copying will stop once either the end of the current iterator is reached,
or the end of the array is reached.
the array to fill.
the starting index.
Copies values produced by this iterator to an array
Copies values produced by this iterator to an array.
Fills the given array xs
with values produced by this iterator, after skipping start
values.
Copying will stop once either the end of the current iterator is reached,
or the end of the array is reached.
Note: will not terminate for infinite iterators.
the type of the elements of the array.
the array to fill.
the starting index.
[use case] Copies selected values produced by this iterator to an array
Copies selected values produced by this iterator to an array.
Fills the given array xs
with at most len
values produced by this
iterator, after skipping start
values.
Copying will stop once either the end of the current iterator is reached,
or the end of the array is reached, or len
elements have been copied.
the array to fill.
the starting index.
the maximal number of elements to copy.
Copies selected values produced by this iterator to an array
Copies selected values produced by this iterator to an array.
Fills the given array xs
with at most len
values produced by this
iterator, after skipping start
values.
Copying will stop once either the end of the current iterator is reached,
or the end of the array is reached, or len
elements have been copied.
Note: will not terminate for infinite iterators.
the type of the elements of the array.
the array to fill.
the starting index.
the maximal number of elements to copy.
Copies all values produced by this iterator to a buffer
Returns a counted iterator from this iterator
Advances this iterator past the first n elements, or the length of the iterator, whichever is smaller
Skips longest sequence of elements of this iterator which satisfy given
predicate p
, and returns an iterator of the remaining elements
Creates two new iterators that both iterate over the same elements as this iterator (in the same order)
The equality method defined in AnyRef
The equality method defined in AnyRef
.
Tests whether a predicate holds for some of the values produced by this iterator
Tests whether a predicate holds for some of the values produced by this iterator.
Note: may not terminate for infinite iterators.
the predicate used to test elements.
true
if the given predicate p
holds for some of the values
produced by this iterator, otherwise false
.
Returns an iterator over all the elements of this iterator that
satisfy the predicate p
Returns an iterator over all the elements of this iterator that
satisfy the predicate p
. The order of the elements
is preserved.
the predicate used to test values.
an iterator which produces those values of this iterator which satisfy the predicate p
.
Creates an iterator over all the elements of this iterator which do not satisfy a predicate p
Finds the first value produced by the iterator satisfying a predicate, if any
Finds the first value produced by the iterator satisfying a predicate, if any.
Note: may not terminate for infinite iterators.
the predicate used to test values.
an option value containing the first value produced by the iterator that satisfies
predicate p
, or None
if none exists.
Returns index of the first element satisfying a predicate, or -1
Creates a new iterator by applying a function to all values produced by this iterator and concatenating the results
Creates a new iterator by applying a function to all values produced by this iterator and concatenating the results.
the function to apply on each element.
the iterator resulting from applying the given iterator-valued function
f
to each value produced by this iterator and concatenating the results.
Applies a binary operator to a start value and all values produced by this iterator, going left to right
Applies a binary operator to a start value and all values produced by this iterator, going left to right.
Note: will not terminate for infinite iterators.
the result type of the binary operator.
the start value.
the binary operator.
the result of inserting op
between consecutive values produced by this iterator
going left to right with the start value z
on the left:
{{{
op(...op(z, x1), x2, ..., xn)
}}}
where x,,1,,, ..., x,,n,,
are the values produced by this iterator.
Applies a binary operator to all values produced by this iterator and a start value, going right to left
Applies a binary operator to all values produced by this iterator and a start value, going right to left.
Note: will not terminate for infinite iterators.
the result type of the binary operator.
the start value.
the binary operator.
the result of inserting op
between consecutive values produced by this iterator
going right to left with the start value z
on the right:
{{{
op(x1, op(x2, ... op(xn, z)...))
}}}
where x,,1,,, ..., x,,n,,
are the values produced by this iterator.
Tests whether a predicate holds for all values produced by this iterator
Tests whether a predicate holds for all values produced by this iterator.
Note: may not terminate for infinite iterators.
the predicate used to test elements.
true
if the given predicate p
holds for all values
produced by this iterator, otherwise false
.
[use case] Applies a function f
to all values produced by this iterator
Applies a function f
to all values produced by this iterator.
the function that is applied for its side-effect to every element.
The result of function f
is discarded.
Applies a function f
to all values produced by this iterator
Applies a function f
to all values produced by this iterator.
the type parameter describing the result of function f
.
This result will always be ignored. Typically U
is Unit
,
but this is not necessary.
the function that is applied for its side-effect to every element.
The result of function f
is discarded.
Returns an iterator which groups this iterator into fixed size blocks
Returns an iterator which groups this iterator into fixed size blocks. Example usages:
// Returns List(List(1, 2, 3), List(4, 5, 6), List(7))) (1 to 7).iterator grouped 3 toList // Returns List(List(1, 2, 3), List(4, 5, 6)) (1 to 7).iterator grouped 3 withPartial false toList // Returns List(List(1, 2, 3), List(4, 5, 6), List(7, 20, 25) // Illustrating that withPadding's argument is by-name. val it2 = Iterator.iterate(20)(_ + 5) (1 to 7).iterator grouped 3 withPadding it2.next toList
Tests whether this iterator can provide another element
Tests whether this iterator can provide another element.
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.
Returns the index of the first occurence of the specified object in this iterable object
Returns the index of the first occurence of the specified object in this iterable object.
Note: may not terminate for infinite iterators.
element to search for.
the index of the first occurence of elem
in the values produced by this iterator,
or -1 if such an element does not exist until the end of the iterator is reached.
Returns the index of the first produced value satisfying a predicate, or -1
Returns the index of the first produced value satisfying a predicate, or -1.
Note: may not terminate for infinite iterators.
the predicate to test values
the index of the first produced value satisfying p
,
or -1 if such an element does not exist until the end of the iterator is reached.
Returns the number of elements in this iterator
Creates a new iterator that maps all produced values of this iterator to new values using a transformation function
Creates a new iterator that maps all produced values of this iterator to new values using a transformation function.
the transformation function
a new iterator which transformes every value produced by this
iterator by applying the functon f
to it.
Displays all values produced by this iterator in a string
Displays all values produced by this iterator in a string using a separator string
Displays all values produced by this iterator in a string using a separator string.
the separator string.
a string representation of this iterator. In the resulting string
the string representations (w.r.t. the method toString
)
of all values produced by this iterator are separated by the string sep
.
Displays all values produced by this iterator in a string using start, end, and separator strings
Displays all values produced by this iterator in a string using start, end, and separator strings.
the starting string.
the separator string.
the ending string.
a string representation of this iterator. The resulting string
begins with the string start
and ends with the string
end
. Inside, the string representations (w.r.t. the method toString
)
of all values produced by this iterator are separated by the string sep
.
Produces the next element of this iterator
Produces the next element of this iterator.
[use case] Appends an element value to this iterator until a given target length is reached
Appends an element value to this iterator until a given target length is reached.
the target length
the padding value
a new iterator consisting of producing all values of this iterator,
followed by the minimal number of occurrences of elem
so
that the number of produced values is at least len
.
Appends an element value to this iterator until a given target length is reached
Appends an element value to this iterator until a given target length is reached.
the target length
the padding value
a new iterator consisting of producing all values of this iterator,
followed by the minimal number of occurrences of elem
so
that the number of produced values is at least len
.
Creates an iterator by transforming values produced by this iterator with a partial function, dropping those values for which the partial function is not defined
Creates an iterator by transforming values produced by this iterator with a partial function, dropping those values for which the partial function is not defined.
the partial function which filters and maps the iterator.
a new iterator which yields each value x
produced by this iterator for
which pf
is defined the image pf(x)
.
Partitions this iterator in two iterators according to a predicate
Partitions this iterator in two iterators according to a predicate.
the predicate on which to partition
a pair of iterators: the iterator that satisfies the predicate
p
and the iterator that does not.
The relative order of the elements in the resulting iterators
is the same as in the original iterator.
Returns this iterator with patched values
return k for a product A(x_1,
return k for a product A(x_1,...,x_k)
for a product A(x_1,
for a product A(x_1,...,x_k)
, returns x_(n+1)
for 0 <= n < k
An iterator that returns all fields of this product
By default the empty string
By default the empty string. Implementations may override this method in order to prepend a string prefix to the result of the toString methods.
Fills the given array xs
with the elements of
this sequence starting at position start
Applies a binary operator to all values produced by this iterator, going left to right
Applies a binary operator to all values produced by this iterator, going left to right.
Note: will not terminate for infinite iterators.
the result type of the binary operator.
the binary operator.
the result of inserting op
between consecutive values produced by this iterator
going left to right:
{{{
op(...(op(x1, x2), ... ) , xn)
}}}
where x,,1,,, ..., x,,n,,
are the values produced by this iterator.
Optionally applies a binary operator to all values produced by this iterator, going left to right
Optionally applies a binary operator to all values produced by this iterator, going left to right.
Note: will not terminate for infinite iterators.
the result type of the binary operator.
the binary operator.
an option value containing the result of reduceLeft(op)
is this iterator is nonempty,
None
otherwise.
Applies a binary operator to all values produced by this iterator, going right to left
Applies a binary operator to all values produced by this iterator, going right to left.
Note: will not terminate for infinite iterators.
the result type of the binary operator.
the binary operator.
the result of inserting op
between consecutive values produced by this iterator
going right to left:
{{{
op(x1, op(x2, ..., op(xn-1, xn)...))
}}}
where x,,1,,, ..., x,,n,,
are the values produced by this iterator.
Optionally applies a binary operator to all values produced by this iterator, going right to left
Optionally applies a binary operator to all values produced by this iterator, going right to left.
Note: will not terminate for infinite iterators.
the result type of the binary operator.
the binary operator.
an option value containing the result of reduceRight(op)
is this iterator is nonempty,
None
otherwise.
Tests if another iterator produces the same valeus as this one
Creates an iterator returning an interval of the values produced by this iterator
Creates an iterator returning an interval of the values produced by this iterator.
the index of the first element in this iterator which forms part of the slice.
the index of the first element following the slice.
an iterator which advances this iterator past the first from
elements using drop
,
and then takes until - from
elements, using take
.
Returns an iterator which presents a "sliding window" view of another iterator
Returns an iterator which presents a "sliding window" view of another iterator. The first argument is the window size, and the second is how far to advance the window on each iteration; defaults to 1. Example usages:
// Returns List(List(1, 2, 3), List(2, 3, 4), List(3, 4, 5)) (1 to 5).iterator.sliding(3).toList // Returns List(List(1, 2, 3, 4), List(4, 5)) (1 to 5).iterator.sliding(4, 3).toList // Returns List(List(1, 2, 3, 4)) (1 to 5).iterator.sliding(4, 3).withPartial(false).toList // Returns List(List(1, 2, 3, 4), List(4, 5, 20, 25)) // Illustrating that withPadding's argument is by-name. val it2 = Iterator.iterate(20)(_ + 5) (1 to 5).iterator.sliding(4, 3).withPadding(it2.next).toList
Selects first n values of this iterator
Takes longest prefix of values produced by this iterator that satisfy a predicate
Takes longest prefix of values produced by this iterator that satisfy a predicate.
The predicate used to test elements.
An iterator returning the values produced by this iterator, until
this iterator produces a value that does not satisfy
the predicate p
.
Traverses this iterator and returns all produced values in a list
Traverses this iterator and returns all produced values in a sequence
Lazily wraps a Stream around this iterator so its values are memoized
Converts this iterator to a string
Creates an iterator over all the elements of this iterator that
satisfy the predicate p
Creates an iterator over all the elements of this iterator that
satisfy the predicate p
. The order of the elements
is preserved.
the predicate used to test values.
an iterator which produces those values of this iterator which satisfy the predicate p
.
Creates an iterator formed from this iterator and another iterator by combining corresponding values in pairs
Creates an iterator formed from this iterator and another iterator by combining corresponding values in pairs. If one of the two iterators is longer than the other, its remaining elements are ignored.
The iterator providing the second half of each result pair
a new iterator containing pairs consisting of
corresponding elements of this iterator and that
. The number
of elements returned by the new iterator is the
minimum of the number of elements returned by this
iterator and that
.
[use case] Creates an iterator formed from this iterator and another iterator by combining corresponding elements in pairs
Creates an iterator formed from this iterator and another iterator by combining corresponding elements in pairs. If one of the two iterators is shorter than the other, placeholder elements are used to extend the shorter iterator to the length of the longer.
iterator that
may have a different length
as the self iterator.
element thisElem
is used to fill up the
resulting iterator if the self iterator is shorter than
that
element thatElem
is used to fill up the
resulting iterator if that
is shorter than
the self iterator
a new iterator containing pairs consisting of
corresponding values of this iterator and that
. The length
of the returned iterator is the maximum of the lengths of this iterator and that
.
If this iterator is shorter than that
, thisElem
values are used to pad the result.
If that
is shorter than this iterator, thatElem
values are used to pad the result.
Creates an iterator formed from this iterator and another iterator by combining corresponding elements in pairs
Creates an iterator formed from this iterator and another iterator by combining corresponding elements in pairs. If one of the two iterators is shorter than the other, placeholder elements are used to extend the shorter iterator to the length of the longer.
iterator that
may have a different length
as the self iterator.
element thisElem
is used to fill up the
resulting iterator if the self iterator is shorter than
that
element thatElem
is used to fill up the
resulting iterator if that
is shorter than
the self iterator
a new iterator containing pairs consisting of
corresponding values of this iterator and that
. The length
of the returned iterator is the maximum of the lengths of this iterator and that
.
If this iterator is shorter than that
, thisElem
values are used to pad the result.
If that
is shorter than this iterator, thatElem
values are used to pad the result.
Creates an iterator that pairs each element produced by this iterator with its index, counting from 0