|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.golden.gamedev.util.Utility
Utility class for array enlargement/shrinkment, array mixed, calculate random value, and other methods that categorized in general methods.
Method Summary | |
static String[] |
compactStrings(String[] s)
Compacting String s to occupy less memory. |
static Object |
cut(Object src,
int position)
The original array is not changed, it creates a whole new array. |
static Object |
expand(Object src,
int increase)
Expands an array of object by specified size, src can not null . |
static Object |
expand(Object src,
int increase,
boolean bottom)
Expands an array of object by specified size, src can not null . |
static Object |
expand(Object src,
int increase,
boolean bottom,
Class type)
Expands an array of Class type object by specified size, src can be null . |
static int |
getRandom(int lowerBound,
int upperBound)
Returns random number, range from lowerbound to upperbound. |
static Random |
getRandomObject()
Returns pre-defined Random object. |
static int[] |
getShiftOperator(int num)
|
static void |
mixElements(Object src)
|
static int |
shiftDivide(int num,
int[] shift)
Working, but makes no sense, not benchmark yet, divide num by shift . |
static int |
shiftMultiply(int num,
int[] shift)
Working, but makes no sense, not benchmark yet, multiply num by shift . |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
public static Object cut(Object src, int position)
public static Object expand(Object src, int increase, boolean bottom)
src
can not null
.
src
- the array to expands, could be an array of primitive or an array of Object.
public static Object expand(Object src, int increase)
src
can not null
.
src
- the array to expands, could be an array of primitive or an array of Object.
public static Object expand(Object src, int increase, boolean bottom, Class type)
Class type
object by specified size, src
can be null
.
public static void mixElements(Object src)
public static Random getRandomObject()
public static int getRandom(int lowerBound, int upperBound)
public static String[] compactStrings(String[] s)
s
to occupy less memory.
Use this with a big array of String to save up memory. FileUtil.fileRead(File)
method returns compact string.
s
- an array of String to be compacted.
public static int shiftDivide(int num, int[] shift)
num
by shift
.
num
- the number to divideshift
- getShiftOperator(int)
public static int shiftMultiply(int num, int[] shift)
num
by shift
.
num
- the number to divideshift
- getShiftOperator(int)
public static int[] getShiftOperator(int num)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |