|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object prefuse.util.ArrayLib
public abstract class ArrayLib
Library of supplementary array routines not supported by the java.util.Arrays class.
Field Summary | |
---|---|
static int |
SORT_THRESHOLD
Arrays with lengths beneath this value will be insertion sorted. |
Constructor Summary | |
---|---|
ArrayLib()
|
Method Summary | |
---|---|
static int |
binarySearch(int[] a,
int key)
Perform a binary search over a sorted array for the given key. |
static int |
binarySearch(int[] a,
int key,
int length)
Perform a binary search over a sorted range of an array for the given key. |
static int |
binarySearch(int[] a,
int key,
int begin,
int end)
Perform a binary search over a sorted range of an array for the given key. |
static int |
binarySearch(java.lang.Object[] a,
java.lang.Object key)
Perform a binary search over a sorted array for the given key. |
static int |
binarySearch(java.lang.Object[] a,
java.lang.Object key,
java.util.Comparator cp)
Perform a binary search over a sorted array for the given key. |
static int |
binarySearch(java.lang.Object[] a,
java.lang.Object key,
java.util.Comparator cp,
int length)
Perform a binary search over a sorted range of an array for the given key. |
static int |
binarySearch(java.lang.Object[] a,
java.lang.Object key,
java.util.Comparator cp,
int begin,
int end)
Perform a binary search over a sorted range of an array for the given key. |
static int |
binarySearch(java.lang.Object[] a,
java.lang.Object key,
int length)
Perform a binary search over a sorted range of an array for the given key. |
static int |
binarySearch(java.lang.Object[] a,
java.lang.Object key,
int begin,
int end)
Perform a binary search over a sorted range of an array for the given key. |
static int |
find(int[] a,
int key)
Linearly search an array for a given key value. |
static int |
find(int[] a,
int key,
int length)
Linearly search an array range for a given key value. |
static int |
find(int[] a,
int key,
int begin,
int end)
Linearly search an array range for a given key value. |
static int[] |
getIntArray(java.lang.String filename)
Read in a text file as an array of integers. |
protected static void |
insertionsort(double[] a,
int[] b,
int p,
int r)
|
protected static void |
insertionsort(float[] a,
int[] b,
int p,
int r)
|
protected static void |
insertionsort(int[] a,
double[] b,
int p,
int r)
|
protected static void |
insertionsort(int[] a,
int[] b,
int p,
int r)
|
protected static void |
insertionsort(int[] a,
java.lang.Object[] b,
int p,
int r)
|
protected static void |
insertionsort(java.lang.Object[] a,
int[] b,
int p,
int r,
java.util.Comparator cmp)
|
static double |
max(double[] a)
Find the maximum value in an array. |
protected static void |
merge(double[] a,
int[] b,
int p,
int q,
int r)
|
protected static void |
merge(float[] a,
int[] b,
int p,
int q,
int r)
|
protected static void |
merge(int[] a,
double[] b,
int p,
int q,
int r)
|
protected static void |
merge(int[] a,
int[] b,
int p,
int q,
int r)
|
protected static void |
merge(int[] a,
java.lang.Object[] b,
int p,
int q,
int r)
|
protected static void |
merge(java.lang.Object[] a,
int[] b,
int p,
int q,
int r,
java.util.Comparator cmp)
|
protected static void |
mergesort(double[] a,
int[] b,
int p,
int r)
|
protected static void |
mergesort(float[] a,
int[] b,
int p,
int r)
|
protected static void |
mergesort(int[] a,
double[] b,
int p,
int r)
|
protected static void |
mergesort(int[] a,
int[] b,
int p,
int r)
|
protected static void |
mergesort(int[] ks,
int[] kd,
java.lang.Object[] vs,
java.lang.Object[] vd,
int lo,
int hi,
int off)
|
protected static void |
mergesort(java.lang.Object[] a,
int[] b,
int p,
int r,
java.util.Comparator cmp)
|
static double |
min(double[] a)
Find the minimum value in an array. |
static double[] |
resize(double[] a,
int size)
Resize the given array as needed to meet a target size. |
static float[] |
resize(float[] a,
int size)
Resize the given array as needed to meet a target size. |
static int[] |
resize(int[] a,
int size)
Resize the given array as needed to meet a target size. |
static java.lang.Object[] |
resize(java.lang.Object[] a,
int size)
Resize the given array as needed to meet a target size. |
static void |
shuffle(double[] a,
int start,
int len,
java.util.Random r)
Randomly permute the contents of a range an array. |
static void |
shuffle(double[] a,
java.util.Random r)
Randomly permute the contents of an array. |
static void |
shuffle(float[] a,
int start,
int len,
java.util.Random r)
Randomly permute the contents of a range an array. |
static void |
shuffle(float[] a,
java.util.Random r)
Randomly permute the contents of an array. |
static void |
shuffle(int[] a,
int start,
int len,
java.util.Random r)
Randomly permute the contents of a range an array. |
static void |
shuffle(int[] a,
java.util.Random r)
Randomly permute the contents of an array. |
static void |
shuffle(long[] a,
int start,
int len,
java.util.Random r)
Randomly permute the contents of a range an array. |
static void |
shuffle(long[] a,
java.util.Random r)
Randomly permute the contents of an array. |
static void |
shuffle(java.lang.Object[] a,
int start,
int len,
java.util.Random r)
Randomly permute the contents of a range an array. |
static void |
shuffle(java.lang.Object[] a,
java.util.Random r)
Randomly permute the contents of an array. |
static void |
sort(double[] a,
int[] b)
Sort two arrays simultaneously, using the sort order of the values in the first array to determine the sort order for both arrays. |
static void |
sort(double[] a,
int[] b,
int length)
Sort two arrays simultaneously, using the sort order of the values in the first array to determine the sort order for both arrays. |
static void |
sort(double[] a,
int[] b,
int begin,
int end)
Sort two arrays simultaneously, using the sort order of the values in the first array to determine the sort order for both arrays. |
static void |
sort(float[] a,
int[] b)
Sort two arrays simultaneously, using the sort order of the values in the first array to determine the sort order for both arrays. |
static void |
sort(float[] a,
int[] b,
int length)
Sort two arrays simultaneously, using the sort order of the values in the first array to determine the sort order for both arrays. |
static void |
sort(float[] a,
int[] b,
int begin,
int end)
Sort two arrays simultaneously, using the sort order of the values in the first array to determine the sort order for both arrays. |
static void |
sort(int[] a,
double[] b)
Sort two arrays simultaneously, using the sort order of the values in the first array to determine the sort order for both arrays. |
static void |
sort(int[] a,
double[] b,
int length)
Sort two arrays simultaneously, using the sort order of the values in the first array to determine the sort order for both arrays. |
static void |
sort(int[] a,
double[] b,
int begin,
int end)
Sort two arrays simultaneously, using the sort order of the values in the first array to determine the sort order for both arrays. |
static void |
sort(int[] a,
int[] b)
Sort two arrays simultaneously, using the sort order of the values in the first array to determine the sort order for both arrays. |
static void |
sort(int[] a,
int[] b,
int length)
Sort two arrays simultaneously, using the sort order of the values in the first array to determine the sort order for both arrays. |
static void |
sort(int[] a,
int[] b,
int begin,
int end)
Sort two arrays simultaneously, using the sort order of the values in the first array to determine the sort order for both arrays. |
static void |
sort(int[] a,
java.lang.Object[] b,
int[] abuf,
java.lang.Object[] bbuf,
int begin,
int end)
Sort two arrays simultaneously, using the sort order of the values in the first array to determine the sort order for both arrays. |
static void |
sort(int[] a,
java.lang.Object[] b,
int begin,
int end)
Sort two arrays simultaneously, using the sort order of the values in the first array to determine the sort order for both arrays. |
static void |
sort(java.lang.Object[] a,
int[] b,
java.util.Comparator cmp)
Sort two arrays simultaneously, using the sort order of the values in the first array to determine the sort order for both arrays. |
static void |
sort(java.lang.Object[] a,
int[] b,
int length,
java.util.Comparator cmp)
Sort two arrays simultaneously, using the sort order of the values in the first array to determine the sort order for both arrays. |
static void |
sort(java.lang.Object[] a,
int[] b,
int begin,
int end,
java.util.Comparator cmp)
Sort two arrays simultaneously, using the sort order of the values in the first array to determine the sort order for both arrays. |
static double |
sum(double[] a)
Compute the sum of the values in an array. |
static double[] |
trim(double[] a,
int size)
Trims an array to be exactly the target a size. |
static float[] |
trim(float[] a,
int size)
Trims an array to be exactly the target a size. |
static int[] |
trim(int[] a,
int size)
Trims an array to be exactly the target a size. |
static java.lang.Object[] |
trim(java.lang.Object[] a,
int size)
Trims an array to be exactly the target a size. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int SORT_THRESHOLD
Constructor Detail |
---|
public ArrayLib()
Method Detail |
---|
public static final void shuffle(int[] a, java.util.Random r)
a
- the array to shuffler
- the source of randomness to usepublic static final void shuffle(int[] a, int start, int len, java.util.Random r)
a
- the array to shufflestart
- the starting index of the range to shufflelen
- then length of the range to shuffler
- the source of randomness to usepublic static final void shuffle(long[] a, java.util.Random r)
a
- the array to shuffler
- the source of randomness to usepublic static final void shuffle(long[] a, int start, int len, java.util.Random r)
a
- the array to shufflestart
- the starting index of the range to shufflelen
- then length of the range to shuffler
- the source of randomness to usepublic static final void shuffle(float[] a, java.util.Random r)
a
- the array to shuffler
- the source of randomness to usepublic static final void shuffle(float[] a, int start, int len, java.util.Random r)
a
- the array to shufflestart
- the starting index of the range to shufflelen
- then length of the range to shuffler
- the source of randomness to usepublic static final void shuffle(double[] a, java.util.Random r)
a
- the array to shuffler
- the source of randomness to usepublic static final void shuffle(double[] a, int start, int len, java.util.Random r)
a
- the array to shufflestart
- the starting index of the range to shufflelen
- then length of the range to shuffler
- the source of randomness to usepublic static final void shuffle(java.lang.Object[] a, java.util.Random r)
a
- the array to shuffler
- the source of randomness to usepublic static final void shuffle(java.lang.Object[] a, int start, int len, java.util.Random r)
a
- the array to shufflestart
- the starting index of the range to shufflelen
- then length of the range to shuffler
- the source of randomness to usepublic static final double max(double[] a)
a
- the array
public static final double min(double[] a)
a
- the array
public static final double sum(double[] a)
a
- the array
public static final int binarySearch(int[] a, int key)
a
- the array to searchkey
- the key to search for
public static final int binarySearch(int[] a, int key, int length)
a
- the array to searchkey
- the key to search forlength
- the the length of the range to search over.
public static final int binarySearch(int[] a, int key, int begin, int end)
a
- the array to searchkey
- the key to search forbegin
- the starting index of the rangeend
- the ending index of the range, exclusive
public static final int binarySearch(java.lang.Object[] a, java.lang.Object key)
a
- the array to searchkey
- the key to search for
public static final int binarySearch(java.lang.Object[] a, java.lang.Object key, int length)
a
- the array to searchkey
- the key to search forlength
- the the length of the range to search over.
public static final int binarySearch(java.lang.Object[] a, java.lang.Object key, int begin, int end)
a
- the array to searchkey
- the key to search forbegin
- the starting index of the rangeend
- the ending index of the range, exclusive
public static final int binarySearch(java.lang.Object[] a, java.lang.Object key, java.util.Comparator cp)
a
- the array to searchkey
- the key to search forcp
- the comparator to use to compare key values
public static final int binarySearch(java.lang.Object[] a, java.lang.Object key, java.util.Comparator cp, int length)
a
- the array to searchkey
- the key to search forcp
- the comparator to use to compare key valueslength
- the the length of the range to search over.
public static final int binarySearch(java.lang.Object[] a, java.lang.Object key, java.util.Comparator cp, int begin, int end)
a
- the array to searchkey
- the key to search forcp
- the comparator to use to compare key valuesbegin
- the starting index of the rangeend
- the ending index of the range, exclusive
public static final int find(int[] a, int key)
a
- the array to searchkey
- the key to search for
public static final int find(int[] a, int key, int length)
a
- the array to searchkey
- the key to search forlength
- the length of the range to search over
public static final int find(int[] a, int key, int begin, int end)
a
- the array to searchkey
- the key to search forbegin
- the starting index of the rangeend
- the ending index of the range, exclusive
public static final int[] resize(int[] a, int size)
a
- the array to potentially resizesize
- the minimum size of the target array
public static final float[] resize(float[] a, int size)
a
- the array to potentially resizesize
- the minimum size of the target array
public static final double[] resize(double[] a, int size)
a
- the array to potentially resizesize
- the minimum size of the target array
public static final java.lang.Object[] resize(java.lang.Object[] a, int size)
a
- the array to potentially resizesize
- the minimum size of the target array
public static final int[] trim(int[] a, int size)
a
- the array to trimsize
- the desired size of the array. This value must be lesser
than or equal to the size of the input array.
public static final float[] trim(float[] a, int size)
a
- the array to trimsize
- the desired size of the array. This value must be lesser
than or equal to the size of the input array.
public static final double[] trim(double[] a, int size)
a
- the array to trimsize
- the desired size of the array. This value must be lesser
than or equal to the size of the input array.
public static final java.lang.Object[] trim(java.lang.Object[] a, int size)
a
- the array to trimsize
- the desired size of the array. This value must be lesser
than or equal to the size of the input array.
public static final void sort(int[] a, double[] b)
a
- the array to sort byb
- the array to re-arrange based on the sort order of the
first array.public static final void sort(int[] a, double[] b, int length)
a
- the array to sort byb
- the array to re-arrange based on the sort order of the
first array.length
- the array range length to sort overpublic static final void sort(int[] a, double[] b, int begin, int end)
a
- the array to sort byb
- the array to re-arrange based on the sort order of the
first array.begin
- the start index of the range to sortend
- the end index, exclusive, of the range to sortprotected static final void insertionsort(int[] a, double[] b, int p, int r)
protected static final void mergesort(int[] a, double[] b, int p, int r)
protected static final void merge(int[] a, double[] b, int p, int q, int r)
public static final void sort(int[] a, int[] b)
a
- the array to sort byb
- the array to re-arrange based on the sort order of the
first array.public static final void sort(int[] a, int[] b, int length)
a
- the array to sort byb
- the array to re-arrange based on the sort order of the
first array.length
- the array range length to sort overpublic static final void sort(int[] a, int[] b, int begin, int end)
a
- the array to sort byb
- the array to re-arrange based on the sort order of the
first array.begin
- the start index of the range to sortend
- the end index, exclusive, of the range to sortprotected static final void insertionsort(int[] a, int[] b, int p, int r)
protected static final void mergesort(int[] a, int[] b, int p, int r)
protected static final void merge(int[] a, int[] b, int p, int q, int r)
public static final void sort(int[] a, java.lang.Object[] b, int begin, int end)
a
- the array to sort byb
- the array to re-arrange based on the sort order of the
first array.begin
- the start index of the range to sortend
- the end index, exclusive, of the range to sortpublic static final void sort(int[] a, java.lang.Object[] b, int[] abuf, java.lang.Object[] bbuf, int begin, int end)
a
- the array to sort byb
- the array to re-arrange based on the sort order of the
first array.abuf
- a buffer array to perform the sorting without
allocating any additional memorybbuf
- a buffer array to perform the sorting without
allocating any additional memorybegin
- the start index of the range to sortend
- the end index, exclusive, of the range to sortprotected static final void insertionsort(int[] a, java.lang.Object[] b, int p, int r)
protected static void mergesort(int[] ks, int[] kd, java.lang.Object[] vs, java.lang.Object[] vd, int lo, int hi, int off)
protected static final void merge(int[] a, java.lang.Object[] b, int p, int q, int r)
public static final void sort(double[] a, int[] b)
a
- the array to sort byb
- the array to re-arrange based on the sort order of the
first array.public static final void sort(double[] a, int[] b, int length)
a
- the array to sort byb
- the array to re-arrange based on the sort order of the
first array.length
- the length of the range to be sortedpublic static final void sort(double[] a, int[] b, int begin, int end)
a
- the array to sort byb
- the array to re-arrange based on the sort order of the
first array.begin
- the start index of the range to sortend
- the end index, exclusive, of the range to sortprotected static final void insertionsort(double[] a, int[] b, int p, int r)
protected static final void mergesort(double[] a, int[] b, int p, int r)
protected static final void merge(double[] a, int[] b, int p, int q, int r)
public static final void sort(float[] a, int[] b)
a
- the array to sort byb
- the array to re-arrange based on the sort order of the
first array.public static final void sort(float[] a, int[] b, int length)
a
- the array to sort byb
- the array to re-arrange based on the sort order of the
first array.length
- the length of the range to be sortedpublic static final void sort(float[] a, int[] b, int begin, int end)
a
- the array to sort byb
- the array to re-arrange based on the sort order of the
first array.begin
- the start index of the range to sortend
- the end index, exclusive, of the range to sortprotected static final void insertionsort(float[] a, int[] b, int p, int r)
protected static final void mergesort(float[] a, int[] b, int p, int r)
protected static final void merge(float[] a, int[] b, int p, int q, int r)
public static final void sort(java.lang.Object[] a, int[] b, java.util.Comparator cmp)
a
- the array to sort byb
- the array to re-arrange based on the sort order of the
first array.cmp
- the comparator to use to compare key valuespublic static final void sort(java.lang.Object[] a, int[] b, int length, java.util.Comparator cmp)
a
- the array to sort byb
- the array to re-arrange based on the sort order of the
first array.length
- the length of the range to be sortedcmp
- the comparator to use to compare key valuespublic static final void sort(java.lang.Object[] a, int[] b, int begin, int end, java.util.Comparator cmp)
a
- the array to sort byb
- the array to re-arrange based on the sort order of the
first array.begin
- the start index of the range to sortend
- the end index, exclusive, of the range to sortcmp
- the comparator to use to compare key valuesprotected static final void insertionsort(java.lang.Object[] a, int[] b, int p, int r, java.util.Comparator cmp)
protected static final void mergesort(java.lang.Object[] a, int[] b, int p, int r, java.util.Comparator cmp)
protected static final void merge(java.lang.Object[] a, int[] b, int p, int q, int r, java.util.Comparator cmp)
public static int[] getIntArray(java.lang.String filename)
filename
- the name of the file to read in
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |