Documentation of 'jsat.utils.concurrent.AtomicDoubleArray' Java class
AtomicDoubleArray
jsat.utils.concurrent

Class AtomicDoubleArray

  • All Implemented Interfaces:
    java.io.Serializable


    public class AtomicDoubleArray
    extends java.lang.Object
    implements java.io.Serializable
    Provides a double array that can have individual values updated atomically. It is backed by and mimics the implementation of AtomicLongArray. As such, the methods have the same documentation
    See Also:
    Serialized Form
    • Constructor Summary

      Constructors 
      Constructor and Description
      AtomicDoubleArray(double[] array)
      Creates a new AtomixDouble Array that is of the same length as the input array.
      AtomicDoubleArray(int length)
      Creates a new AtomicDoubleArray of the given length, with all values initialized to zero
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method and Description
      double accumulateAndGet(int i, double x, java.util.function.DoubleBinaryOperator accumulatorFunction)
      Atomically updates the element at index i with the results of applying the given function to the current and given values, returning the updated value.
      double addAndGet(int i, double delta)
      Atomically adds the given value to the element at index i.
      boolean compareAndSet(int i, double expected, double update)
      Atomically sets the element at position i to the given updated value if the current value == the expected value.
      void fill(double value)
      This is a convenience method to set every value in this array to a specified value
      double get(int i)
      Gets the current value at position i.
      double getAndAccumulate(int i, double x, java.util.function.DoubleBinaryOperator accumulatorFunction)
      Atomically updates the element at index i with the results of applying the given function to the current and given values, returning the previous value.
      double getAndAdd(int i, double delta)
      Atomically adds the given value to the element at index i.
      double getAndDecrement(int i)
      Atomically decrements by one the element at index i.
      double getAndIncrement(int i)
      Atomically increments by one the element at index i.
      double getAndSet(int i, double newValue)
      Atomically sets the element at position i to the given value and returns the old value.
      double getAndUpdate(int i, java.util.function.DoubleUnaryOperator updateFunction)
      Atomically updates the element at index i with the results of applying the given function, returning the previous value.
      void lazySet(int i, double newValue)
      Eventually sets the element at position i to the given value.
      int length()
      Returns the length of the array.
      void set(int i, double newValue)
      Sets the element at position i to the given value.
      double updateAndGet(int i, java.util.function.DoubleUnaryOperator updateFunction)
      Atomically updates the element at index i with the results of applying the given function, returning the updated value.
      boolean weakCompareAndSet(int i, double expected, double update)
      Atomically sets the element at position i to the given updated value if the current value == the expected value.
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • AtomicDoubleArray

        public AtomicDoubleArray(int length)
        Creates a new AtomicDoubleArray of the given length, with all values initialized to zero
        Parameters:
        length - the length of the array
      • AtomicDoubleArray

        public AtomicDoubleArray(double[] array)
        Creates a new AtomixDouble Array that is of the same length as the input array. The values will be copied into the new object
        Parameters:
        array - the array of values to copy
    • Method Detail

      • getAndIncrement

        public double getAndIncrement(int i)
        Atomically increments by one the element at index i.
        Parameters:
        i - the index
        Returns:
        the previous value
      • getAndDecrement

        public double getAndDecrement(int i)
        Atomically decrements by one the element at index i.
        Parameters:
        i - the index
        Returns:
        the previous value
      • getAndAdd

        public double getAndAdd(int i,
                                double delta)
        Atomically adds the given value to the element at index i.
        Parameters:
        i - the index
        delta - the value to add
        Returns:
        the previous value
      • addAndGet

        public double addAndGet(int i,
                                double delta)
        Atomically adds the given value to the element at index i.
        Parameters:
        i - the index
        delta - the value to add
        Returns:
        the updated value
      • getAndSet

        public double getAndSet(int i,
                                double newValue)
        Atomically sets the element at position i to the given value and returns the old value.
        Parameters:
        i - the index
        newValue - the new value
        Returns:
        the previous value
      • set

        public void set(int i,
                        double newValue)
        Sets the element at position i to the given value.
        Parameters:
        i - the index
        newValue - the new value
      • lazySet

        public void lazySet(int i,
                            double newValue)
        Eventually sets the element at position i to the given value.
        Parameters:
        i - the index
        newValue - the new value
      • compareAndSet

        public boolean compareAndSet(int i,
                                     double expected,
                                     double update)
        Atomically sets the element at position i to the given updated value if the current value == the expected value.
        Parameters:
        i - the index
        expected - the expected value
        update - the new value
        Returns:
        true if successful. False return indicates that the actual value was not equal to the expected value.
      • weakCompareAndSet

        public boolean weakCompareAndSet(int i,
                                         double expected,
                                         double update)
        Atomically sets the element at position i to the given updated value if the current value == the expected value.

        May fail spuriously and does not provide ordering guarantees, so is only rarely an appropriate alternative to compareAndSet.

        Parameters:
        i - the index
        expected - the expected value
        update - the new value
        Returns:
        true if successful.
      • updateAndGet

        public final double updateAndGet(int i,
                                         java.util.function.DoubleUnaryOperator updateFunction)
        Atomically updates the element at index i with the results of applying the given function, returning the updated value. The function should be side-effect-free, since it may be re-applied when attempted updates fail due to contention among threads.
        Parameters:
        i - the index
        updateFunction - a side-effect-free function
        Returns:
        the updated value
      • getAndUpdate

        public final double getAndUpdate(int i,
                                         java.util.function.DoubleUnaryOperator updateFunction)
        Atomically updates the element at index i with the results of applying the given function, returning the previous value. The function should be side-effect-free, since it may be re-applied when attempted updates fail due to contention among threads.
        Parameters:
        i - the index
        updateFunction - a side-effect-free function
        Returns:
        the previous value
      • getAndAccumulate

        public final double getAndAccumulate(int i,
                                             double x,
                                             java.util.function.DoubleBinaryOperator accumulatorFunction)
        Atomically updates the element at index i with the results of applying the given function to the current and given values, returning the previous value. The function should be side-effect-free, since it may be re-applied when attempted updates fail due to contention among threads. The function is applied with the current value at index i as its first argument, and the given update as the second argument.
        Parameters:
        i - the index
        x - the update value
        accumulatorFunction - a side-effect-free function of two arguments
        Returns:
        the previous value
      • accumulateAndGet

        public final double accumulateAndGet(int i,
                                             double x,
                                             java.util.function.DoubleBinaryOperator accumulatorFunction)
        Atomically updates the element at index i with the results of applying the given function to the current and given values, returning the updated value. The function should be side-effect-free, since it may be re-applied when attempted updates fail due to contention among threads. The function is applied with the current value at index i as its first argument, and the given update as the second argument.
        Parameters:
        i - the index
        x - the update value
        accumulatorFunction - a side-effect-free function of two arguments
        Returns:
        the updated value
      • get

        public double get(int i)
        Gets the current value at position i.
        Parameters:
        i - the index
        Returns:
        the current value
      • length

        public int length()
        Returns the length of the array.
        Returns:
        the length of the array
      • fill

        public void fill(double value)
        This is a convenience method to set every value in this array to a specified value
        Parameters:
        value - the value fill with

DataMelt 3.0 © DataMelt by jWork.ORG

You see the box below because you did not login.