Skip to content
This repository
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 65 lines (51 sloc) 2.52 kb
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 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
/* __ *\
** ________ ___ / / ___ Scala API **
** / __/ __// _ | / / / _ | (c) 2003-2013, LAMP/EPFL **
** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
\* */

package scala.collection.parallel


import scala.collection.Seq


/** A precise splitter (or a precise split iterator) can be split into arbitrary number of splitters
* that traverse disjoint subsets of arbitrary sizes.
*
* Implementors might want to override the parameterless `split` method for efficiency.
*
* @tparam T type of the elements this splitter traverses
*
* @since 2.9
* @author Aleksandar Prokopec
*/
trait PreciseSplitter[+T] extends Splitter[T] {

  /** Splits the splitter into disjunct views.
*
* This overloaded version of the `split` method is specific to precise splitters.
* It returns a sequence of splitters, each iterating some subset of the
* elements in this splitter. The sizes of the subsplitters in the partition is equal to
* the size in the corresponding argument, as long as there are enough elements in this
* splitter to split it that way.
*
* If there aren't enough elements, a zero element splitter is appended for each additional argument.
* If there are additional elements, an additional splitter is appended at the end to compensate.
*
* For example, say we have a splitter `ps` with 100 elements. Invoking:
* {{{
* ps.split(50, 25, 25, 10, 5)
* }}}
* will return a sequence of five splitters, last two views being empty. On the other hand, calling:
* {{{
* ps.split(50, 40)
* }}}
* will return a sequence of three splitters, last of them containing ten elements.
*
* '''Note:''' this method actually invalidates the current splitter.
*
* Unlike the case with `split` found in splitters, views returned by this method can be empty.
*
* @param sizes the sizes used to split this split iterator into iterators that traverse disjunct subsets
* @return a sequence of disjunct subsequence iterators of this parallel iterator
*/
  def psplit(sizes: Int*): Seq[PreciseSplitter[T]]

  def split: Seq[PreciseSplitter[T]]

}





Something went wrong with that request. Please try again.