Package ghidra.util.datastruct

# Class CallbackAccumulator<T>

java.lang.Object
ghidra.util.datastruct.CallbackAccumulator<T>

Type Parameters:
  `T` - the type of the item being accumulated

All Implemented Interfaces:
  `Accumulator<T>`, `Iterable<T>`, `Consumer<T>`

public class CallbackAccumulator<T> extends Object implements Accumulator<T>
An implementation of `Accumulator` that allows clients to easily process items as they arrive.

This class is different than normal accumulators in that the values are not stored internally. As such, calls to `get()`, `iterator()` and `size()` will reflect having no data.

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `CallbackAccumulator(Consumer<T> consumer)`
  Constructor

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `add(T t)`
  `void`
  `addAll(Collection<T> collection)`
  `boolean`
  `contains(T t)`
  `Collection<T>`
  `get()`
  `Iterator<T>`
  `iterator()`
  `int`
  `size()`

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

  ### Methods inherited from interface ghidra.util.datastruct.Accumulator

  `accept, isEmpty, stream`

  ### Methods inherited from interface java.util.function.Consumer

  `andThen`

  ### Methods inherited from interface java.lang.Iterable

  `forEach, spliterator`

- ## Constructor Details

  - ### CallbackAccumulator

    public CallbackAccumulator(Consumer<T> consumer)
    Constructor
    Parameters:
      `consumer` - the consumer that will get called each time an item is added

- ## Method Details

  - ### add

    public void add(T t)
    Specified by:
      `add` in interface `Accumulator<T>`

  - ### addAll

    public void addAll(Collection<T> collection)
    Specified by:
      `addAll` in interface `Accumulator<T>`

  - ### contains

    public boolean contains(T t)
    Specified by:
      `contains` in interface `Accumulator<T>`

  - ### get

    public Collection<T> get()
    Specified by:
      `get` in interface `Accumulator<T>`

  - ### iterator

    public Iterator<T> iterator()
    Specified by:
      `iterator` in interface `Iterable<T>`

  - ### size

    public int size()
    Specified by:
      `size` in interface `Accumulator<T>`