Class ArrayEvery

java.lang.Object
ortus.boxlang.runtime.bifs.BIF
ortus.boxlang.runtime.bifs.global.array.ArrayEvery
Direct Known Subclasses:
ListEvery

@BoxBIF(description="Test whether every item in an array meets a test condition") @BoxMember(type=ARRAY) public class ArrayEvery extends BIF
  • Constructor Details

    • ArrayEvery

      public ArrayEvery()
      Constructor
  • Method Details

    • _invoke

      public Object _invoke(IBoxContext context, ArgumentsScope arguments)
      Used to iterate over an array and test whether every item meets the test callback. The function will be passed 3 arguments: the value, the index, and the array. You can alternatively pass a Java Predicate which will only receive the 1st arg. The function should return true if the item meets the test, and false otherwise.

      Note: This operation is a short-circuit operation, meaning it will stop iterating as soon as it finds the first item that does not meet the test condition.

      Parallel Execution

      If the parallel argument is set to true, and no max_threads are sent, the filter will be executed in parallel using a ForkJoinPool with parallel streams. If max_threads is specified, it will create a new ForkJoinPool with the specified number of threads to run the filter in parallel, and destroy it after the operation is complete. This allows for efficient processing of large arrays, especially when the test function is computationally expensive or the array is large.
      Specified by:
      _invoke in class BIF
      Parameters:
      context - The context in which the BIF is being invoked.
      arguments - Argument scope for the BIF.
      Returns:
      The result of the invocation