public class Util extends Object
Constructor and Description |
---|
Util() |
Modifier and Type | Method and Description |
---|---|
static void |
dsort(Object[] array,
int start,
int end)
Sorts the specified range in the array in descending order.
|
static void |
qSortByString(Object[] array,
int start,
int stop)
Sorts the array of objects by their string representation
in ascending order.
|
static void |
sort(Object[] array,
int start,
int end)
Sorts the specified range in the array in ascending order.
|
static void |
sortByString(Object[] array)
Performs a quicksort of the given objects
by their string representation in ascending order.
|
static void |
swap(Object[] array)
Reverse the elements in the array.
|
static String |
toString(Object object,
int length)
Returns a string representation of the object
in the given length.
|
static String |
toString(Object object,
int length,
char pad,
boolean onLeft)
Returns a string representation of the object
in the given length.
|
public static void sortByString(Object[] array)
array
- The array of objects to sortpublic static void qSortByString(Object[] array, int start, int stop)
This is a version of C.A.R Hoare's Quick Sort algorithm.
array
- the array of objects to sortstart
- the start index to begin sortingstop
- the end index to stop sortingArrayIndexOutOfBoundsException
- when start < 0
or end >= array.length
public static void sort(Object[] array, int start, int end)
array
- the Object array to be sortedstart
- the start index to sortend
- the last + 1 index to sortClassCastException
- when an element in the array does not
implement Comparable or elements cannot be compared to each otherIllegalArgumentException
- when start > end
ArrayIndexOutOfBoundsException
- when start < 0
or end > array.size()
public static void dsort(Object[] array, int start, int end)
array
- the Object array to be sortedstart
- the start index to sortend
- the last + 1 index to sortClassCastException
- when an element in the array does not
implement Comparable or elements cannot be compared to each otherIllegalArgumentException
- when start > end
ArrayIndexOutOfBoundsException
- when start < 0
or end > array.size()
public static void swap(Object[] array)
array
- the Object array to be reversedpublic static String toString(Object object, int length)
object
- the object to convertlength
- the length the output stringpublic static String toString(Object object, int length, char pad, boolean onLeft)
object
- the object to convertlength
- the length the output stringpad
- the pad characteronLeft
- if true
pad on the left, otherwise an the rightCopyright © 2007–2018 The Apache Software Foundation. All rights reserved.