public class LongUtils
extends java.lang.Object
Provides extra functionality for long
primitives.
Constructor and Description |
---|
LongUtils() |
Modifier and Type | Method and Description |
---|---|
static java.lang.Long[] |
asObjectArray(long[] array)
Converts from an
long array to an Long array. |
static long[] |
asPrimitiveArray(java.lang.Long[] array)
Converts from an
Long array to an long array. |
static long[] |
concatenate(long[]... arrays)
Concatenates a series of arrays.
|
static boolean |
contains(long[] array,
long value)
Checks if an input array contains a given value
|
static boolean |
containsAll(long[] array1,
long[] array2)
Checks if an array contains all numbers from another.
|
static boolean |
containsAny(long[] array1,
long[] array2)
Checks whether any element of an array is present in another.
|
static long[] |
copy(long[] array)
Returns a deep copy of the input
array . |
static int[] |
find(long[] array,
long value,
Constants.SearchType searchType)
Returns the position(s) where a given value can be found into an array.
|
static java.lang.String |
join(long[] array,
java.lang.String separator)
Joins the elements in an input array using a given separator.
|
static long[] |
select(long[] array,
int[] indexes)
Returns a set of selected elements from an input array.
|
static long[] |
setdiff(long[]... arrays)
Returns the elements contained in the first array, but not any of the others.
|
static long[] |
toArray(java.util.Collection<java.lang.Long> list)
Converts a collection (
List , Set ...) of Long objects to a long array. |
static int[] |
toIntArray(long[] array)
Converts a
long array to an int array (truncation may happen). |
static java.util.List<java.lang.Long> |
toList(long[] array)
Converts from a
long array to a list. |
static long[] |
union(long[]... arrays)
Returns an array with all elements in input arrays (no repetitions).
|
public static java.lang.Long[] asObjectArray(long[] array)
long
array to an Long
array.array
- long
arrayLong
arraypublic static long[] asPrimitiveArray(java.lang.Long[] array)
Long
array to an long
array.array
- Long
arraylong
arraypublic static long[] concatenate(long[]... arrays)
arrays
- List of arrayspublic static boolean contains(long[] array, long value)
array
- Input arrayvalue
- Value to searchtrue
if value
is present in array
, and false otherwisepublic static boolean containsAll(long[] array1, long[] array2)
array1
- Container arrayarray2
- Array with elements to be checkedtrue
if value
is present in array
, and false otherwisepublic static boolean containsAny(long[] array1, long[] array2)
array1
- Container arrayarray2
- Array with elements to be checkedtrue
if any number in array1
is present in array2
, and false otherwisepublic static long[] copy(long[] array)
array
.array
- Input arrayarray
public static long[] setdiff(long[]... arrays)
arrays
- Input arrayspublic static long[] toArray(java.util.Collection<java.lang.Long> list)
List
, Set
...) of Long
objects to a long
array.list
- Input listlong
arraypublic static java.util.List<java.lang.Long> toList(long[] array)
long
array to a list.array
- Input arrayLong
objectspublic static java.lang.String join(long[] array, java.lang.String separator)
Arrays.toString()
.array
- Input arrayseparator
- SeparatorString
representation of the input array
public static int[] toIntArray(long[] array)
long
array to an int
array (truncation may happen).array
- Input arrayint
arraypublic static long[] union(long[]... arrays)
arrays
- Input arrayspublic static int[] find(long[] array, long value, Constants.SearchType searchType)
array
- Input arrayvalue
- Value to be searched forsearchType
- Indicates whether the first, the last, or all minimum positions are returnedpublic static long[] select(long[] array, int[] indexes)
array
- Input arrayindexes
- Position of elements to be selected.indexes