|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.terrier.utility.ArrayUtils
public class ArrayUtils
Handy methods for resizing arrays, and other handy array methods This is a fresh implementation of the capacity methods, without the use of any prelicensed code.
Field Summary | |
---|---|
protected static double |
GOLDEN_RATIO
the Golden ration (φ). |
Constructor Summary | |
---|---|
ArrayUtils()
|
Method Summary | |
---|---|
static int[] |
cast(double[] arr)
cast double[] to int[] |
static double[] |
cast(float[] arr)
cast float[] to double[] |
static double[] |
cast(int[] arr)
cast int[] to double[] |
static byte[] |
ensureCapacity(byte[] array,
int length)
Grow an array to ensure it is the desired length. |
static byte[] |
ensureCapacity(byte[] array,
int length,
int preserve)
Grow an array to ensure it is the desired length. |
static byte[] |
grow(byte[] array,
int length)
Grow an array to ensure it is at least the desired length. |
static byte[] |
grow(byte[] array,
int length,
int preserve)
Grow an array to ensure it is at least the desired length. |
static double[] |
grow(double[] array,
int length)
grow array |
static int[] |
grow(int[] array,
int length)
grow array |
static short[] |
grow(short[] array,
int length)
grow array |
static int[] |
intersection(int[] arr1,
int[] arr2)
return intersection between two int[] |
static java.lang.String |
join(boolean[] in,
java.lang.String join)
Join some strings together. |
static java.lang.String |
join(byte[] in,
java.lang.String join)
join string |
static java.lang.String |
join(double[] in,
java.lang.String join)
join string |
static java.lang.String |
join(int[] in,
java.lang.String join)
Join some strings together. |
static java.lang.String |
join(java.lang.String[] in,
char join)
Join some strings together. |
static java.lang.String |
join(java.lang.String[] in,
java.lang.String join)
Join some strings together. |
static java.lang.String |
join(java.lang.String[] in,
java.lang.String join,
int l,
int r)
Join some strings together. |
static int[] |
parseCommaDelimitedInts(java.lang.String src)
parse comma delimited int |
static java.lang.String[] |
parseCommaDelimitedString(java.lang.String src)
parse comma delimited string |
static int[] |
parseDelimitedInts(java.lang.String src,
java.lang.String sep)
parse comma delimited int |
static java.lang.String[] |
parseDelimitedString(java.lang.String src,
java.lang.String delim)
parse delimited string |
static java.lang.String[] |
parseDelimitedString(java.lang.String src,
java.lang.String[] delims)
parse delimited string |
static void |
reverse(double[] a)
Reverse the order of an array of doubles |
static void |
reverse(int[] a)
Reverse the order of an array of ints |
static int[] |
union(int[] arr1,
int[] arr2)
union 2 int[] |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected static final double GOLDEN_RATIO
Constructor Detail |
---|
public ArrayUtils()
Method Detail |
---|
public static byte[] ensureCapacity(byte[] array, int length)
array
- input arraylength
- ensure array is this length
public static byte[] ensureCapacity(byte[] array, int length, int preserve)
array
- input arraylength
- new desired lengthpreserve
- amount of old array to copy to new array in case of reallocation
public static byte[] grow(byte[] array, int length)
array
- input arraylength
- minimuim length of new array
public static void reverse(double[] a)
public static void reverse(int[] a)
public static byte[] grow(byte[] array, int length, int preserve)
array
- input arraylength
- minimuim length of new array
public static java.lang.String join(java.lang.String[] in, java.lang.String join)
in
- Strings to joinjoin
- Character or String to join bypublic static java.lang.String join(java.lang.String[] in, java.lang.String join, int l, int r)
in
- join
- l
- r
-
public static java.lang.String join(java.lang.String[] in, char join)
in
- Strings to joinjoin
- Character or String to join bypublic static java.lang.String join(int[] in, java.lang.String join)
in
- join
-
public static java.lang.String join(boolean[] in, java.lang.String join)
in
- join
-
public static int[] grow(int[] array, int length)
array
- length
-
public static double[] grow(double[] array, int length)
array
- length
-
public static short[] grow(short[] array, int length)
array
- length
-
public static java.lang.String[] parseCommaDelimitedString(java.lang.String src)
src
-
public static java.lang.String[] parseDelimitedString(java.lang.String src, java.lang.String delim)
src
- delim
-
public static java.lang.String[] parseDelimitedString(java.lang.String src, java.lang.String[] delims)
src
- delims
-
public static int[] parseCommaDelimitedInts(java.lang.String src)
src
-
public static int[] parseDelimitedInts(java.lang.String src, java.lang.String sep)
src
- sep
-
public static java.lang.String join(byte[] in, java.lang.String join)
in
- join
-
public static java.lang.String join(double[] in, java.lang.String join)
in
- join
-
public static int[] cast(double[] arr)
arr
-
public static double[] cast(int[] arr)
arr
-
public static double[] cast(float[] arr)
arr
-
public static int[] intersection(int[] arr1, int[] arr2)
arr1
- arr2
-
public static int[] union(int[] arr1, int[] arr2)
arr1
- arr2
-
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |