|
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 boolean s. |
static byte[] |
rotateCopy(byte[] ar,
int amt)
Rotates an array of byte s. |
static char[] |
rotateCopy(char[] ar,
int amt)
Rotates an array of char s. |
static double[] |
rotateCopy(double[] ar,
int amt)
Rotates an array of double s. |
static float[] |
rotateCopy(float[] ar,
int amt)
Rotates an array of float s. |
static int[] |
rotateCopy(int[] ar,
int amt)
Rotates an array of int s. |
static long[] |
rotateCopy(long[] ar,
int amt)
Rotates an array of long s. |
static java.lang.Object[] |
rotateCopy(java.lang.Object[] ar,
int amt)
Rotates an array of Object s. |
static short[] |
rotateCopy(short[] ar,
int amt)
Rotates an array of short s. |
static boolean[] |
shiftCopy(boolean[] ar,
int amt)
Shifts an array of boolean s. |
static byte[] |
shiftCopy(byte[] ar,
int amt)
Shifts an array of byte s. |
static char[] |
shiftCopy(char[] ar,
int amt)
Shifts an array of char s. |
static double[] |
shiftCopy(double[] ar,
int amt)
Shifts an array of double s. |
static float[] |
shiftCopy(float[] ar,
int amt)
Shifts an array of float s. |
static int[] |
shiftCopy(int[] ar,
int amt)
Shifts an array of int s. |
static long[] |
shiftCopy(long[] ar,
int amt)
Shifts an array of long s. |
static java.lang.Object[] |
shiftCopy(java.lang.Object[] ar,
int amt)
Shifts an array of Object s. |
static short[] |
shiftCopy(short[] ar,
int amt)
Shifts an array of short s. |
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)
double
s.ar
- the arrayamt
- amount of rotationpublic static final float[] rotateCopy(float[] ar, int amt)
float
s.ar
- the arrayamt
- amount of rotationpublic static final long[] rotateCopy(long[] ar, int amt)
long
s.ar
- the arrayamt
- amount of rotationpublic static final int[] rotateCopy(int[] ar, int amt)
int
s.ar
- the arrayamt
- amount of rotationpublic static final short[] rotateCopy(short[] ar, int amt)
short
s.ar
- the arrayamt
- amount of rotationpublic static final byte[] rotateCopy(byte[] ar, int amt)
byte
s.ar
- the arrayamt
- amount of rotationpublic static final char[] rotateCopy(char[] ar, int amt)
char
s.ar
- the arrayamt
- amount of rotationpublic static final boolean[] rotateCopy(boolean[] ar, int amt)
boolean
s.ar
- the arrayamt
- amount of rotationpublic static final java.lang.Object[] rotateCopy(java.lang.Object[] ar, int amt)
Object
s.
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 rotationpublic static final java.lang.Object[] shiftCopy(java.lang.Object[] ar, int amt)
Object
s.
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 shiftpublic static final double[] shiftCopy(double[] ar, int amt)
double
s.ar
- the arrayamt
- amount of shiftpublic static final float[] shiftCopy(float[] ar, int amt)
float
s.ar
- the arrayamt
- amount of shiftpublic static final long[] shiftCopy(long[] ar, int amt)
long
s.ar
- the arrayamt
- amount of shiftpublic static final int[] shiftCopy(int[] ar, int amt)
int
s.ar
- the arrayamt
- amount of shiftpublic static final short[] shiftCopy(short[] ar, int amt)
short
s.ar
- the arrayamt
- amount of shiftpublic static final char[] shiftCopy(char[] ar, int amt)
char
s.ar
- the arrayamt
- amount of shiftpublic static final byte[] shiftCopy(byte[] ar, int amt)
byte
s.ar
- the arrayamt
- amount of shiftpublic static final boolean[] shiftCopy(boolean[] ar, int amt)
boolean
s.ar
- the arrayamt
- amount of shift
|
Sharkysoft home | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |