Class ArrayContext.Event

java.lang.Object
net.algart.arrays.ArrayContext.Event
Enclosing interface:
ArrayContext

public static class ArrayContext.Event extends Object
The array processing event: an argument of ArrayContext.updateProgress(Event) method.
  • Constructor Details

    • Event

      public Event(Class<?> elementType, long readyCount, long length)
      Creates new event with the specified elementType(), length(), readyCount() for the case of 1 parallel task. The readyPart() method in the created instance returns (double)readyCount/(double)length. Equivalent to new Event(elementType, new long[] {length}, new long[] {readyCount}).
      Parameters:
      elementType - the result of elementType() method in the created event; may be null.
      readyCount - the only element in the result of readyCountPerTask() method in the created event.
      length - the result of length() method in the created event.
      Throws:
      IllegalArgumentException - if length or readyCount is negative, or if readyCount>length.
    • Event

      public Event(Class<?> elementType, long[] readyCountPerTask, long[] lengthPerTask)
      Creates new event with the specified elementType(), lengthPerTask() and readyCountPerTask(). The length() method in the created instance returns the sum of all elements of lengthPerTask argument. The readyCount() method returns the sum of all elements of readyCountPerTask argument. The numberOfParallelTasks() method returns the length of each of the passed arrays (their lengths must be equal). The readyPart() method returns (double)readyCount()/(double)length().

      All elements of the readyCountPerTask array must not be greater than the corresponding elements of the lengthsPerTask array. All elements of these arrays must not be negative.

      The passed lengthPerTask and readyCountPerTask arguments are cloned by this method: no references to them are maintained by the created instance.

      Parameters:
      elementType - the result of elementType() method in the created event; may be null.
      readyCountPerTask - the result of readyCountPerTask() method in the created event.
      lengthPerTask - the result of lengthPerTask() method in the created event.
      Throws:
      NullPointerException - if lengthPerTask or readyCountPerTask is null.
      IllegalArgumentException - if lengthPerTask or readyCountPerTask is an empty array, or if their lengths are not equal, or if some their elements are negative, or if readyCountPerTask[k] is than lengthPerTask[k] for some index k, or if the sum of all elements of one of these arrays is greater than Long.MAX_VALUE.
  • Method Details

    • elementType

      public Class<?> elementType()
      Returns the type of elements in the source AlgART array, passed to an array processing method alike Arrays.ParallelExecutor.process(). If the context of using cannot define a suitable type of array elements, this method may return null.
      Returns:
      the type of elements in the source array.
      See Also:
    • lengthPerTask

      public long[] lengthPerTask()
      Returns the total number of elements, that must be processed per each of parallel tasks, which the algorithm is split into. (So, the number of parallel tasks is equal to the length of the returned array.) These elements are usually located in several ranges in the array, some number of regions per one task.

      The returned array is a clone of the internal array stored in this object. The returned array is never empty (its length cannot be zero).

      Returns:
      the total number of elements, that must be processed per each of parallel tasks, which the algorithm is split into.
    • length

      public long length()
      Returns the total number of processed elements. Always equal to the sum of all elements in the array, returned by lengthPerTask() method.

      For Arrays.copy(ArrayContext, UpdatableArray, Array) method, returns min(dest.length(), src.length()), where dest and src are the AlgART arrays passed this method. For Arrays.ParallelExecutor.process() method and another methods based on it, return src.Array.length(), where src is the processed AlgART array.

      Returns:
      the total number of processing elements.
    • readyCountPerTask

      public long[] readyCountPerTask()
      Returns the number of elements, that was already processed until this moment per each of parallel tasks, which the algorithm is split into. (So, the number of parallel tasks is equal to the length of the returned array.) These elements are usually located in several ranges in the array, some number of regions per one task.

      The returned array is a clone of the internal array stored in this object. The returned array is never empty (its length cannot be zero).

      Returns:
      the number of elements, that was already processed until this moment per each of parallel tasks, which the algorithm is split into.
    • readyCount

      public long readyCount()
      Returns the number of elements that was already processed until this moment. Always equal to the sum of all elements in the array, returned by readyCountPerTask() method.
      Returns:
      the number of elements that was already processed until this moment.
    • numberOfParallelTasks

      public int numberOfParallelTasks()
      Returns the number of parallel tasks, which the algorithm is split into. Always equal to the number of elements in the arrays, returned by lengthPerTask() and readyCountPerTask() method.
      Returns:
      the number of parallel tasks that are executed simultaneously in several threads.
      See Also:
    • readyPart

      public double readyPart()
      Returns the ready part of total algorithm execution. In simple cases, returns (double)readyCount()/(double)length(). Returns 1.0 if and only if all calculations are finished. Also returns 1.0 if length() is zero.
      Returns:
      the ready part of total algorithm execution (from 0.0 to 1.0).
      See Also: