Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 59 lines (53 sloc) 2.492 kb
5749084 @axel22 Updated docs. No review.
axel22 authored
1 /* __ *\
2 ** ________ ___ / / ___ Scala API **
807dbe5 @heathermiller Brings all copyrights (in comments) up-to-date, from 2011/12 to 2013
heathermiller authored
3 ** / __/ __// _ | / / / _ | (c) 2003-2013, LAMP/EPFL **
5749084 @axel22 Updated docs. No review.
axel22 authored
4 ** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
5 ** /____/\___/_/ |_/____/_/ | | **
6 ** |/ **
7 \* */
8
9923b97 @axel22 Moved parallel collections to library dir, chan...
axel22 authored
9 package scala.collection.parallel
10
f82acf5 @paulp Reducing the sbt launcher footprint by eliminat...
paulp authored
11 import scala.collection.{ Seq, Iterator }
9923b97 @axel22 Moved parallel collections to library dir, chan...
axel22 authored
12
13 /** A splitter (or a split iterator) can be split into more splitters that traverse over
14 * disjoint subsets of elements.
15 *
5749084 @axel22 Updated docs. No review.
axel22 authored
16 * @tparam T type of the elements this splitter traverses
9923b97 @axel22 Moved parallel collections to library dir, chan...
axel22 authored
17 *
5749084 @axel22 Updated docs. No review.
axel22 authored
18 * @since 2.9
19 * @author Aleksandar Prokopec
9923b97 @axel22 Moved parallel collections to library dir, chan...
axel22 authored
20 */
21 trait Splitter[+T] extends Iterator[T] {
22
23 /** Splits the iterator into a sequence of disjunct views.
24 *
25 * Returns a sequence of split iterators, each iterating over some subset of the
26 * elements in the collection. These subsets are disjoint and should be approximately
27 * equal in size. These subsets are not empty, unless the iterator is empty in which
5749084 @axel22 Updated docs. No review.
axel22 authored
28 * case this method returns a sequence with a single empty iterator. If the splitter has
29 * more than two elements, this method will return two or more splitters.
9923b97 @axel22 Moved parallel collections to library dir, chan...
axel22 authored
30 *
5749084 @axel22 Updated docs. No review.
axel22 authored
31 * Implementors are advised to keep this partition relatively small - two splitters are
9923b97 @axel22 Moved parallel collections to library dir, chan...
axel22 authored
32 * already enough when partitioning the collection, although there may be a few more.
33 *
5749084 @axel22 Updated docs. No review.
axel22 authored
34 * '''Note:''' this method actually invalidates the current splitter.
9923b97 @axel22 Moved parallel collections to library dir, chan...
axel22 authored
35 *
36 * @return a sequence of disjunct iterators of the collection
37 */
38 def split: Seq[Splitter[T]]
eeb70cd @axel22 Refactoring certain tasks to accept empty split...
axel22 authored
39 /*
40 * '''Note:''' splitters in this sequence may actually be empty and it can contain a splitter
41 * which iterates over the same elements as the original splitter AS LONG AS calling `split`
42 * a finite number of times on the resulting splitters eventually returns a nontrivial partition.
43 *
44 * Note that the docs contract above yields implementations which are a subset of implementations
45 * defined by this fineprint.
46 *
47 * The rationale behind this is best given by the following example:
48 * try splitting an iterator over a linear hash table.
49 */
9923b97 @axel22 Moved parallel collections to library dir, chan...
axel22 authored
50 }
51
23c6d4f @axel22 Adding immutable parallel hashsets.
axel22 authored
52 object Splitter {
53 def empty[T]: Splitter[T] = new Splitter[T] {
54 def hasNext = false
55 def next = Iterator.empty.next
56 def split = Seq(this)
57 }
58 }
Something went wrong with that request. Please try again.