Object/Class

com.rklaehn.sonicreducer

Reducer

Related Docs: class Reducer | package sonicreducer

Permalink

object Reducer

A helper object to reduce collections using an associative operation and to produce stateful reducer objects.

Instead of aggregating from the left to the right, the result will be aggregated from the bottom to the top. E.g. for a sequence Array(1,2,3,4) and an operation (+), the reducers produced by this helper class would execute (1 + 2) + (3 + 4) instead of (((1+2)+3)+4). This can have significant advantages when the cost of an operation depends on the weight of an element.

Consider string concatenation: concatenating a sequence of one-char strings of size N using seq.reduceLeft(_ + _) would be an O(N**2) operation. Reducing it hierarchically would be an O(N*log(N)) operation.

Linear Supertypes
AnyRef, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. Reducer
  2. AnyRef
  3. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Value Members

  1. final def !=(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  4. def apply[T](op: (T, T) ⇒ T): Reducer[T]

    Permalink

    Returns a stateful hierarchical reducer.

    Returns a stateful hierarchical reducer. This is used by the reduce operation internally. The reducer will perform as many reduce steps as possible every time a new element is added. It will retain at most 32 non-reduced elements, which will all be combined once the result() method is called.

    T

    the element and result type

    op

    the reduce operation. Must be associative

    returns

    a stateful reducer that can be fed elements by calling apply

  5. final def asInstanceOf[T0]: T0

    Permalink
    Definition Classes
    Any
  6. def clone(): AnyRef

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  7. final def eq(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  8. def equals(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  9. def finalize(): Unit

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  10. final def getClass(): Class[_]

    Permalink
    Definition Classes
    AnyRef → Any
  11. def hashCode(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  12. final def isInstanceOf[T0]: Boolean

    Permalink
    Definition Classes
    Any
  13. final def ne(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  14. final def notify(): Unit

    Permalink
    Definition Classes
    AnyRef
  15. final def notifyAll(): Unit

    Permalink
    Definition Classes
    AnyRef
  16. def reduce[T](elements: TraversableOnce[T])(op: (T, T) ⇒ T): Option[T]

    Permalink

    Reduces any traversable collection hierarchically.

    Reduces any traversable collection hierarchically.

    T

    the element and result type

    elements

    a traversable collection to be reduced

    op

    the reduce operation. Must be associative

    returns

    an opt containing the result, or Opt.empty[T] if the collection is of size 0

  17. def reduceArray[T](elements: Array[T])(op: (T, T) ⇒ T): Option[T]

    Permalink

    Reduces an array hierarchically.

    Reduces an array hierarchically.

    T

    the element type

    elements

    the elements to reduce

    op

    the reduce operation. Must be associative

    returns

    an opt containing the result, or Opt.empty[T] if the array is of size 0

  18. final def synchronized[T0](arg0: ⇒ T0): T0

    Permalink
    Definition Classes
    AnyRef
  19. def toString(): String

    Permalink
    Definition Classes
    AnyRef → Any
  20. final def wait(): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  21. final def wait(arg0: Long, arg1: Int): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  22. final def wait(arg0: Long): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )

Inherited from AnyRef

Inherited from Any

Ungrouped