Class ManArrayExt
- java.lang.Object
-
- manifold.ext.rt.extensions.manifold.rt.api.Array.ManArrayExt
-
-
Constructor Summary
Constructors Constructor Description ManArrayExt()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static intbinarySearch(Object array, int from, int to, Object key)static intbinarySearch(Object array, int from, int to, Object key, Comparator<? super Object> comparator)static intbinarySearch(Object array, Object key)static intbinarySearch(Object array, Object key, Comparator<? super Object> comparator)static Objectcopy(Object array)static Objectcopy(Object array, int newLength)Copies this array's elements into a new array of the specifiednewLength.static ObjectcopyRange(Object array, int from, int to)Copies a range of elements from this array to a newly allocated array.static ObjectcopyRangeTo(Object array, int from, int to, Object target, int targetIndex)Copies a range of elements from this array to thetargetarray.static ObjectcopyTo(Object array, Object to)Copies the elements of this array to a specified array, truncating or padding with nulls as needed.static booleanequals(Object array, Object that)static Objectfirst(Object array)static voidforEach(Object array, IndexedConsumer<? super Object> action)static inthashCode(Object array)static booleanisEmpty(Object array)static booleanisNullOrEmpty(Object array)static Objectlast(Object array)static Spliterator<Object>spliterator(Object array)static Stream<Object>stream(Object array)Returns a sequentialStreamwith this array as its source.static List<Object>toList(Object array)Returns a fixed-size list backed by the specified array.static StringtoString(Object array)
-
-
-
Method Detail
-
toList
public static List<Object> toList(Object array)
Returns a fixed-size list backed by the specified array. (Changes to the returned list "write through" to the array.) This method acts as bridge between array-based and collection-based APIs, in combination withCollection.toArray(). The returned list is serializable and implementsRandomAccess.- Returns:
- a list view of the specified array
-
isEmpty
public static boolean isEmpty(Object array)
-
isNullOrEmpty
public static boolean isNullOrEmpty(Object array)
-
copy
public static Object copy(Object array, int newLength)
Copies this array's elements into a new array of the specifiednewLength. IfnewLengthis < 0, the new array's size matches this array, otherwise the new array is truncated or padded withnullasnewLengthdiffers from this array's length.- Parameters:
newLength- The length of the new array. If < 0, the resulting array's length matches this array, otherwise the resulting array is truncated or padded withnullaccordingly.- Returns:
- A newly allocated array with elements corresponding with this array.
-
copyTo
public static Object copyTo(Object array, Object to)
Copies the elements of this array to a specified array, truncating or padding with nulls as needed.
-
copyRange
public static Object copyRange(Object array, int from, int to)
Copies a range of elements from this array to a newly allocated array. Note, ifto< 0, the range contains the remainder of this array's elements.- Parameters:
from- The start point of the range, inclusive.to- The endpoint of the range, exclusive. A negative value may be used as a convenience to use this array's endpoint.- Returns:
- A newly allocated array containing the specified range of elements from this array.
-
copyRangeTo
public static Object copyRangeTo(Object array, int from, int to, Object target, int targetIndex)
Copies a range of elements from this array to thetargetarray. Note, ifto< 0, the range contains the remainder of this array's elements.- Parameters:
from- The starting point of the range, inclusive.to- The endpoint of the range, exclusive. A negative value may be used as a convenience to use this array's endpoint.- Returns:
- The
targetarray containing the specified range of elements from this array.
-
stream
public static Stream<Object> stream(Object array)
Returns a sequentialStreamwith this array as its source. Note, this array is assumed to be unmodified during use- Returns:
- A
Streamfor the array
-
forEach
public static void forEach(Object array, IndexedConsumer<? super Object> action)
-
spliterator
public static Spliterator<Object> spliterator(Object array)
-
binarySearch
public static int binarySearch(Object array, Object key, Comparator<? super Object> comparator)
-
binarySearch
public static int binarySearch(Object array, int from, int to, Object key, Comparator<? super Object> comparator)
-
hashCode
public static int hashCode(Object array)
-
-