Class BindActionToSamplers

java.lang.Object
net.imglib2.loops.BindActionToSamplers

final class BindActionToSamplers extends Object
Package-private utility class that's used by LoopBuilder.
  • Field Details

  • Constructor Details

    • BindActionToSamplers

      BindActionToSamplers()
  • Method Details

    • bindActionToSamplers

      public static Runnable bindActionToSamplers(Object action, List<? extends Sampler<?>> samplers)
      For example.: Given a BiConsumer and two Samplers:
      
      
      BiConsumer<A, B> biConsumer = ... ;
      Sampler<A> samplerA = ... ;
      Sampler<B> samplerB = ... ;
      
      
      This method bindConsumerToSamplers(biConsumer, Arrays.asList(samplerA, samplerB)) will return a Runnable that is functionally equivalent to:
      
      
      Runnable result = () -> {
          biConsumer.accept( sampleA.get(), samplerB.get() );
      };
      
      
      It does it in such manner, that the returned Runnable can be gracefully optimised by the Java just-in-time compiler.
      Parameters:
      action - This must be an instance of Consumer, BiConsumer of LoopBuilder.TriConsumer. LoopBuilder.FourConsumer, LoopBuilder.FourConsumer, or LoopBuilder.SixConsumer.
      samplers - A list of Sampler, the size of the list must fit the consumer given by .
      Throws:
      IllegalArgumentException - if the number of sampler does not fit the given consumer.