List of usage examples for java.util Arrays fill
public static void fill(Object[] a, Object val)
From source file:Main.java
public static Boolean[][] getEmptyMatrix(int sizeX, int sizeY) { Boolean[][] matrix = new Boolean[sizeX][sizeY]; if (sizeX > 0) { for (int i = 0; i < matrix.length; i++) { Arrays.fill(matrix[i], false); }/*from www. j a va 2 s. com*/ } return matrix; }
From source file:Main.java
public static double[] planckTaperWindow(int length, double e) { if (length < 1 || e <= 0 || e >= 0.5f) { return null; }/*www . ja v a 2 s .c o m*/ double[] planckTaperWindow = new double[length]; Arrays.fill(planckTaperWindow, 1); planckTaperWindow[0] = 0; planckTaperWindow[length - 1] = 0; for (int i = 1; i < e * (length - 1); i++) { double za = e * (length - 1) * (1.0f / i + 1.0f / (i - e * (length - 1))); planckTaperWindow[i] = 1.0f / (Math.exp(za) + 1); } for (int i = (int) (1 - e) * (length - 1); i < length - 1; i++) { double zb = e * (length - 1) * (1.0f / (length - 1 + i) + 1.0f / ((1 - e) * (length - 1) * (i))); planckTaperWindow[i] = 1.0f / (Math.exp(zb) + 1); } return planckTaperWindow; }
From source file:Main.java
public static byte[] createPinEncryption(String pin, String pan) { byte[] decryption = new byte[8]; byte[] bytePin = new byte[8]; byte[] bytePan = new byte[8]; Arrays.fill(bytePin, (byte) 0xFF); Arrays.fill(bytePan, (byte) 0x00); byte[] srcPin = HexStringToByteArray(pin); byte[] srcPan = HexStringToByteArray(pan); bytePin[0] = 0x06;/*from w ww.j ava2 s .c om*/ System.arraycopy(srcPin, 0, bytePin, 1, srcPin.length); System.arraycopy(srcPan, 2, bytePan, 2, srcPan.length - 2); for (int i = 0; i < 8; i++) { decryption[i] = (byte) (bytePin[i] ^ bytePan[i]); } return decryption; }
From source file:Main.java
/** * Fill the given array with the given value * @param <T> Type of array elements * @param array array to fill//from w w w . j av a 2 s. co m * @param value value to use * @return filled array */ public static <T> T[] fill(final T[] array, final T value) { Arrays.fill(array, value); return array; }
From source file:Main.java
public static byte[] repeat(byte b, int nrRepeats) { byte[] result = new byte[nrRepeats]; Arrays.fill(result, b); return result; }
From source file:Main.java
public static String byteToString(byte[] data) { int index = data.length; for (int i = 0; i < data.length; i++) { if (data[i] == 0) { index = i;/*from ww w . j a va 2 s . c o m*/ break; } } byte[] temp = new byte[index]; Arrays.fill(temp, (byte) 0); System.arraycopy(data, 0, temp, 0, index); String str; try { str = new String(temp, "GBK"); } catch (UnsupportedEncodingException e) { // TODO Auto-generated catch block e.printStackTrace(); return ""; } return str; }
From source file:Main.java
static String rjust(String string, char padding, int length) { if (string == null) { return null; }// w w w . ja v a2 s .c o m int paddingNum = length - string.length(); if (paddingNum < 1) { return string; } char[] pads = new char[paddingNum]; Arrays.fill(pads, padding); return new String(pads) + string; }
From source file:Main.java
public static Class[] params(Class cls1, Class clsFill, int times) { Class[] classes = new Class[times + 1]; Arrays.fill(classes, clsFill); classes[0] = cls1;/* w w w. j a va 2 s .com*/ return classes; }
From source file:Main.java
public static byte[] calMacCode(byte[] mak, byte[] src) { int srcLen = src.length; int m_len = srcLen % 8; int count = srcLen + (m_len == 0 ? m_len : (8 - m_len)); byte[] calData = new byte[count]; byte[] _data8 = new byte[8]; Arrays.fill(calData, (byte) 0); Arrays.fill(_data8, (byte) 0); System.arraycopy(src, 0, calData, 0, srcLen); System.arraycopy(calData, 0, _data8, 0, 8); for (int i = 1; i < count / 8; i++) { for (int j = 0; j < 8; j++) { _data8[j] = (byte) (_data8[j] ^ calData[i * 8 + j]); }//w w w. j av a 2 s. com } return TriDesEncryption(mak, _data8); }
From source file:Main.java
@NonNull private static Drawable getRippleMask(int color) { float[] outerRadii = new float[8]; // 3 is radius of final ripple, // instead of 3 you can give required final radius Arrays.fill(outerRadii, 3); RoundRectShape r = new RoundRectShape(outerRadii, null, null); ShapeDrawable shapeDrawable = new ShapeDrawable(r); shapeDrawable.getPaint().setColor(color); return shapeDrawable; }