std/iteration
Lazy pipelines: the two traits everything is pulled through, the stages between them, and the collectors that end
one. The stage types themselves are not exported - map and filter answer an Iterate<Item>, and which type
carries it is nobody's business.
Stage is the same middle piece written once for the pull side here and the push side of std/stream
(see docs/design/STREAMS.md). It lives here and not there because it is synchronous and because what it turns into what
is an Accumulator - both words of this package - which also keeps the dependency one-way.
Modules
std/iteration/collectorsCollectors decide where the values of a pipeline end up:std/iteration/concatenateOne step, and the reason the whole package needs it: putting many short texts together into one long one.std/iteration/iterationThe pull side of a pipeline: [Iterator], a cursor with one method, and [Iterate], anything that can hand one out.std/iteration/stageA stage is the middle of a pipeline, written once for both worlds: it turns anAccumulator<Output, Final>into anAccumulator<Input, Final>, a transducer in Clojure's word.std/iteration/stagedThe synchronous driver of aStage: whatIterate.through(stage)answers.
Everything
- trait
AccumulatorWhat to do with the values of a pipeline, and the state of doing it: values arrive one at a time throughadd, andfinishproduces the result once they have all arrived. - fn
averagingNonefor an empty pipeline. - fn
chunkingGroups values into lists of at mostsize. - fn
collectorStateis the starting point of every run. - fn
concatenatedThe pieces in one text, withseparatorbetween every two of them. - fn
countingHow many values there are. - fn
filteringKeeps every value that answers the predicate, and drops the rest. - fn
filterMappingmapandfilterin one: keeps the value of everySome. - fn
flatMappingTransforms every value into its own Iterate, and flattens all of them into one sequence. - fn
groupingBygroupingBy { _.department } // Map<String, List<Employee>> groupingBy { _.department }.then(counting()) // Map<String, Int> groupingBy { _.department }.then(maxBy { _.salary }) // Map<String, Employee?>. - fn
indexing(0, first), (1, second), ...with the halves namedindexanditem- the stage behindindexed(). - fn
intoCollects into anything a pipeline can be turned into (From<Iterate<Item>>), which every collection is. - trait
IterateEverything that works withfor ... inand the spread operator (...). - trait
IteratorA cursor over a sequence, with one method:next. - fn
joiningEvery value, joined into oneString, withseparatorbetween values andprefix/suffixaround all of them. - trait
LengthThe size of a collection, and the two questions built on it. - type
ListAccumulatorGathers the values into aListand answers it: the specialised accumulator this package ships, and the shape a package that owns a collection writes for its own (HashSetAccumulatorwriting straight into a set). - fn
listingShorthand forListAccumulator<Item>(), which is what a pipeline ends in most often. - fn
mappingEvery stage is a function, not a member ofStage, for one reason: a member of a trait used as a namespace has to fix the trait's own type arguments, andStage.filtercould not (its answer says nothing aboutOutput). - fn
mappingWhileLikefilterMapping, but the firstNoneends the pipeline. - fn
maxByThe value with the largest key, orNonefor an empty pipeline. - trait
MergeTwo partial results of one accumulator, joined: what lets an accumulator run over pieces of its input - the chunks ofparallel(), a divide-and-conquer fold, a map-reduce over the parts of a file - and still answer what one run over the whole input answers. - fn
mergingCollector[collector] with a [Merge]:mergejoins the outputs of two pieces of the input, in their order, and is never handed the output of a piece that received no value. - fn
minByThe value with the smallest key, orNonefor an empty pipeline. - fn
partitioningBy(matching, rest). - type
QueueingThe tail of a pipeline that somebody pulls from: every value the stage pushes lands in a list the driver also holds. - fn
skippingEvery value after the firstamount, which are read and thrown away. - trait
Stageontois the whole protocol, and it is the reason a stage composes: what it answers is anAccumulatoragain, so the next stage can wrap that one. - fn
summingEvery value, added together, starting from zero. - fn
takingEnds the pipeline afteramountvalues, and asks for none of the values behind them. - fn
takingWhileValues up to, but not including, the first one that fails the predicate.