|
Sharkysoft home | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Object | +--lava.array.ArrayShifter
Shifts and rotates arrays.
Details: ArrayShifter is a collection of functions for shifting and rotating arrays.
Depending on the function name, the array is either manipulated in place, or the array is copied and then manipulated, leaving the original unmodified. In all cases, the manipulated result is returned.
Negative amounts for rotating and shifting indicate shifting towards the beginning (zero element) of the array, and positive values shift towards the end. Shifting by an amount greater than the length of the array produces an array filled with default values. Rotating by an amount greater than the length of the array produces the result you would expect to get if the array were repeatedly rotated by one element that many times.
Functions in this class are not thread-safe. If the input array is modified by another thread while it is being copied, shifted, or rotated, the results may be unpredictable. Users should develop their own thread-safety protocol for arrays that may be affected in this manner.
| Constructor Summary | |
ArrayShifter()
|
|
| Method Summary | |
static boolean[] |
rotateCopy(boolean[] ar,
int amt)
Rotates an array of booleans. |
static byte[] |
rotateCopy(byte[] ar,
int amt)
Rotates an array of bytes. |
static char[] |
rotateCopy(char[] ar,
int amt)
Rotates an array of chars. |
static double[] |
rotateCopy(double[] ar,
int amt)
Rotates an array of doubles. |
static float[] |
rotateCopy(float[] ar,
int amt)
Rotates an array of floats. |
static int[] |
rotateCopy(int[] ar,
int amt)
Rotates an array of ints. |
static long[] |
rotateCopy(long[] ar,
int amt)
Rotates an array of longs. |
static java.lang.Object[] |
rotateCopy(java.lang.Object[] ar,
int amt)
Rotates an array of Objects. |
static short[] |
rotateCopy(short[] ar,
int amt)
Rotates an array of shorts. |
static boolean[] |
shiftCopy(boolean[] ar,
int amt)
Shifts an array of booleans. |
static byte[] |
shiftCopy(byte[] ar,
int amt)
Shifts an array of bytes. |
static char[] |
shiftCopy(char[] ar,
int amt)
Shifts an array of chars. |
static double[] |
shiftCopy(double[] ar,
int amt)
Shifts an array of doubles. |
static float[] |
shiftCopy(float[] ar,
int amt)
Shifts an array of floats. |
static int[] |
shiftCopy(int[] ar,
int amt)
Shifts an array of ints. |
static long[] |
shiftCopy(long[] ar,
int amt)
Shifts an array of longs. |
static java.lang.Object[] |
shiftCopy(java.lang.Object[] ar,
int amt)
Shifts an array of Objects. |
static short[] |
shiftCopy(short[] ar,
int amt)
Shifts an array of shorts. |
| Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
| Constructor Detail |
public ArrayShifter()
| Method Detail |
public static final double[] rotateCopy(double[] ar,
int amt)
doubles.ar - the arrayamt - amount of rotation
public static final float[] rotateCopy(float[] ar,
int amt)
floats.ar - the arrayamt - amount of rotation
public static final long[] rotateCopy(long[] ar,
int amt)
longs.ar - the arrayamt - amount of rotation
public static final int[] rotateCopy(int[] ar,
int amt)
ints.ar - the arrayamt - amount of rotation
public static final short[] rotateCopy(short[] ar,
int amt)
shorts.ar - the arrayamt - amount of rotation
public static final byte[] rotateCopy(byte[] ar,
int amt)
bytes.ar - the arrayamt - amount of rotation
public static final char[] rotateCopy(char[] ar,
int amt)
chars.ar - the arrayamt - amount of rotation
public static final boolean[] rotateCopy(boolean[] ar,
int amt)
booleans.ar - the arrayamt - amount of rotation
public static final java.lang.Object[] rotateCopy(java.lang.Object[] ar,
int amt)
Objects.
Details: shiftCopy uses Java reflection to create a new array of the same type and length as the input, performs the rotate-copy, and returns the new array. The result should probably be type-casted into the desired array type.
ar - the arrayamt - amount of rotation
public static final java.lang.Object[] shiftCopy(java.lang.Object[] ar,
int amt)
Objects.
Details: shiftCopy uses Java reflection to create a new array of the same type and length as the input, performs the shift-copy, and returns the new array. The result should probably be type-casted into the desired array type.
ar - the arrayamt - amount of shift
public static final double[] shiftCopy(double[] ar,
int amt)
doubles.ar - the arrayamt - amount of shift
public static final float[] shiftCopy(float[] ar,
int amt)
floats.ar - the arrayamt - amount of shift
public static final long[] shiftCopy(long[] ar,
int amt)
longs.ar - the arrayamt - amount of shift
public static final int[] shiftCopy(int[] ar,
int amt)
ints.ar - the arrayamt - amount of shift
public static final short[] shiftCopy(short[] ar,
int amt)
shorts.ar - the arrayamt - amount of shift
public static final char[] shiftCopy(char[] ar,
int amt)
chars.ar - the arrayamt - amount of shift
public static final byte[] shiftCopy(byte[] ar,
int amt)
bytes.ar - the arrayamt - amount of shift
public static final boolean[] shiftCopy(boolean[] ar,
int amt)
booleans.ar - the arrayamt - amount of shift
|
Sharkysoft home | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||