- All Known Implementing Classes:
- BaseSequence, ConcatSequence, ExecutorExecutingSequence, FilteredSequence, LazySequence, LimitedSequence, MappedSequence, MergeSequence, ResourceClosingSequence, SimpleSequence, YieldingSequenceBase
public interface Sequence<T>
A Sequence represents an iterable sequence of elements. Unlike normal Iterators however, it doesn't expose
a way for you to extract values from it, instead you provide it with a worker (an Accumulator) and that defines
what happens with the data.
This inversion of control is in place to allow the Sequence to do resource management. It can enforce that close()
methods get called and other resources get cleaned up whenever processing is complete. Without this inversion
it is very easy to unintentionally leak resources when iterating over something that is backed by a resource.
Sequences also expose {#see com.metamx.common.guava.Yielder} Yielder objects which allow you to implement a
continuation over the Sequence. Yielder do not offer the same guarantees of automagic resource management
as the accumulate method, but they are Closeable and will do the proper cleanup when close() is called on them.