public final class UtilitiesArray
extends java.lang.Object
Modifier and Type | Method and Description |
---|---|
static boolean |
arrayContains(double[] array,
double value)
Returns
true if the array contains the given value. |
static boolean |
arrayContains(int[] array,
int value)
Returns
true if the array contains the given value. |
static boolean |
arrayContains(java.lang.Object[] array,
java.lang.Object object)
Returns
true if the array contains the given object. |
static <T> T[] |
concatenateArrays(T[] a,
java.util.Collection<? extends T> b)
Concatenates specified array with elements from the given collection.
|
static <T> T[] |
concatenateArrays(T[] a,
T... b)
Concatenates specified array with the given elements.
|
static <T> T[] |
concatenateArrays(T[] a,
T[]... b)
Concatenates specified array with the given elements.
|
static int |
indexOf(double[] array,
double value)
Returns the index of the first occurrence of the given value in the array.
|
static int |
indexOf(double[] array,
java.util.function.DoublePredicate test)
Returns the index of the first occurrence of the matching value in the array.
|
static int |
indexOf(int[] array,
int value)
Returns the index of the first occurrence of the given value in the array.
|
static int |
indexOf(int[] array,
java.util.function.IntPredicate test)
Returns the index of the first occurrence of the matching value in the array.
|
static int |
indexOf(java.lang.Object[] array,
java.lang.Object object)
Returns the index of the first occurrence of the given object in the array.
|
static <T> int |
indexOf(T[] array,
java.util.function.Predicate<? super T> test)
Returns the index of the first occurrence of the matching object in the array.
|
static int |
indexOfMax(double[] array)
Returns the index of the maximum value from the given array.
|
static int |
indexOfMax(int[] array)
Returns the index of the maximum value from the given array.
|
static int |
indexOfMin(double[] array)
Returns the index of the minimum value from the given array.
|
static int |
indexOfMin(int[] array)
Returns the index of the minimum value from the given array.
|
static double |
max(double[] array)
Returns the maximum value from the given array.
|
static int |
max(int[] array)
Returns the maximum value from the given array.
|
static double |
min(double[] array)
Returns the minimum value from the given array.
|
static int |
min(int[] array)
Returns the minimum value from the given array.
|
static <T> T[] |
toArray(T e,
T... b)
Creates array using concatenation of the specified element with given array/elements.
|
public static int min(int[] array)
array
is null
or empty.array
- the array to scanarray
public static double min(double[] array)
Double.NaN
if array contains only Double.NaN
values.array
is null
or empty.array
- the array to scanarray
public static int max(int[] array)
array
is null
or empty.array
- the array to scanarray
public static double max(double[] array)
Double.NaN
if array contains only Double.NaN
values.array
is null
or empty.array
- the array to scanarray
public static int indexOfMin(int[] array)
-1
if passed array
is null
or empty.array
- the array to scanarray
, starting from 0public static int indexOfMin(double[] array)
-1
if passed array
is null
or empty or contains only NaN
values.array
- the array to scanarray
, starting from 0public static int indexOfMax(int[] array)
-1
if passed array
is null
or empty.array
- the array to scanarray
, starting from 0public static int indexOfMax(double[] array)
-1
if passed array
is null
or empty or contains only NaN
values.array
- the array to scanarray
, starting from 0public static int indexOf(int[] array, int value)
-1
if value not found or if passed array
is null
or empty.array
- the array to scanvalue
- the value to search forarray
, starting from 0public static int indexOf(int[] array, java.util.function.IntPredicate test)
-1
if no matching value is found or if passed array
is null
or empty.array
- the array to scantest
- the text expression, e.g. v -> v > 10
array
, starting from 0public static int indexOf(double[] array, double value)
-1
if value not found or if passed array
is null
or empty.array
- the array to scanvalue
- the value to search forarray
, starting from 0public static int indexOf(double[] array, java.util.function.DoublePredicate test)
-1
if no matching value is found or if passed array
is null
or empty.array
- the array to scantest
- the text expression, e.g. v -> v > 10
array
, starting from 0public static int indexOf(java.lang.Object[] array, java.lang.Object object)
.equals()
method.-1
if value not found or if passed array
is null
or empty.String[] s = new String[]{ "a", "b", "c" }; traceln( indexOf( s, "b" ) ); // will print out '1'
array
- the array to scanobject
- the object to search for, may be null
- in this case
the method will try to find the index of null
in the given array.array
, starting from 0public static <T> int indexOf(T[] array, java.util.function.Predicate<? super T> test)
-1
if value not found or if passed array
is null
or empty.String[] s = new String[]{ "a", "ab", "abc" }; traceln( indexOf( s, s -> s.length() > 1 ) ); // will print out '1'
array
- the array to scantest
- the text expression, special behavior: if null
is passed instead of predicate, the method will try to find the index of null
in the given array,
to be conforming with indexOf(Object[], Object)
array
, starting from 0public static boolean arrayContains(int[] array, int value)
true
if the array contains the given value.indexOf( array, value ) >= 0
array
- the array to scanvalue
- the value to search fortrue
if the array
contains value
,
false
otherwisepublic static boolean arrayContains(double[] array, double value)
true
if the array contains the given value.indexOf( array, value ) >= 0
array
- the array to scanvalue
- the value to search fortrue
if the array
contains value
,
false
otherwisepublic static boolean arrayContains(java.lang.Object[] array, java.lang.Object object)
true
if the array contains the given object..equals()
method.String[] s = new String[]{ "a", "b", "c" }; traceln( contains( s, "b" ) ); // will print out 'true'
indexOf( array, object ) >= 0
array
- the array to scanobject
- the object to search fortrue
if the array
contains object
,
false
otherwisepublic static <T> T[] concatenateArrays(T[] a, java.util.Collection<? extends T> b)
a
followed
by all other elements (b
)a
- array 1b
- collection of elements to be added to the resulting arraya
followed by elements
from b
@SafeVarargs public static <T> T[] concatenateArrays(T[] a, T... b)
a
followed
by all other elements (b
)a
- array 1b
- array 2 or comma-separated elementsa
followed by elements
from b
@SafeVarargs public static <T> T[] concatenateArrays(T[] a, T[]... b)
a
followed
by all other elements (b
)a
- array 1b
- array 2 or comma-separated elementsa
followed by elements
from b
@SafeVarargs public static <T> T[] toArray(T e, T... b)
a
followed
by all other elements (b
)e
- the first elementb
- array 2 or comma-separated elementsa
followed by elements
from b
Copyright © AnyLogic North America, LLC. All Rights Reserved.