Package net.imglib2

Interface RealRandomAccess<T>

    • Method Detail

      • copyRealRandomAccess

        @Deprecated
        default RealRandomAccess<T> copyRealRandomAccess()
        Deprecated.
      • copy

        RealRandomAccess<T> copy()
        Specified by:
        copy in interface Sampler<T>
        Returns:
        - A new Sampler in the same state accessing the same values. It does NOT copy T, just the state of the Sampler. Otherwise use T.copy() if available. Sampler.copy().get() == Sampler.get(), i.e. both hold the same value, not necessarily the same instance (this is the case for an ArrayCursor for example)
      • setPositionAndGet

        default T setPositionAndGet​(double... position)
        Convenience method that moves the RealRandomAccess to the given position and gets the value at that position. It's a shortcut for:

         
         setPosition( position );
         get();
         
         

        WARNING: The return value is invalidated by next call to setPositionAndGet(double...) or RealPositionable.setPosition(net.imglib2.RealLocalizable).

         
         // This is wrong!!!
         a = randomAccess.setPositionAndGet( positionA );
         b = randomAccess.setPositionAndGet( positionB ); // this invalidates "a" !!!
         wrongDifference = a.getRealDouble() - b.getRealDouble();
        
         // Correct:
         // Use individual RandomAccesses to query a and b
         a = randomAccess_A.setPositionAndGet( positionA );
         b = randomAccess_B.setPositionAndGet( positionB ); // this is fine because a different RandomAccess is used
         difference = a.getRealDouble() - b.getRealDouble();
         
         
      • setPositionAndGet

        default T setPositionAndGet​(float... position)
        Convenience method that moves the RealRandomAccess to the given position and gets the value at that position. It's a shortcut for:

         
         setPosition( position );
         get();
         
         

        WARNING: The return value is invalidated by next call to setPositionAndGet(double...) or RealPositionable.setPosition(net.imglib2.RealLocalizable).

         
         // This is wrong!!!
         a = randomAccess.setPositionAndGet( positionA );
         b = randomAccess.setPositionAndGet( positionB ); // this invalidates "a" !!!
         wrongDifference = a.getRealDouble() - b.getRealDouble();
        
         // Correct:
         // Use individual RandomAccesses to query a and b
         a = randomAccess_A.setPositionAndGet( positionA );
         b = randomAccess_B.setPositionAndGet( positionB ); // this is fine because a different RandomAccess is used
         difference = a.getRealDouble() - b.getRealDouble();
         
         
      • setPositionAndGet

        default T setPositionAndGet​(RealLocalizable position)
        Convenience method that moves the RealRandomAccess to the given position and gets the value at that position. It's a shortcut for:

         
         setPosition( position );
         get();
         
         

        WARNING: The return value is invalidated by next call to setPositionAndGet(double...) or RealPositionable.setPosition(net.imglib2.RealLocalizable).

         
         // This is wrong!!!
         a = randomAccess.setPositionAndGet( positionA );
         b = randomAccess.setPositionAndGet( positionB ); // this invalidates "a" !!!
         wrongDifference = a.getRealDouble() - b.getRealDouble();
        
         // Correct:
         // Use individual RandomAccesses to query a and b
         a = randomAccess_A.setPositionAndGet( positionA );
         b = randomAccess_B.setPositionAndGet( positionB ); // this is fine because a different RandomAccess is used
         difference = a.getRealDouble() - b.getRealDouble();