List of utility methods to do Number Swap
int | swap(final int value) Performs a byte-order swap for a 32-bit signed integer. return (((value << 24) & 0xFF000000) | ((value << 8) & 0x00FF0000) | ((value >> 8) & 0x0000FF00)
| ((value >> 24) & 0x000000FF));
|
long | swap(int elementWidth, long value) swap return Long.reverseBytes(value) >>> (8 * (8 - elementWidth));
|
void | swap(Integer i, Integer j) swap System.out.println("i=" + i + ", j=" + j); if (i != j) { i ^= j; j ^= i; i ^= j; System.out.println("i=" + i + ", j=" + j); |
short | swap(short myShort) Swaps byte order, short. return (short) (((myShort & 0xff00) >> 8) | ((myShort & 0x00ff) << 8)); |
short | swap(short value) Swap the bytes in the value, thereby converting a big-endian value into a little-endian value (or vice versa). return (short) ((0x00ff & (value >>> 8)) | (0xff00 & (value << 8))); |
short | swap(short x) swap return (short) ((x << 8) | ((char) x >>> 8)); |
String | swap(String str, int i, int j) swap char[] chars = str.toCharArray(); char temp = chars[i]; chars[i] = chars[j]; chars[j] = temp; return String.valueOf(chars); |
void | swap(StringBuffer s, int i, int j) Swap s.charAt(i) and s.charAt(j). final char c = s.charAt(i); s.setCharAt(i, s.charAt(j)); s.setCharAt(j, c); |
void | swap(T a, T b) swap T temp = a; a = b; b = temp; |
T | swap(T... args) swap return args[0];
|