com.landawn.abacus.util.f Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of abacus-android-jdk7 Show documentation
Show all versions of abacus-android-jdk7 Show documentation
A general programming library in Java
/*
* Copyright (C) 2017 HaiYang Li
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*/
package com.landawn.abacus.util;
import java.math.RoundingMode;
import com.landawn.abacus.annotation.Beta;
@Beta
public final class f {
private static final String ARRAY_PRINT_SEPERATOR = StringUtil.repeat('-', 80);
static final char CHAR_0 = (char) 0;
static final byte BYTE_0 = (byte) 0;
static final byte BYTE_1 = (byte) 1;
static final short SHORT_0 = (short) 0;
private f() {
// utility class.
}
public static void replaceAlll(final T[] a, final Try.UnaryOperator operator) throws E {
if (N.isNullOrEmpty(a)) {
return;
}
for (int i = 0, n = a.length; i < n; i++) {
a[i] = operator.apply(a[i]);
}
}
public static void replaceAlll(final T[][] a, final Try.UnaryOperator operator) throws E {
if (N.isNullOrEmpty(a)) {
return;
}
for (int i = 0, n = a.length; i < n; i++) {
replaceAlll(a[i], operator);
}
}
public static void replaceAlll(final T[][][] a, final Try.UnaryOperator operator) throws E {
if (N.isNullOrEmpty(a)) {
return;
}
for (int i = 0, n = a.length; i < n; i++) {
replaceAlll(a[i], operator);
}
}
public static void replaceIff(final T[] a, final Try.Predicate super T, E> predicate, final T newValue) throws E {
if (N.isNullOrEmpty(a)) {
return;
}
for (int i = 0, n = a.length; i < n; i++) {
if (predicate.test(a[i])) {
a[i] = newValue;
}
}
}
public static void replaceIff(final T[][] a, final Try.Predicate super T, E> predicate, final T newValue) throws E {
if (N.isNullOrEmpty(a)) {
return;
}
for (int i = 0, n = a.length; i < n; i++) {
replaceIff(a[i], predicate, newValue);
}
}
public static void replaceIff(final T[][][] a, final Try.Predicate super T, E> predicate, final T newValue) throws E {
if (N.isNullOrEmpty(a)) {
return;
}
for (int i = 0, n = a.length; i < n; i++) {
replaceIff(a[i], predicate, newValue);
}
}
public static T[] flattenn(final T[][] a) {
int count = 0;
for (int i = 0, n = a.length; i < n; i++) {
count += (a[i] == null ? 0 : a[i].length);
}
final T[] c = N.newArray(a.getClass().getComponentType().getComponentType(), count);
int from = 0;
for (int i = 0, n = a.length; i < n; i++) {
if (N.isNullOrEmpty(a[i])) {
continue;
}
N.copy(a[i], 0, c, from, a[i].length);
from += a[i].length;
}
return c;
}
public static T[] flattenn(final T[][][] a) {
int count = 0;
for (int i = 0, n = a.length; i < n; i++) {
if (N.isNullOrEmpty(a[i])) {
continue;
}
for (int j = 0, m = a[i].length; j < m; j++) {
if (N.isNullOrEmpty(a[i][j])) {
continue;
}
count += (a[i][j] == null ? 0 : a[i][j].length);
}
}
final T[] c = N.newArray(a.getClass().getComponentType().getComponentType().getComponentType(), count);
int from = 0;
for (int i = 0, n = a.length; i < n; i++) {
if (N.isNullOrEmpty(a[i])) {
continue;
}
for (int j = 0, m = a[i].length; j < m; j++) {
if (N.isNullOrEmpty(a[i][j])) {
continue;
}
N.copy(a[i][j], 0, c, from, a[i][j].length);
from += a[i][j].length;
}
}
return c;
}
public static T[][] reshappe(final T[] a, final int m) {
N.checkArgument(m > 0, "'m' must be positive number: m = %s", m);
// if (N.isNullOrEmpty(a)) {
// return new T[0][0];
// }
final int len = a.length;
final int n = Matth.divide(len, m, RoundingMode.CEILING);
final T[][] c = N.newArray(a.getClass(), n);
for (int i = 0, from = 0; i < n; i++, from += m) {
c[i] = N.copyOfRange(a, from, from + N.min(len - from, m));
}
return c;
}
public static T[][][] reshappe(final T[] a, final int m, final int l) {
N.checkArgument(m > 0 && l > 0, "'m' and 'l' must be positive number: m = %s, l = %s", m, l);
// if (N.isNullOrEmpty(a)) {
// return new T[0][0][0];
// }
final int len = a.length;
final int n = Matth.divide(len, m * l, RoundingMode.CEILING);
final T[][][] c = N.newArray(N.newArray(a.getClass(), 0).getClass(), n);
for (int i = 0, from = 0; i < n; i++) {
c[i] = N.newArray(a.getClass(), N.min(m, Matth.divide(len - from, l, RoundingMode.CEILING)));
for (int j = 0, y = c[i].length; j < y; j++, from += l) {
c[i][j] = N.copyOfRange(a, from, from + N.min(len - from, l));
}
}
return c;
}
public static T[] mapp(final T[] a, final Try.UnaryOperator func) throws E {
if (a == null) {
return null;
}
return map((Class) a.getClass().getComponentType(), a, func);
}
public static R[] map(final Class cls, final T[] a, final Try.Function super T, R, E> func) throws E {
if (a == null) {
return null;
}
final int len = N.len(a);
final R[] c = N.newArray(cls, len);
for (int i = 0; i < len; i++) {
c[i] = func.apply(a[i]);
}
return c;
}
public static T[][] mapp(final T[][] a, final Try.UnaryOperator func) throws E {
if (a == null) {
return null;
}
return map((Class) a.getClass().getComponentType().getComponentType(), a, func);
}
public static R[][] map(final Class cls, final T[][] a, final Try.Function super T, R, E> func) throws E {
if (a == null) {
return null;
}
final int len = N.len(a);
final R[][] c = N.newArray(N.newArray(cls, 0).getClass(), len);
for (int i = 0; i < len; i++) {
c[i] = map(cls, a[i], func);
}
return c;
}
public static T[][][] mapp(final T[][][] a, final Try.UnaryOperator func) throws E {
if (a == null) {
return null;
}
return map((Class) a.getClass().getComponentType().getComponentType().getComponentType(), a, func);
}
public static R[][][] map(final Class cls, final T[][][] a, final Try.Function super T, R, E> func) throws E {
if (a == null) {
return null;
}
final int len = N.len(a);
final R[][][] c = N.newArray(N.newArray(N.newArray(cls, 0).getClass(), 0).getClass(), len);
for (int i = 0; i < len; i++) {
c[i] = map(cls, a[i], func);
}
return c;
}
public static boolean[] mapToBoolean(final T[] a, final Try.ToBooleanFunction super T, E> func) throws E {
if (a == null) {
return null;
}
final int len = N.len(a);
final boolean[] c = new boolean[len];
for (int i = 0; i < len; i++) {
c[i] = func.applyAsBoolean(a[i]);
}
return c;
}
public static boolean[][] mapToBoolean(final T[][] a, final Try.ToBooleanFunction super T, E> func) throws E {
if (a == null) {
return null;
}
final int len = N.len(a);
final boolean[][] c = new boolean[len][];
for (int i = 0; i < len; i++) {
c[i] = mapToBoolean(a[i], func);
}
return c;
}
public static boolean[][][] mapToBoolean(final T[][][] a, final Try.ToBooleanFunction super T, E> func) throws E {
if (a == null) {
return null;
}
final int len = N.len(a);
final boolean[][][] c = new boolean[len][][];
for (int i = 0; i < len; i++) {
c[i] = mapToBoolean(a[i], func);
}
return c;
}
public static char[] mapToChar(final T[] a, final Try.ToCharFunction super T, E> func) throws E {
if (a == null) {
return null;
}
final int len = N.len(a);
final char[] c = new char[len];
for (int i = 0; i < len; i++) {
c[i] = func.applyAsChar(a[i]);
}
return c;
}
public static char[][] mapToChar(final T[][] a, final Try.ToCharFunction super T, E> func) throws E {
if (a == null) {
return null;
}
final int len = N.len(a);
final char[][] c = new char[len][];
for (int i = 0; i < len; i++) {
c[i] = mapToChar(a[i], func);
}
return c;
}
public static char[][][] mapToChar(final T[][][] a, final Try.ToCharFunction super T, E> func) throws E {
if (a == null) {
return null;
}
final int len = N.len(a);
final char[][][] c = new char[len][][];
for (int i = 0; i < len; i++) {
c[i] = mapToChar(a[i], func);
}
return c;
}
public static byte[] mapToByte(final T[] a, final Try.ToByteFunction super T, E> func) throws E {
if (a == null) {
return null;
}
final int len = N.len(a);
final byte[] c = new byte[len];
for (int i = 0; i < len; i++) {
c[i] = func.applyAsByte(a[i]);
}
return c;
}
public static byte[][] mapToByte(final T[][] a, final Try.ToByteFunction super T, E> func) throws E {
if (a == null) {
return null;
}
final int len = N.len(a);
final byte[][] c = new byte[len][];
for (int i = 0; i < len; i++) {
c[i] = mapToByte(a[i], func);
}
return c;
}
public static byte[][][] mapToByte(final T[][][] a, final Try.ToByteFunction super T, E> func) throws E {
if (a == null) {
return null;
}
final int len = N.len(a);
final byte[][][] c = new byte[len][][];
for (int i = 0; i < len; i++) {
c[i] = mapToByte(a[i], func);
}
return c;
}
public static short[] mapToShort(final T[] a, final Try.ToShortFunction super T, E> func) throws E {
if (a == null) {
return null;
}
final int len = N.len(a);
final short[] c = new short[len];
for (int i = 0; i < len; i++) {
c[i] = func.applyAsShort(a[i]);
}
return c;
}
public static short[][] mapToShort(final T[][] a, final Try.ToShortFunction super T, E> func) throws E {
if (a == null) {
return null;
}
final int len = N.len(a);
final short[][] c = new short[len][];
for (int i = 0; i < len; i++) {
c[i] = mapToShort(a[i], func);
}
return c;
}
public static short[][][] mapToShort(final T[][][] a, final Try.ToShortFunction super T, E> func) throws E {
if (a == null) {
return null;
}
final int len = N.len(a);
final short[][][] c = new short[len][][];
for (int i = 0; i < len; i++) {
c[i] = mapToShort(a[i], func);
}
return c;
}
public static int[] mapToInt(final T[] a, final Try.ToIntFunction super T, E> func) throws E {
if (a == null) {
return null;
}
final int len = N.len(a);
final int[] c = new int[len];
for (int i = 0; i < len; i++) {
c[i] = func.applyAsInt(a[i]);
}
return c;
}
public static int[][] mapToInt(final T[][] a, final Try.ToIntFunction super T, E> func) throws E {
if (a == null) {
return null;
}
final int len = N.len(a);
final int[][] c = new int[len][];
for (int i = 0; i < len; i++) {
c[i] = mapToInt(a[i], func);
}
return c;
}
public static int[][][] mapToInt(final T[][][] a, final Try.ToIntFunction super T, E> func) throws E {
if (a == null) {
return null;
}
final int len = N.len(a);
final int[][][] c = new int[len][][];
for (int i = 0; i < len; i++) {
c[i] = mapToInt(a[i], func);
}
return c;
}
public static long[] mapToLong(final T[] a, final Try.ToLongFunction super T, E> func) throws E {
if (a == null) {
return null;
}
final int len = N.len(a);
final long[] c = new long[len];
for (int i = 0; i < len; i++) {
c[i] = func.applyAsLong(a[i]);
}
return c;
}
public static long[][] mapToLong(final T[][] a, final Try.ToLongFunction super T, E> func) throws E {
if (a == null) {
return null;
}
final int len = N.len(a);
final long[][] c = new long[len][];
for (int i = 0; i < len; i++) {
c[i] = mapToLong(a[i], func);
}
return c;
}
public static long[][][] mapToLong(final T[][][] a, final Try.ToLongFunction super T, E> func) throws E {
if (a == null) {
return null;
}
final int len = N.len(a);
final long[][][] c = new long[len][][];
for (int i = 0; i < len; i++) {
c[i] = mapToLong(a[i], func);
}
return c;
}
public static float[] mapToFloat(final T[] a, final Try.ToFloatFunction super T, E> func) throws E {
if (a == null) {
return null;
}
final int len = N.len(a);
final float[] c = new float[len];
for (int i = 0; i < len; i++) {
c[i] = func.applyAsFloat(a[i]);
}
return c;
}
public static float[][] mapToFloat(final T[][] a, final Try.ToFloatFunction super T, E> func) throws E {
if (a == null) {
return null;
}
final int len = N.len(a);
final float[][] c = new float[len][];
for (int i = 0; i < len; i++) {
c[i] = mapToFloat(a[i], func);
}
return c;
}
public static float[][][] mapToFloat(final T[][][] a, final Try.ToFloatFunction super T, E> func) throws E {
if (a == null) {
return null;
}
final int len = N.len(a);
final float[][][] c = new float[len][][];
for (int i = 0; i < len; i++) {
c[i] = mapToFloat(a[i], func);
}
return c;
}
public static double[] mapToDouble(final T[] a, final Try.ToDoubleFunction super T, E> func) throws E {
if (a == null) {
return null;
}
final int len = N.len(a);
final double[] c = new double[len];
for (int i = 0; i < len; i++) {
c[i] = func.applyAsDouble(a[i]);
}
return c;
}
public static double[][] mapToDouble(final T[][] a, final Try.ToDoubleFunction super T, E> func) throws E {
if (a == null) {
return null;
}
final int len = N.len(a);
final double[][] c = new double[len][];
for (int i = 0; i < len; i++) {
c[i] = mapToDouble(a[i], func);
}
return c;
}
public static double[][][] mapToDouble(final T[][][] a, final Try.ToDoubleFunction super T, E> func) throws E {
if (a == null) {
return null;
}
final int len = N.len(a);
final double[][][] c = new double[len][][];
for (int i = 0; i < len; i++) {
c[i] = mapToDouble(a[i], func);
}
return c;
}
public static T[] mapToObj(final Class cls, final boolean[] a, final Try.BooleanFunction extends T, E> mapper) throws E {
if (a == null) {
return null;
}
final int len = N.len(a);
final T[] result = N.newArray(cls, len);
for (int i = 0; i < len; i++) {
result[i] = mapper.apply(a[i]);
}
return result;
}
public static T[][] mapToObj(final Class cls, final boolean[][] a, final Try.BooleanFunction extends T, E> mapper) throws E {
if (a == null) {
return null;
}
final int len = N.len(a);
final T[][] result = N.newArray(N.newArray(cls, 0).getClass(), len);
for (int i = 0; i < len; i++) {
result[i] = mapToObj(cls, a[i], mapper);
}
return result;
}
public static T[][][] mapToObj(final Class cls, final boolean[][][] a, final Try.BooleanFunction extends T, E> mapper)
throws E {
if (a == null) {
return null;
}
final int len = N.len(a);
final T[][][] result = N.newArray(N.newArray(N.newArray(cls, 0).getClass(), 0).getClass(), len);
for (int i = 0; i < len; i++) {
result[i] = mapToObj(cls, a[i], mapper);
}
return result;
}
public static T[] mapToObj(final Class cls, final char[] a, final Try.CharFunction extends T, E> mapper) throws E {
if (a == null) {
return null;
}
final int len = N.len(a);
final T[] result = N.newArray(cls, len);
for (int i = 0; i < len; i++) {
result[i] = mapper.apply(a[i]);
}
return result;
}
public static T[][] mapToObj(final Class cls, final char[][] a, final Try.CharFunction extends T, E> mapper) throws E {
if (a == null) {
return null;
}
final int len = N.len(a);
final T[][] result = N.newArray(N.newArray(cls, 0).getClass(), len);
for (int i = 0; i < len; i++) {
result[i] = mapToObj(cls, a[i], mapper);
}
return result;
}
public static T[][][] mapToObj(final Class cls, final char[][][] a, final Try.CharFunction extends T, E> mapper) throws E {
if (a == null) {
return null;
}
final int len = N.len(a);
final T[][][] result = N.newArray(N.newArray(N.newArray(cls, 0).getClass(), 0).getClass(), len);
for (int i = 0; i < len; i++) {
result[i] = mapToObj(cls, a[i], mapper);
}
return result;
}
public static T[] mapToObj(final Class cls, final byte[] a, final Try.ByteFunction extends T, E> mapper) throws E {
if (a == null) {
return null;
}
final int len = N.len(a);
final T[] result = N.newArray(cls, len);
for (int i = 0; i < len; i++) {
result[i] = mapper.apply(a[i]);
}
return result;
}
public static T[][] mapToObj(final Class cls, final byte[][] a, final Try.ByteFunction extends T, E> mapper) throws E {
if (a == null) {
return null;
}
final int len = N.len(a);
final T[][] result = N.newArray(N.newArray(cls, 0).getClass(), len);
for (int i = 0; i < len; i++) {
result[i] = mapToObj(cls, a[i], mapper);
}
return result;
}
public static T[][][] mapToObj(final Class cls, final byte[][][] a, final Try.ByteFunction extends T, E> mapper) throws E {
if (a == null) {
return null;
}
final int len = N.len(a);
final T[][][] result = N.newArray(N.newArray(N.newArray(cls, 0).getClass(), 0).getClass(), len);
for (int i = 0; i < len; i++) {
result[i] = mapToObj(cls, a[i], mapper);
}
return result;
}
public static T[] mapToObj(final Class cls, final short[] a, final Try.ShortFunction extends T, E> mapper) throws E {
if (a == null) {
return null;
}
final int len = N.len(a);
final T[] result = N.newArray(cls, len);
for (int i = 0; i < len; i++) {
result[i] = mapper.apply(a[i]);
}
return result;
}
public static T[][] mapToObj(final Class cls, final short[][] a, final Try.ShortFunction extends T, E> mapper) throws E {
if (a == null) {
return null;
}
final int len = N.len(a);
final T[][] result = N.newArray(N.newArray(cls, 0).getClass(), len);
for (int i = 0; i < len; i++) {
result[i] = mapToObj(cls, a[i], mapper);
}
return result;
}
public static T[][][] mapToObj(final Class cls, final short[][][] a, final Try.ShortFunction extends T, E> mapper) throws E {
if (a == null) {
return null;
}
final int len = N.len(a);
final T[][][] result = N.newArray(N.newArray(N.newArray(cls, 0).getClass(), 0).getClass(), len);
for (int i = 0; i < len; i++) {
result[i] = mapToObj(cls, a[i], mapper);
}
return result;
}
public static T[] mapToObj(final Class cls, final int[] a, final Try.IntFunction extends T, E> mapper) throws E {
if (a == null) {
return null;
}
final int len = N.len(a);
final T[] result = N.newArray(cls, len);
for (int i = 0; i < len; i++) {
result[i] = mapper.apply(a[i]);
}
return result;
}
public static T[][] mapToObj(final Class cls, final int[][] a, final Try.IntFunction extends T, E> mapper) throws E {
if (a == null) {
return null;
}
final int len = N.len(a);
final T[][] result = N.newArray(N.newArray(cls, 0).getClass(), len);
for (int i = 0; i < len; i++) {
result[i] = mapToObj(cls, a[i], mapper);
}
return result;
}
public static T[][][] mapToObj(final Class cls, final int[][][] a, final Try.IntFunction extends T, E> mapper) throws E {
if (a == null) {
return null;
}
final int len = N.len(a);
final T[][][] result = N.newArray(N.newArray(N.newArray(cls, 0).getClass(), 0).getClass(), len);
for (int i = 0; i < len; i++) {
result[i] = mapToObj(cls, a[i], mapper);
}
return result;
}
public static T[] mapToObj(final Class cls, final long[] a, final Try.LongFunction extends T, E> mapper) throws E {
if (a == null) {
return null;
}
final int len = N.len(a);
final T[] result = N.newArray(cls, len);
for (int i = 0; i < len; i++) {
result[i] = mapper.apply(a[i]);
}
return result;
}
public static T[][] mapToObj(final Class cls, final long[][] a, final Try.LongFunction extends T, E> mapper) throws E {
if (a == null) {
return null;
}
final int len = N.len(a);
final T[][] result = N.newArray(N.newArray(cls, 0).getClass(), len);
for (int i = 0; i < len; i++) {
result[i] = mapToObj(cls, a[i], mapper);
}
return result;
}
public static T[][][] mapToObj(final Class cls, final long[][][] a, final Try.LongFunction extends T, E> mapper) throws E {
if (a == null) {
return null;
}
final int len = N.len(a);
final T[][][] result = N.newArray(N.newArray(N.newArray(cls, 0).getClass(), 0).getClass(), len);
for (int i = 0; i < len; i++) {
result[i] = mapToObj(cls, a[i], mapper);
}
return result;
}
public static T[] mapToObj(final Class cls, final float[] a, final Try.FloatFunction extends T, E> mapper) throws E {
if (a == null) {
return null;
}
final int len = N.len(a);
final T[] result = N.newArray(cls, len);
for (int i = 0; i < len; i++) {
result[i] = mapper.apply(a[i]);
}
return result;
}
public static T[][] mapToObj(final Class cls, final float[][] a, final Try.FloatFunction extends T, E> mapper) throws E {
if (a == null) {
return null;
}
final int len = N.len(a);
final T[][] result = N.newArray(N.newArray(cls, 0).getClass(), len);
for (int i = 0; i < len; i++) {
result[i] = mapToObj(cls, a[i], mapper);
}
return result;
}
public static T[][][] mapToObj(final Class cls, final float[][][] a, final Try.FloatFunction extends T, E> mapper) throws E {
if (a == null) {
return null;
}
final int len = N.len(a);
final T[][][] result = N.newArray(N.newArray(N.newArray(cls, 0).getClass(), 0).getClass(), len);
for (int i = 0; i < len; i++) {
result[i] = mapToObj(cls, a[i], mapper);
}
return result;
}
public static T[] mapToObj(final Class cls, final double[] a, final Try.DoubleFunction extends T, E> mapper) throws E {
if (a == null) {
return null;
}
final int len = N.len(a);
final T[] result = N.newArray(cls, len);
for (int i = 0; i < len; i++) {
result[i] = mapper.apply(a[i]);
}
return result;
}
public static T[][] mapToObj(final Class cls, final double[][] a, final Try.DoubleFunction extends T, E> mapper) throws E {
if (a == null) {
return null;
}
final int len = N.len(a);
final T[][] result = N.newArray(N.newArray(cls, 0).getClass(), len);
for (int i = 0; i < len; i++) {
result[i] = mapToObj(cls, a[i], mapper);
}
return result;
}
public static T[][][] mapToObj(final Class cls, final double[][][] a, final Try.DoubleFunction extends T, E> mapper)
throws E {
if (a == null) {
return null;
}
final int len = N.len(a);
final T[][][] result = N.newArray(N.newArray(N.newArray(cls, 0).getClass(), 0).getClass(), len);
for (int i = 0; i < len; i++) {
result[i] = mapToObj(cls, a[i], mapper);
}
return result;
}
public static A[] zipp(final A[] a, final B[] b, final Try.BiFunction super A, ? super B, A, E> zipFunction) throws E {
return zip((Class) a.getClass().getComponentType(), a, b, zipFunction);
}
public static R[] zip(final Class cls, final A[] a, final B[] b,
final Try.BiFunction super A, ? super B, R, E> zipFunction) throws E {
final int lenA = N.len(a);
final int lenB = N.len(b);
final R[] result = N.newArray(cls, N.min(lenA, lenB));
for (int i = 0, len = result.length; i < len; i++) {
result[i] = zipFunction.apply(a[i], b[i]);
}
return result;
}
public static A[] zipp(final A[] a, final B[] b, final A valueForNoneA, final B valueForNoneB,
final Try.BiFunction super A, ? super B, A, E> zipFunction) throws E {
return zip((Class) a.getClass().getComponentType(), a, b, valueForNoneA, valueForNoneB, zipFunction);
}
public static R[] zip(final Class cls, final A[] a, final B[] b, final A valueForNoneA, final B valueForNoneB,
final Try.BiFunction super A, ? super B, R, E> zipFunction) throws E {
final int lenA = N.len(a);
final int lenB = N.len(b);
return zip(N.max(lenA, lenB), cls, a, b, valueForNoneA, valueForNoneB, zipFunction);
}
private static R[] zip(final int len, final Class cls, final A[] a, final B[] b, final A valueForNoneA,
final B valueForNoneB, final Try.BiFunction super A, ? super B, R, E> zipFunction) throws E {
final int lenA = N.len(a);
final int lenB = N.len(b);
final R[] result = N.newArray(cls, len);
for (int i = 0, min = N.min(lenA, lenB, len); i < min; i++) {
result[i] = zipFunction.apply(a[i], b[i]);
}
if (lenA < lenB && lenA < len) {
for (int i = lenA, min = N.min(lenB, len); i < min; i++) {
result[i] = zipFunction.apply(valueForNoneA, b[i]);
}
} else if (lenB < lenA && lenB < len) {
for (int i = lenB, min = N.min(lenA, len); i < min; i++) {
result[i] = zipFunction.apply(a[i], valueForNoneB);
}
}
if (N.max(lenA, lenB) < len) {
for (int i = N.max(lenA, lenB); i < len; i++) {
result[i] = zipFunction.apply(valueForNoneA, valueForNoneB);
}
}
return result;
}
public static A[] zipp(final A[] a, final B[] b, final C[] c,
final Try.TriFunction super A, ? super B, ? super C, A, E> zipFunction) throws E {
return zip((Class) a.getClass().getComponentType(), a, b, c, zipFunction);
}
public static R[] zip(final Class cls, final A[] a, final B[] b, final C[] c,
final Try.TriFunction super A, ? super B, ? super C, R, E> zipFunction) throws E {
final int lenA = N.len(a);
final int lenB = N.len(b);
final int lenC = N.len(c);
final R[] result = N.newArray(cls, N.min(lenA, lenB, lenC));
for (int i = 0, len = result.length; i < len; i++) {
result[i] = zipFunction.apply(a[i], b[i], c[i]);
}
return result;
}
public static A[] zipp(final A[] a, final B[] b, final C[] c, final A valueForNoneA, final B valueForNoneB,
final C valueForNoneC, final Try.TriFunction super A, ? super B, ? super C, A, E> zipFunction) throws E {
return zip((Class) a.getClass().getComponentType(), a, b, c, valueForNoneA, valueForNoneB, valueForNoneC, zipFunction);
}
public static R[] zip(final Class cls, final A[] a, final B[] b, final C[] c, final A valueForNoneA,
final B valueForNoneB, final C valueForNoneC, final Try.TriFunction super A, ? super B, ? super C, R, E> zipFunction) throws E {
final int lenA = N.len(a);
final int lenB = N.len(b);
final int lenC = N.len(c);
return zip(N.max(lenA, lenB, lenC), cls, a, b, c, valueForNoneA, valueForNoneB, valueForNoneC, zipFunction);
}
private static R[] zip(final int len, final Class cls, final A[] a, final B[] b, final C[] c, final A valueForNoneA,
final B valueForNoneB, final C valueForNoneC, final Try.TriFunction super A, ? super B, ? super C, R, E> zipFunction) throws E {
final int lenA = N.len(a);
final int lenB = N.len(b);
final int lenC = N.len(c);
final R[] result = N.newArray(cls, len);
for (int i = 0, min = N.min(lenA, lenB, lenC, len); i < min; i++) {
result[i] = zipFunction.apply(a[i], b[i], c[i]);
}
if (N.min(lenA, lenB, lenC) < len) {
for (int i = N.min(lenA, lenB, lenC); i < len; i++) {
result[i] = zipFunction.apply(i < lenA ? a[i] : valueForNoneA, i < lenB ? b[i] : valueForNoneB, i < lenC ? c[i] : valueForNoneC);
}
}
return result;
}
public static A[][] zipp(final A[][] a, final B[][] b, final Try.BiFunction super A, ? super B, A, E> zipFunction) throws E {
return zip((Class) a.getClass().getComponentType().getComponentType(), a, b, zipFunction);
}
public static R[][] zip(final Class cls, final A[][] a, final B[][] b,
final Try.BiFunction super A, ? super B, R, E> zipFunction) throws E {
final int lenA = N.len(a);
final int lenB = N.len(b);
final R[][] result = N.newArray(N.newArray(cls, 0).getClass(), N.min(lenA, lenB));
for (int i = 0, len = result.length; i < len; i++) {
result[i] = zip(cls, a[i], b[i], zipFunction);
}
return result;
}
public static A[][] zipp(final A[][] a, final B[][] b, final A valueForNoneA, final B valueForNoneB,
final Try.BiFunction super A, ? super B, A, E> zipFunction) throws E {
return zip((Class) a.getClass().getComponentType().getComponentType(), a, b, valueForNoneA, valueForNoneB, zipFunction);
}
public static R[][] zip(final Class cls, final A[][] a, final B[][] b, final A valueForNoneA, final B valueForNoneB,
final Try.BiFunction super A, ? super B, R, E> zipFunction) throws E {
return zip(N.max(N.len(a), N.len(b)), N.max(maxSubArrayLen(a), maxSubArrayLen(b)), cls, a, b, valueForNoneA, valueForNoneB, zipFunction);
}
private static R[][] zip(final int len, final int rowLen, final Class cls, final A[][] a, final B[][] b,
final A valueForNoneA, final B valueForNoneB, final Try.BiFunction super A, ? super B, R, E> zipFunction) throws E {
final int lenA = N.len(a);
final int lenB = N.len(b);
final R[][] result = N.newArray(N.newArray(cls, 0).getClass(), len);
for (int i = 0, min = N.min(lenA, lenB, len); i < min; i++) {
result[i] = zip(rowLen, cls, a[i], b[i], valueForNoneA, valueForNoneB, zipFunction);
}
if (lenA < lenB && lenA < len) {
for (int i = lenA, min = N.min(lenB, len); i < min; i++) {
result[i] = zip(rowLen, cls, null, b[i], valueForNoneA, valueForNoneB, zipFunction);
}
} else if (lenB < lenA && lenB < len) {
for (int i = lenB, min = N.min(lenA, len); i < min; i++) {
result[i] = zip(rowLen, cls, a[i], null, valueForNoneA, valueForNoneB, zipFunction);
}
}
if (N.max(lenA, lenB) < len) {
for (int i = N.max(lenA, lenB); i < len; i++) {
result[i] = zip(rowLen, cls, null, null, valueForNoneA, valueForNoneB, zipFunction);
}
}
return result;
}
public static A[][] zipp(final A[][] a, final B[][] b, final C[][] c,
final Try.TriFunction super A, ? super B, ? super C, A, E> zipFunction) throws E {
return zip((Class) a.getClass().getComponentType().getComponentType(), a, b, c, zipFunction);
}
public static R[][] zip(final Class cls, final A[][] a, final B[][] b, final C[][] c,
final Try.TriFunction super A, ? super B, ? super C, R, E> zipFunction) throws E {
final int lenA = N.len(a);
final int lenB = N.len(b);
final int lenC = N.len(c);
final R[][] result = N.newArray(N.newArray(cls, 0).getClass(), N.min(lenA, lenB, lenC));
for (int i = 0, len = result.length; i < len; i++) {
result[i] = zip(cls, a[i], b[i], c[i], zipFunction);
}
return result;
}
public static A[][] zipp(final A[][] a, final B[][] b, final C[][] c, final A valueForNoneA, final B valueForNoneB,
final C valueForNoneC, final Try.TriFunction super A, ? super B, ? super C, A, E> zipFunction) throws E {
return zip((Class) a.getClass().getComponentType().getComponentType(), a, b, c, valueForNoneA, valueForNoneB, valueForNoneC, zipFunction);
}
public static R[][] zip(final Class cls, final A[][] a, final B[][] b, final C[][] c, final A valueForNoneA,
final B valueForNoneB, final C valueForNoneC, final Try.TriFunction super A, ? super B, ? super C, R, E> zipFunction) throws E {
return zip(N.max(N.len(a), N.len(b), N.len(c)), N.max(maxSubArrayLen(a), maxSubArrayLen(b), maxSubArrayLen(c)), cls, a, b, c, valueForNoneA,
valueForNoneB, valueForNoneC, zipFunction);
}
private static R[][] zip(final int len, final int rowLen, final Class cls, final A[][] a, final B[][] b, final C[][] c,
final A valueForNoneA, final B valueForNoneB, final C valueForNoneC, final Try.TriFunction super A, ? super B, ? super C, R, E> zipFunction)
throws E {
final int lenA = N.len(a);
final int lenB = N.len(b);
final int lenC = N.len(c);
final R[][] result = N.newArray(N.newArray(cls, 0).getClass(), len);
for (int i = 0, min = N.min(lenA, lenB, lenC, len); i < min; i++) {
result[i] = zip(rowLen, cls, a[i], b[i], c[i], valueForNoneA, valueForNoneB, valueForNoneC, zipFunction);
}
if (N.min(lenA, lenB, lenC) < len) {
for (int i = N.min(lenA, lenB, lenC); i < len; i++) {
result[i] = zip(rowLen, cls, i < lenA ? a[i] : null, i < lenB ? b[i] : null, i < lenC ? c[i] : null, valueForNoneA, valueForNoneB,
valueForNoneC, zipFunction);
}
}
return result;
}
public static A[][][] zipp(final A[][][] a, final B[][][] b, final Try.BiFunction super A, ? super B, A, E> zipFunction)
throws E {
return zip((Class) a.getClass().getComponentType().getComponentType().getComponentType(), a, b, zipFunction);
}
public static R[][][] zip(final Class cls, final A[][][] a, final B[][][] b,
final Try.BiFunction super A, ? super B, R, E> zipFunction) throws E {
final int lenA = N.len(a);
final int lenB = N.len(b);
final R[][][] result = N.newArray(N.newArray(N.newArray(cls, 0).getClass(), 0).getClass(), N.min(lenA, lenB));
for (int i = 0, len = result.length; i < len; i++) {
result[i] = zip(cls, a[i], b[i], zipFunction);
}
return result;
}
public static A[][][] zipp(final A[][][] a, final B[][][] b, final A valueForNoneA, final B valueForNoneB,
final Try.BiFunction super A, ? super B, A, E> zipFunction) throws E {
return zip((Class) a.getClass().getComponentType().getComponentType().getComponentType(), a, b, valueForNoneA, valueForNoneB, zipFunction);
}
public static R[][][] zip(final Class cls, final A[][][] a, final B[][][] b, final A valueForNoneA, final B valueForNoneB,
final Try.BiFunction super A, ? super B, R, E> zipFunction) throws E {
final int lenA = N.len(a);
final int lenB = N.len(b);
final R[][][] result = N.newArray(N.newArray(N.newArray(cls, 0).getClass(), 0).getClass(), N.max(lenA, lenB));
for (int i = 0, min = N.min(lenA, lenB); i < min; i++) {
result[i] = zip(cls, a[i], b[i], valueForNoneA, valueForNoneB, zipFunction);
}
if (lenA < lenB) {
for (int i = lenA; i < lenB; i++) {
result[i] = zip(cls, null, b[i], valueForNoneA, valueForNoneB, zipFunction);
}
} else if (lenB < lenA) {
for (int i = lenB; i < lenA; i++) {
result[i] = zip(cls, a[i], null, valueForNoneA, valueForNoneB, zipFunction);
}
}
return result;
}
public static A[][][] zipp(final A[][][] a, final B[][][] b, final C[][][] c,
final Try.TriFunction super A, ? super B, ? super C, A, E> zipFunction) throws E {
return zip((Class) a.getClass().getComponentType().getComponentType().getComponentType(), a, b, c, zipFunction);
}
public static R[][][] zip(final Class cls, final A[][][] a, final B[][][] b, final C[][][] c,
final Try.TriFunction super A, ? super B, ? super C, R, E> zipFunction) throws E {
final int lenA = N.len(a);
final int lenB = N.len(b);
final int lenC = N.len(c);
final R[][][] result = N.newArray(N.newArray(N.newArray(cls, 0).getClass(), 0).getClass(), N.min(lenA, lenB, lenC));
for (int i = 0, len = result.length; i < len; i++) {
result[i] = zip(cls, a[i], b[i], c[i], zipFunction);
}
return result;
}
public static A[][][] zipp(final A[][][] a, final B[][][] b, final C[][][] c, final A valueForNoneA, final B valueForNoneB,
final C valueForNoneC, final Try.TriFunction super A, ? super B, ? super C, A, E> zipFunction) throws E {
return zip((Class) a.getClass().getComponentType().getComponentType().getComponentType(), a, b, c, valueForNoneA, valueForNoneB, valueForNoneC,
zipFunction);
}
public static R[][][] zip(final Class cls, final A[][][] a, final B[][][] b, final C[][][] c, final A valueForNoneA,
final B valueForNoneB, final C valueForNoneC, final Try.TriFunction super A, ? super B, ? super C, R, E> zipFunction) throws E {
final int lenA = N.len(a);
final int lenB = N.len(b);
final int lenC = N.len(c);
final R[][][] result = N.newArray(N.newArray(N.newArray(cls, 0).getClass(), 0).getClass(), N.max(lenA, lenB, lenC));
for (int i = 0, min = N.min(lenA, lenB, lenC); i < min; i++) {
result[i] = zip(cls, a[i], b[i], c[i], valueForNoneA, valueForNoneB, valueForNoneC, zipFunction);
}
for (int i = N.min(lenA, lenB, lenC), len = result.length; i < len; i++) {
result[i] = zip(cls, i < lenA ? a[i] : null, i < lenB ? b[i] : null, i < lenC ? c[i] : null, valueForNoneA, valueForNoneB, valueForNoneC,
zipFunction);
}
return result;
}
public static T[] copy(Class newType, Object[] a) {
if (N.isNullOrEmpty(a)) {
return N.newArray(newType.getComponentType(), 0);
}
return N.copyOf(a, a.length, newType);
}
public static T[][] copy(Class newType, Object[][] a) {
final Class componentType = (Class) newType.getComponentType();
if (N.isNullOrEmpty(a)) {
return N.newArray(componentType, 0);
}
final int len = N.len(a);
final T[][] result = N.newArray(componentType, len);
for (int i = 0; i < len; i++) {
result[i] = copy(componentType, a[i]);
}
return result;
}
public static T[][][] copy(Class newType, Object[][][] a) {
final Class componentType = (Class) newType.getComponentType();
if (N.isNullOrEmpty(a)) {
return N.newArray(componentType, 0);
}
final int len = N.len(a);
final T[][][] result = N.newArray(componentType, len);
for (int i = 0; i < len; i++) {
result[i] = copy(componentType, a[i]);
}
return result;
}
public static void println(final T[] a) {
if (a == null) {
N.println("null");
} else if (a.length == 0) {
N.println("[]");
} else {
N.println(a);
}
}
public static void println(final T[][] a) {
if (a == null) {
N.println("null");
} else if (a.length == 0) {
N.println("[]");
} else {
final int len = N.len(a);
for (int i = 0; i < len; i++) {
println(a[i]);
}
}
}
public static void println(final T[][][] a) {
if (a == null) {
N.println("null");
} else if (a.length == 0) {
N.println("[]");
} else {
final int len = N.len(a);
for (int i = 0; i < len; i++) {
if (i > 0) {
N.println(ARRAY_PRINT_SEPERATOR);
}
println(a[i]);
}
}
}
public static int minSubArrayLen(T[][] a) {
if (a == null) {
return 0;
}
final int len = a.length;
int minLen = 0;
for (int i = 0; i < len; i++) {
minLen = N.min(minLen, a[i] == null ? 0 : a[i].length);
}
return minLen;
}
public static int maxSubArrayLen(T[][] a) {
if (a == null) {
return 0;
}
final int len = N.len(a);
int maxLen = 0;
for (int i = 0; i < len; i++) {
maxLen = N.max(maxLen, a[i] == null ? 0 : a[i].length);
}
return maxLen;
}
public static void replaceAll(final boolean[] a, final Try.BooleanUnaryOperator operator) throws E {
if (N.isNullOrEmpty(a)) {
return;
}
for (int i = 0, n = a.length; i < n; i++) {
a[i] = operator.applyAsBoolean(a[i]);
}
}
public static void replaceAll(final boolean[][] a, final Try.BooleanUnaryOperator operator) throws E {
if (N.isNullOrEmpty(a)) {
return;
}
for (int i = 0, n = a.length; i < n; i++) {
replaceAll(a[i], operator);
}
}
public static void replaceAll(final boolean[][][] a, final Try.BooleanUnaryOperator operator) throws E {
if (N.isNullOrEmpty(a)) {
return;
}
for (int i = 0, n = a.length; i < n; i++) {
replaceAll(a[i], operator);
}
}
public static void replaceIf(final boolean[] a, final Try.BooleanPredicate predicate, final boolean newValue) throws E {
if (N.isNullOrEmpty(a)) {
return;
}
for (int i = 0, n = a.length; i < n; i++) {
if (predicate.test(a[i])) {
a[i] = newValue;
}
}
}
public static void replaceIf(final boolean[][] a, final Try.BooleanPredicate predicate, final boolean newValue) throws E {
if (N.isNullOrEmpty(a)) {
return;
}
for (int i = 0, n = a.length; i < n; i++) {
replaceIf(a[i], predicate, newValue);
}
}
public static void replaceIf(final boolean[][][] a, final Try.BooleanPredicate predicate, final boolean newValue) throws E {
if (N.isNullOrEmpty(a)) {
return;
}
for (int i = 0, n = a.length; i < n; i++) {
replaceIf(a[i], predicate, newValue);
}
}
public static boolean[] flatten(final boolean[][] a) {
if (N.isNullOrEmpty(a)) {
return N.EMPTY_BOOLEAN_ARRAY;
}
int count = 0;
for (int i = 0, n = a.length; i < n; i++) {
count += (a[i] == null ? 0 : a[i].length);
}
final boolean[] c = new boolean[count];
int from = 0;
for (int i = 0, n = a.length; i < n; i++) {
if (N.isNullOrEmpty(a[i])) {
continue;
}
N.copy(a[i], 0, c, from, a[i].length);
from += a[i].length;
}
return c;
}
public static boolean[] flatten(final boolean[][][] a) {
if (N.isNullOrEmpty(a)) {
return N.EMPTY_BOOLEAN_ARRAY;
}
int count = 0;
for (int i = 0, n = a.length; i < n; i++) {
if (N.isNullOrEmpty(a[i])) {
continue;
}
for (int j = 0, m = a[i].length; j < m; j++) {
if (N.isNullOrEmpty(a[i][j])) {
continue;
}
count += (a[i][j] == null ? 0 : a[i][j].length);
}
}
final boolean[] c = new boolean[count];
int from = 0;
for (int i = 0, n = a.length; i < n; i++) {
if (N.isNullOrEmpty(a[i])) {
continue;
}
for (int j = 0, m = a[i].length; j < m; j++) {
if (N.isNullOrEmpty(a[i][j])) {
continue;
}
N.copy(a[i][j], 0, c, from, a[i][j].length);
from += a[i][j].length;
}
}
return c;
}
public static boolean[][] reshape(final boolean[] a, final int m) {
N.checkArgument(m > 0, "'m' must be positive number: m = %s", m);
if (N.isNullOrEmpty(a)) {
return new boolean[0][0];
}
final int len = a.length;
final int n = Matth.divide(len, m, RoundingMode.CEILING);
final boolean[][] c = new boolean[n][];
for (int i = 0, from = 0; i < n; i++, from += m) {
c[i] = N.copyOfRange(a, from, from + N.min(len - from, m));
}
return c;
}
public static boolean[][][] reshape(final boolean[] a, final int m, final int l) {
N.checkArgument(m > 0 && l > 0, "'m' and 'l' must be positive number: m = %s, l = %s", m, l);
if (N.isNullOrEmpty(a)) {
return new boolean[0][0][0];
}
final int len = a.length;
final int n = Matth.divide(len, m * l, RoundingMode.CEILING);
final boolean[][][] c = new boolean[n][][];
for (int i = 0, from = 0; i < n; i++) {
c[i] = new boolean[N.min(m, Matth.divide(len - from, l, RoundingMode.CEILING))][];
for (int j = 0, y = c[i].length; j < y; j++, from += l) {
c[i][j] = N.copyOfRange(a, from, from + N.min(len - from, l));
}
}
return c;
}
public static boolean[] zip(final boolean[] a, final boolean[] b, final Try.BooleanBiFunction zipFunction) throws E {
final int lenA = N.len(a);
final int lenB = N.len(b);
final boolean[] result = new boolean[N.min(lenA, lenB)];
for (int i = 0, len = result.length; i < len; i++) {
result[i] = zipFunction.apply(a[i], b[i]);
}
return result;
}
public static boolean[] zip(final boolean[] a, final boolean[] b, final boolean valueForNoneA, final boolean valueForNoneB,
final Try.BooleanBiFunction zipFunction) throws E {
final int lenA = N.len(a);
final int lenB = N.len(b);
return zip(N.max(lenA, lenB), a, b, valueForNoneA, valueForNoneB, zipFunction);
}
private static boolean[] zip(final int len, final boolean[] a, final boolean[] b, final boolean valueForNoneA,
final boolean valueForNoneB, final Try.BooleanBiFunction zipFunction) throws E {
final int lenA = N.len(a);
final int lenB = N.len(b);
final boolean[] result = new boolean[len];
for (int i = 0, min = N.min(lenA, lenB, len); i < min; i++) {
result[i] = zipFunction.apply(a[i], b[i]);
}
if (lenA < lenB && lenA < len) {
for (int i = lenA, min = N.min(lenB, len); i < min; i++) {
result[i] = zipFunction.apply(valueForNoneA, b[i]);
}
} else if (lenB < lenA && lenB < len) {
for (int i = lenB, min = N.min(lenA, len); i < min; i++) {
result[i] = zipFunction.apply(a[i], valueForNoneB);
}
}
if (N.max(lenA, lenB) < len) {
for (int i = N.max(lenA, lenB); i < len; i++) {
result[i] = zipFunction.apply(valueForNoneA, valueForNoneB);
}
}
return result;
}
public static boolean[] zip(final boolean[] a, final boolean[] b, final boolean[] c,
final Try.BooleanTriFunction zipFunction) throws E {
final int lenA = N.len(a);
final int lenB = N.len(b);
final int lenC = N.len(c);
final boolean[] result = new boolean[N.min(lenA, lenB, lenC)];
for (int i = 0, len = result.length; i < len; i++) {
result[i] = zipFunction.apply(a[i], b[i], c[i]);
}
return result;
}
public static boolean[] zip(final boolean[] a, final boolean[] b, final boolean[] c, final boolean valueForNoneA,
final boolean valueForNoneB, final boolean valueForNoneC, final Try.BooleanTriFunction zipFunction) throws E {
final int lenA = N.len(a);
final int lenB = N.len(b);
final int lenC = N.len(c);
return zip(N.max(lenA, lenB, lenC), a, b, c, valueForNoneA, valueForNoneB, valueForNoneC, zipFunction);
}
private static boolean[] zip(final int len, final boolean[] a, final boolean[] b, final boolean[] c, final boolean valueForNoneA,
final boolean valueForNoneB, final boolean valueForNoneC, final Try.BooleanTriFunction zipFunction) throws E {
final int lenA = N.len(a);
final int lenB = N.len(b);
final int lenC = N.len(c);
final boolean[] result = new boolean[len];
for (int i = 0, min = N.min(lenA, lenB, lenC, len); i < min; i++) {
result[i] = zipFunction.apply(a[i], b[i], c[i]);
}
if (N.min(lenA, lenB, lenC) < len) {
for (int i = N.min(lenA, lenB, lenC); i < len; i++) {
result[i] = zipFunction.apply(i < lenA ? a[i] : valueForNoneA, i < lenB ? b[i] : valueForNoneB, i < lenC ? c[i] : valueForNoneC);
}
}
return result;
}
public static boolean[][] zip(final boolean[][] a, final boolean[][] b, final Try.BooleanBiFunction zipFunction)
throws E {
final int lenA = N.len(a);
final int lenB = N.len(b);
final boolean[][] result = new boolean[N.min(lenA, lenB)][];
for (int i = 0, len = result.length; i < len; i++) {
result[i] = zip(a[i], b[i], zipFunction);
}
return result;
}
public static boolean[][] zip(final boolean[][] a, final boolean[][] b, final boolean valueForNoneA, final boolean valueForNoneB,
final Try.BooleanBiFunction zipFunction) throws E {
return zip(N.max(N.len(a), N.len(b)), N.max(maxSubArrayLen(a), maxSubArrayLen(b)), a, b, valueForNoneA, valueForNoneB, zipFunction);
}
private static boolean[][] zip(final int len, final int rowLen, final boolean[][] a, final boolean[][] b, final boolean valueForNoneA,
final boolean valueForNoneB, final Try.BooleanBiFunction zipFunction) throws E {
final int lenA = N.len(a);
final int lenB = N.len(b);
final boolean[][] result = new boolean[len][];
for (int i = 0, min = N.min(lenA, lenB, len); i < min; i++) {
result[i] = zip(rowLen, a[i], b[i], valueForNoneA, valueForNoneB, zipFunction);
}
if (lenA < lenB && lenA < len) {
for (int i = lenA, min = N.min(lenB, len); i < min; i++) {
result[i] = zip(rowLen, null, b[i], valueForNoneA, valueForNoneB, zipFunction);
}
} else if (lenB < lenA && lenB < len) {
for (int i = lenB, min = N.min(lenA, len); i < min; i++) {
result[i] = zip(rowLen, a[i], null, valueForNoneA, valueForNoneB, zipFunction);
}
}
if (N.max(lenA, lenB) < len) {
for (int i = N.max(lenA, lenB); i < len; i++) {
result[i] = zip(rowLen, null, null, valueForNoneA, valueForNoneB, zipFunction);
}
}
return result;
}
public static boolean[][] zip(final boolean[][] a, final boolean[][] b, final boolean[][] c,
final Try.BooleanTriFunction zipFunction) throws E {
final int lenA = N.len(a);
final int lenB = N.len(b);
final int lenC = N.len(c);
final boolean[][] result = new boolean[N.min(lenA, lenB, lenC)][];
for (int i = 0, len = result.length; i < len; i++) {
result[i] = zip(a[i], b[i], c[i], zipFunction);
}
return result;
}
public static boolean[][] zip(final boolean[][] a, final boolean[][] b, final boolean[][] c, final boolean valueForNoneA,
final boolean valueForNoneB, final boolean valueForNoneC, final Try.BooleanTriFunction zipFunction) throws E {
return zip(N.max(N.len(a), N.len(b), N.len(c)), N.max(maxSubArrayLen(a), maxSubArrayLen(b), maxSubArrayLen(c)), a, b, c, valueForNoneA, valueForNoneB,
valueForNoneC, zipFunction);
}
private static boolean[][] zip(final int len, final int rowLen, final boolean[][] a, final boolean[][] b, final boolean[][] c,
final boolean valueForNoneA, final boolean valueForNoneB, final boolean valueForNoneC, final Try.BooleanTriFunction zipFunction)
throws E {
final int lenA = N.len(a);
final int lenB = N.len(b);
final int lenC = N.len(c);
final boolean[][] result = new boolean[len][];
for (int i = 0, min = N.min(lenA, lenB, lenC, len); i < min; i++) {
result[i] = zip(rowLen, a[i], b[i], c[i], valueForNoneA, valueForNoneB, valueForNoneC, zipFunction);
}
if (N.min(lenA, lenB, lenC) < len) {
for (int i = N.min(lenA, lenB, lenC); i < len; i++) {
result[i] = zip(rowLen, i < lenA ? a[i] : null, i < lenB ? b[i] : null, i < lenC ? c[i] : null, valueForNoneA, valueForNoneB, valueForNoneC,
zipFunction);
}
}
return result;
}
public static boolean[][][] zip(final boolean[][][] a, final boolean[][][] b, final Try.BooleanBiFunction zipFunction)
throws E {
final int lenA = N.len(a);
final int lenB = N.len(b);
final boolean[][][] result = new boolean[N.min(lenA, lenB)][][];
for (int i = 0, len = result.length; i < len; i++) {
result[i] = zip(a[i], b[i], zipFunction);
}
return result;
}
public static boolean[][][] zip(final boolean[][][] a, final boolean[][][] b, final boolean valueForNoneA,
final boolean valueForNoneB, final Try.BooleanBiFunction zipFunction) throws E {
final int lenA = N.len(a);
final int lenB = N.len(b);
final boolean[][][] result = new boolean[N.max(lenA, lenB)][][];
for (int i = 0, min = N.min(lenA, lenB); i < min; i++) {
result[i] = zip(a[i], b[i], valueForNoneA, valueForNoneB, zipFunction);
}
if (lenA < lenB) {
for (int i = lenA; i < lenB; i++) {
result[i] = zip(null, b[i], valueForNoneA, valueForNoneB, zipFunction);
}
} else if (lenB < lenA) {
for (int i = lenB; i < lenA; i++) {
result[i] = zip(a[i], null, valueForNoneA, valueForNoneB, zipFunction);
}
}
return result;
}
public static boolean[][][] zip(final boolean[][][] a, final boolean[][][] b, final boolean[][][] c,
final Try.BooleanTriFunction zipFunction) throws E {
final int lenA = N.len(a);
final int lenB = N.len(b);
final int lenC = N.len(c);
final boolean[][][] result = new boolean[N.min(lenA, lenB, lenC)][][];
for (int i = 0, len = result.length; i < len; i++) {
result[i] = zip(a[i], b[i], c[i], zipFunction);
}
return result;
}
public static boolean[][][] zip(final boolean[][][] a, final boolean[][][] b, final boolean[][][] c, final boolean valueForNoneA,
final boolean valueForNoneB, final boolean valueForNoneC, final Try.BooleanTriFunction zipFunction) throws E {
final int lenA = N.len(a);
final int lenB = N.len(b);
final int lenC = N.len(c);
final boolean[][][] result = new boolean[N.max(lenA, lenB, lenC)][][];
for (int i = 0, min = N.min(lenA, lenB, lenC); i < min; i++) {
result[i] = zip(a[i], b[i], c[i], valueForNoneA, valueForNoneB, valueForNoneC, zipFunction);
}
for (int i = N.min(lenA, lenB, lenC), len = result.length; i < len; i++) {
result[i] = zip(i < lenA ? a[i] : null, i < lenB ? b[i] : null, i < lenC ? c[i] : null, valueForNoneA, valueForNoneB, valueForNoneC, zipFunction);
}
return result;
}
public static Boolean[] box(final boolean[] a) {
return Array.box(a);
}
public static Boolean[][] box(final boolean[][] a) {
if (a == null) {
return null;
}
final int len = N.len(a);
final Boolean[][] result = new Boolean[len][];
for (int i = 0; i < len; i++) {
result[i] = box(a[i]);
}
return result;
}
public static Boolean[][][] box(final boolean[][][] a) {
if (a == null) {
return null;
}
final int len = N.len(a);
final Boolean[][][] result = new Boolean[len][][];
for (int i = 0; i < len; i++) {
result[i] = box(a[i]);
}
return result;
}
public static boolean[] unbox(final Boolean[] a) {
return Array.unbox(a);
}
public static boolean[] unbox(final Boolean[] a, final boolean valueForNul) {
return Array.unbox(a, valueForNul);
}
public static boolean[][] unbox(final Boolean[][] a) {
if (a == null) {
return null;
}
final int len = N.len(a);
final boolean[][] result = new boolean[len][];
for (int i = 0; i < len; i++) {
result[i] = unbox(a[i]);
}
return result;
}
public static boolean[][] unbox(final Boolean[][] a, final boolean valueForNul) {
if (a == null) {
return null;
}
final int len = N.len(a);
final boolean[][] result = new boolean[len][];
for (int i = 0; i < len; i++) {
result[i] = unbox(a[i], valueForNul);
}
return result;
}
public static boolean[][][] unbox(final Boolean[][][] a) {
if (a == null) {
return null;
}
final int len = N.len(a);
final boolean[][][] result = new boolean[len][][];
for (int i = 0; i < len; i++) {
result[i] = unbox(a[i]);
}
return result;
}
public static boolean[][][] unbox(final Boolean[][][] a, final boolean valueForNul) {
if (a == null) {
return null;
}
final int len = N.len(a);
final boolean[][][] result = new boolean[len][][];
for (int i = 0; i < len; i++) {
result[i] = unbox(a[i], valueForNul);
}
return result;
}
public static void println(final boolean[] a) {
if (a == null) {
N.println("null");
} else if (a.length == 0) {
N.println("[]");
} else {
N.println(a);
}
}
public static void println(final boolean[][] a) {
if (a == null) {
N.println("null");
} else if (a.length == 0) {
N.println("[]");
} else {
final int len = a.length;
for (int i = 0; i < len; i++) {
println(a[i]);
}
}
}
public static void println(final boolean[][][] a) {
if (a == null) {
N.println("null");
} else if (a.length == 0) {
N.println("[]");
} else {
final int len = a.length;
for (int i = 0; i < len; i++) {
if (i > 0) {
N.println(ARRAY_PRINT_SEPERATOR);
}
println(a[i]);
}
}
}
public static int minSubArrayLen(boolean[][] a) {
if (a == null) {
return 0;
}
final int len = a.length;
int minLen = 0;
for (int i = 0; i < len; i++) {
minLen = N.min(minLen, a[i] == null ? 0 : a[i].length);
}
return minLen;
}
public static int maxSubArrayLen(boolean[][] a) {
if (a == null) {
return 0;
}
final int len = a.length;
int maxLen = 0;
for (int i = 0; i < len; i++) {
maxLen = N.max(maxLen, a[i] == null ? 0 : a[i].length);
}
return maxLen;
}
public static void plus(final char[] a, final int param) {
if (N.isNullOrEmpty(a)) {
return;
}
for (int i = 0, n = a.length; i < n; i++) {
a[i] += param;
}
}
public static void plus(final char[][] a, final int param) {
if (N.isNullOrEmpty(a)) {
return;
}
for (int i = 0, n = a.length; i < n; i++) {
plus(a[i], param);
}
}
public static void plus(final char[][][] a, final int param) {
if (N.isNullOrEmpty(a)) {
return;
}
for (int i = 0, n = a.length; i < n; i++) {
plus(a[i], param);
}
}
public static void minus(final char[] a, final int param) {
if (N.isNullOrEmpty(a)) {
return;
}
for (int i = 0, n = a.length; i < n; i++) {
a[i] -= param;
}
}
public static void minus(final char[][] a, final int param) {
if (N.isNullOrEmpty(a)) {
return;
}
for (int i = 0, n = a.length; i < n; i++) {
minus(a[i], param);
}
}
public static void minus(final char[][][] a, final int param) {
if (N.isNullOrEmpty(a)) {
return;
}
for (int i = 0, n = a.length; i < n; i++) {
minus(a[i], param);
}
}
public static void multipliedBy(final char[] a, final int param) {
if (N.isNullOrEmpty(a)) {
return;
}
for (int i = 0, n = a.length; i < n; i++) {
a[i] *= param;
}
}
public static void multipliedBy(final char[][] a, final int param) {
if (N.isNullOrEmpty(a)) {
return;
}
for (int i = 0, n = a.length; i < n; i++) {
multipliedBy(a[i], param);
}
}
public static void multipliedBy(final char[][][] a, final int param) {
if (N.isNullOrEmpty(a)) {
return;
}
for (int i = 0, n = a.length; i < n; i++) {
multipliedBy(a[i], param);
}
}
public static void dividedBy(final char[] a, final int param) {
if (N.isNullOrEmpty(a)) {
return;
}
for (int i = 0, n = a.length; i < n; i++) {
a[i] /= param;
}
}
public static void dividedBy(final char[][] a, final int param) {
if (N.isNullOrEmpty(a)) {
return;
}
for (int i = 0, n = a.length; i < n; i++) {
dividedBy(a[i], param);
}
}
public static void dividedBy(final char[][][] a, final int param) {
if (N.isNullOrEmpty(a)) {
return;
}
for (int i = 0, n = a.length; i < n; i++) {
dividedBy(a[i], param);
}
}
public static void replaceAll(final char[] a, final Try.CharUnaryOperator operator) throws E {
if (N.isNullOrEmpty(a)) {
return;
}
for (int i = 0, n = a.length; i < n; i++) {
a[i] = operator.applyAsChar(a[i]);
}
}
public static void replaceAll(final char[][] a, final Try.CharUnaryOperator operator) throws E {
if (N.isNullOrEmpty(a)) {
return;
}
for (int i = 0, n = a.length; i < n; i++) {
replaceAll(a[i], operator);
}
}
public static void replaceAll(final char[][][] a, final Try.CharUnaryOperator operator) throws E {
if (N.isNullOrEmpty(a)) {
return;
}
for (int i = 0, n = a.length; i < n; i++) {
replaceAll(a[i], operator);
}
}
public static void replaceIf(final char[] a, final Try.CharPredicate predicate, final char newValue) throws E {
if (N.isNullOrEmpty(a)) {
return;
}
for (int i = 0, n = a.length; i < n; i++) {
if (predicate.test(a[i])) {
a[i] = newValue;
}
}
}
public static void replaceIf(final char[][] a, final Try.CharPredicate predicate, final char newValue) throws E {
if (N.isNullOrEmpty(a)) {
return;
}
for (int i = 0, n = a.length; i < n; i++) {
replaceIf(a[i], predicate, newValue);
}
}
public static void replaceIf(final char[][][] a, final Try.CharPredicate predicate, final char newValue) throws E {
if (N.isNullOrEmpty(a)) {
return;
}
for (int i = 0, n = a.length; i < n; i++) {
replaceIf(a[i], predicate, newValue);
}
}
public static char[] flatten(final char[][] a) {
if (N.isNullOrEmpty(a)) {
return N.EMPTY_CHAR_ARRAY;
}
int count = 0;
for (int i = 0, n = a.length; i < n; i++) {
count += (a[i] == null ? 0 : a[i].length);
}
final char[] c = new char[count];
int from = 0;
for (int i = 0, n = a.length; i < n; i++) {
if (N.isNullOrEmpty(a[i])) {
continue;
}
N.copy(a[i], 0, c, from, a[i].length);
from += a[i].length;
}
return c;
}
public static char[] flatten(final char[][][] a) {
if (N.isNullOrEmpty(a)) {
return N.EMPTY_CHAR_ARRAY;
}
int count = 0;
for (int i = 0, n = a.length; i < n; i++) {
if (N.isNullOrEmpty(a[i])) {
continue;
}
for (int j = 0, m = a[i].length; j < m; j++) {
if (N.isNullOrEmpty(a[i][j])) {
continue;
}
count += (a[i][j] == null ? 0 : a[i][j].length);
}
}
final char[] c = new char[count];
int from = 0;
for (int i = 0, n = a.length; i < n; i++) {
if (N.isNullOrEmpty(a[i])) {
continue;
}
for (int j = 0, m = a[i].length; j < m; j++) {
if (N.isNullOrEmpty(a[i][j])) {
continue;
}
N.copy(a[i][j], 0, c, from, a[i][j].length);
from += a[i][j].length;
}
}
return c;
}
public static char[][] reshape(final char[] a, final int m) {
N.checkArgument(m > 0, "'m' must be positive number: m = %s", m);
if (N.isNullOrEmpty(a)) {
return new char[0][0];
}
final int len = a.length;
final int n = Matth.divide(len, m, RoundingMode.CEILING);
final char[][] c = new char[n][];
for (int i = 0, from = 0; i < n; i++, from += m) {
c[i] = N.copyOfRange(a, from, from + N.min(len - from, m));
}
return c;
}
public static char[][][] reshape(final char[] a, final int m, final int l) {
N.checkArgument(m > 0 && l > 0, "'m' and 'l' must be positive number: m = %s, l = %s", m, l);
if (N.isNullOrEmpty(a)) {
return new char[0][0][0];
}
final int len = a.length;
final int n = Matth.divide(len, m * l, RoundingMode.CEILING);
final char[][][] c = new char[n][][];
for (int i = 0, from = 0; i < n; i++) {
c[i] = new char[N.min(m, Matth.divide(len - from, l, RoundingMode.CEILING))][];
for (int j = 0, y = c[i].length; j < y; j++, from += l) {
c[i][j] = N.copyOfRange(a, from, from + N.min(len - from, l));
}
}
return c;
}
public static char[] zip(final char[] a, final char[] b, final Try.CharBiFunction zipFunction) throws E {
final int lenA = N.len(a);
final int lenB = N.len(b);
final char[] result = new char[N.min(lenA, lenB)];
for (int i = 0, len = result.length; i < len; i++) {
result[i] = zipFunction.apply(a[i], b[i]);
}
return result;
}
public static char[] zip(final char[] a, final char[] b, final char valueForNoneA, final char valueForNoneB,
final Try.CharBiFunction zipFunction) throws E {
final int lenA = N.len(a);
final int lenB = N.len(b);
return zip(N.max(lenA, lenB), a, b, valueForNoneA, valueForNoneB, zipFunction);
}
private static char[] zip(final int len, final char[] a, final char[] b, final char valueForNoneA, final char valueForNoneB,
final Try.CharBiFunction zipFunction) throws E {
final int lenA = N.len(a);
final int lenB = N.len(b);
final char[] result = new char[len];
for (int i = 0, min = N.min(lenA, lenB, len); i < min; i++) {
result[i] = zipFunction.apply(a[i], b[i]);
}
if (lenA < lenB && lenA < len) {
for (int i = lenA, min = N.min(lenB, len); i < min; i++) {
result[i] = zipFunction.apply(valueForNoneA, b[i]);
}
} else if (lenB < lenA && lenB < len) {
for (int i = lenB, min = N.min(lenA, len); i < min; i++) {
result[i] = zipFunction.apply(a[i], valueForNoneB);
}
}
if (N.max(lenA, lenB) < len) {
for (int i = N.max(lenA, lenB); i < len; i++) {
result[i] = zipFunction.apply(valueForNoneA, valueForNoneB);
}
}
return result;
}
public static char[] zip(final char[] a, final char[] b, final char[] c, final Try.CharTriFunction zipFunction)
throws E {
final int lenA = N.len(a);
final int lenB = N.len(b);
final int lenC = N.len(c);
final char[] result = new char[N.min(lenA, lenB, lenC)];
for (int i = 0, len = result.length; i < len; i++) {
result[i] = zipFunction.apply(a[i], b[i], c[i]);
}
return result;
}
public static char[] zip(final char[] a, final char[] b, final char[] c, final char valueForNoneA, final char valueForNoneB,
final char valueForNoneC, final Try.CharTriFunction zipFunction) throws E {
final int lenA = N.len(a);
final int lenB = N.len(b);
final int lenC = N.len(c);
return zip(N.max(lenA, lenB, lenC), a, b, c, valueForNoneA, valueForNoneB, valueForNoneC, zipFunction);
}
private static char[] zip(final int len, final char[] a, final char[] b, final char[] c, final char valueForNoneA,
final char valueForNoneB, final char valueForNoneC, final Try.CharTriFunction zipFunction) throws E {
final int lenA = N.len(a);
final int lenB = N.len(b);
final int lenC = N.len(c);
final char[] result = new char[len];
for (int i = 0, min = N.min(lenA, lenB, lenC, len); i < min; i++) {
result[i] = zipFunction.apply(a[i], b[i], c[i]);
}
if (N.min(lenA, lenB, lenC) < len) {
for (int i = N.min(lenA, lenB, lenC); i < len; i++) {
result[i] = zipFunction.apply(i < lenA ? a[i] : valueForNoneA, i < lenB ? b[i] : valueForNoneB, i < lenC ? c[i] : valueForNoneC);
}
}
return result;
}
public static char[][] zip(final char[][] a, final char[][] b, final Try.CharBiFunction zipFunction) throws E {
final int lenA = N.len(a);
final int lenB = N.len(b);
final char[][] result = new char[N.min(lenA, lenB)][];
for (int i = 0, len = result.length; i < len; i++) {
result[i] = zip(a[i], b[i], zipFunction);
}
return result;
}
public static char[][] zip(final char[][] a, final char[][] b, final char valueForNoneA, final char valueForNoneB,
final Try.CharBiFunction zipFunction) throws E {
return zip(N.max(N.len(a), N.len(b)), N.max(maxSubArrayLen(a), maxSubArrayLen(b)), a, b, valueForNoneA, valueForNoneB, zipFunction);
}
private static char[][] zip(final int len, final int rowLen, final char[][] a, final char[][] b, final char valueForNoneA,
final char valueForNoneB, final Try.CharBiFunction zipFunction) throws E {
final int lenA = N.len(a);
final int lenB = N.len(b);
final char[][] result = new char[len][];
for (int i = 0, min = N.min(lenA, lenB, len); i < min; i++) {
result[i] = zip(rowLen, a[i], b[i], valueForNoneA, valueForNoneB, zipFunction);
}
if (lenA < lenB && lenA < len) {
for (int i = lenA, min = N.min(lenB, len); i < min; i++) {
result[i] = zip(rowLen, null, b[i], valueForNoneA, valueForNoneB, zipFunction);
}
} else if (lenB < lenA && lenB < len) {
for (int i = lenB, min = N.min(lenA, len); i < min; i++) {
result[i] = zip(rowLen, a[i], null, valueForNoneA, valueForNoneB, zipFunction);
}
}
if (N.max(lenA, lenB) < len) {
for (int i = N.max(lenA, lenB); i < len; i++) {
result[i] = zip(rowLen, null, null, valueForNoneA, valueForNoneB, zipFunction);
}
}
return result;
}
public static char[][] zip(final char[][] a, final char[][] b, final char[][] c, final Try.CharTriFunction zipFunction)
throws E {
final int lenA = N.len(a);
final int lenB = N.len(b);
final int lenC = N.len(c);
final char[][] result = new char[N.min(lenA, lenB, lenC)][];
for (int i = 0, len = result.length; i < len; i++) {
result[i] = zip(a[i], b[i], c[i], zipFunction);
}
return result;
}
public static char[][] zip(final char[][] a, final char[][] b, final char[][] c, final char valueForNoneA, final char valueForNoneB,
final char valueForNoneC, final Try.CharTriFunction zipFunction) throws E {
return zip(N.max(N.len(a), N.len(b), N.len(c)), N.max(maxSubArrayLen(a), maxSubArrayLen(b), maxSubArrayLen(c)), a, b, c, valueForNoneA, valueForNoneB,
valueForNoneC, zipFunction);
}
private static char[][] zip(final int len, final int rowLen, final char[][] a, final char[][] b, final char[][] c,
final char valueForNoneA, final char valueForNoneB, final char valueForNoneC, final Try.CharTriFunction zipFunction) throws E {
final int lenA = N.len(a);
final int lenB = N.len(b);
final int lenC = N.len(c);
final char[][] result = new char[len][];
for (int i = 0, min = N.min(lenA, lenB, lenC, len); i < min; i++) {
result[i] = zip(rowLen, a[i], b[i], c[i], valueForNoneA, valueForNoneB, valueForNoneC, zipFunction);
}
if (N.min(lenA, lenB, lenC) < len) {
for (int i = N.min(lenA, lenB, lenC); i < len; i++) {
result[i] = zip(rowLen, i < lenA ? a[i] : null, i < lenB ? b[i] : null, i < lenC ? c[i] : null, valueForNoneA, valueForNoneB, valueForNoneC,
zipFunction);
}
}
return result;
}
public static char[][][] zip(final char[][][] a, final char[][][] b, final Try.CharBiFunction zipFunction) throws E {
final int lenA = N.len(a);
final int lenB = N.len(b);
final char[][][] result = new char[N.min(lenA, lenB)][][];
for (int i = 0, len = result.length; i < len; i++) {
result[i] = zip(a[i], b[i], zipFunction);
}
return result;
}
public static char[][][] zip(final char[][][] a, final char[][][] b, final char valueForNoneA, final char valueForNoneB,
final Try.CharBiFunction zipFunction) throws E {
final int lenA = N.len(a);
final int lenB = N.len(b);
final char[][][] result = new char[N.max(lenA, lenB)][][];
for (int i = 0, min = N.min(lenA, lenB); i < min; i++) {
result[i] = zip(a[i], b[i], valueForNoneA, valueForNoneB, zipFunction);
}
if (lenA < lenB) {
for (int i = lenA; i < lenB; i++) {
result[i] = zip(null, b[i], valueForNoneA, valueForNoneB, zipFunction);
}
} else if (lenB < lenA) {
for (int i = lenB; i < lenA; i++) {
result[i] = zip(a[i], null, valueForNoneA, valueForNoneB, zipFunction);
}
}
return result;
}
public static char[][][] zip(final char[][][] a, final char[][][] b, final char[][][] c,
final Try.CharTriFunction zipFunction) throws E {
final int lenA = N.len(a);
final int lenB = N.len(b);
final int lenC = N.len(c);
final char[][][] result = new char[N.min(lenA, lenB, lenC)][][];
for (int i = 0, len = result.length; i < len; i++) {
result[i] = zip(a[i], b[i], c[i], zipFunction);
}
return result;
}
public static char[][][] zip(final char[][][] a, final char[][][] b, final char[][][] c, final char valueForNoneA,
final char valueForNoneB, final char valueForNoneC, final Try.CharTriFunction zipFunction) throws E {
final int lenA = N.len(a);
final int lenB = N.len(b);
final int lenC = N.len(c);
final char[][][] result = new char[N.max(lenA, lenB, lenC)][][];
for (int i = 0, min = N.min(lenA, lenB, lenC); i < min; i++) {
result[i] = zip(a[i], b[i], c[i], valueForNoneA, valueForNoneB, valueForNoneC, zipFunction);
}
for (int i = N.min(lenA, lenB, lenC), len = result.length; i < len; i++) {
result[i] = zip(i < lenA ? a[i] : null, i < lenB ? b[i] : null, i < lenC ? c[i] : null, valueForNoneA, valueForNoneB, valueForNoneC, zipFunction);
}
return result;
}
public static Character[] box(final char[] a) {
return Array.box(a);
}
public static Character[][] box(final char[][] a) {
if (a == null) {
return null;
}
final int len = a.length;
final Character[][] result = new Character[len][];
for (int i = 0; i < len; i++) {
result[i] = box(a[i]);
}
return result;
}
public static Character[][][] box(final char[][][] a) {
if (a == null) {
return null;
}
final int len = a.length;
final Character[][][] result = new Character[len][][];
for (int i = 0; i < len; i++) {
result[i] = box(a[i]);
}
return result;
}
public static char[] unbox(final Character[] a) {
return Array.unbox(a);
}
public static char[] unbox(final Character[] a, final char valueForNul) {
return Array.unbox(a, valueForNul);
}
public static char[][] unbox(final Character[][] a) {
if (a == null) {
return null;
}
final int len = a.length;
final char[][] result = new char[len][];
for (int i = 0; i < len; i++) {
result[i] = unbox(a[i]);
}
return result;
}
public static char[][] unbox(final Character[][] a, final char valueForNul) {
if (a == null) {
return null;
}
final int len = a.length;
final char[][] result = new char[len][];
for (int i = 0; i < len; i++) {
result[i] = unbox(a[i], valueForNul);
}
return result;
}
public static char[][][] unbox(final Character[][][] a) {
if (a == null) {
return null;
}
final int len = a.length;
final char[][][] result = new char[len][][];
for (int i = 0; i < len; i++) {
result[i] = unbox(a[i]);
}
return result;
}
public static char[][][] unbox(final Character[][][] a, final char valueForNul) {
if (a == null) {
return null;
}
final int len = a.length;
final char[][][] result = new char[len][][];
for (int i = 0; i < len; i++) {
result[i] = unbox(a[i], valueForNul);
}
return result;
}
public static void println(final char[] a) {
if (a == null) {
N.println("null");
} else if (a.length == 0) {
N.println("[]");
} else {
N.println(a);
}
}
public static void println(final char[][] a) {
if (a == null) {
N.println("null");
} else if (a.length == 0) {
N.println("[]");
} else {
final int len = a.length;
for (int i = 0; i < len; i++) {
println(a[i]);
}
}
}
public static void println(final char[][][] a) {
if (a == null) {
N.println("null");
} else if (a.length == 0) {
N.println("[]");
} else {
final int len = a.length;
for (int i = 0; i < len; i++) {
if (i > 0) {
N.println(ARRAY_PRINT_SEPERATOR);
}
println(a[i]);
}
}
}
public static int minSubArrayLen(char[][] a) {
if (a == null) {
return 0;
}
final int len = a.length;
int minLen = 0;
for (int i = 0; i < len; i++) {
minLen = N.min(minLen, a[i] == null ? 0 : a[i].length);
}
return minLen;
}
public static int maxSubArrayLen(char[][] a) {
if (a == null) {
return 0;
}
final int len = a.length;
int maxLen = 0;
for (int i = 0; i < len; i++) {
maxLen = N.max(maxLen, a[i] == null ? 0 : a[i].length);
}
return maxLen;
}
public static void plus(final byte[] a, final byte param) {
if (N.isNullOrEmpty(a)) {
return;
}
for (int i = 0, n = a.length; i < n; i++) {
a[i] += param;
}
}
public static void plus(final byte[][] a, final byte param) {
if (N.isNullOrEmpty(a)) {
return;
}
for (int i = 0, n = a.length; i < n; i++) {
plus(a[i], param);
}
}
public static void plus(final byte[][][] a, final byte param) {
if (N.isNullOrEmpty(a)) {
return;
}
for (int i = 0, n = a.length; i < n; i++) {
plus(a[i], param);
}
}
public static void minus(final byte[] a, final byte param) {
if (N.isNullOrEmpty(a)) {
return;
}
for (int i = 0, n = a.length; i < n; i++) {
a[i] -= param;
}
}
public static void minus(final byte[][] a, final byte param) {
if (N.isNullOrEmpty(a)) {
return;
}
for (int i = 0, n = a.length; i < n; i++) {
minus(a[i], param);
}
}
public static void minus(final byte[][][] a, final byte param) {
if (N.isNullOrEmpty(a)) {
return;
}
for (int i = 0, n = a.length; i < n; i++) {
minus(a[i], param);
}
}
public static void multipliedBy(final byte[] a, final byte param) {
if (N.isNullOrEmpty(a)) {
return;
}
for (int i = 0, n = a.length; i < n; i++) {
a[i] *= param;
}
}
public static void multipliedBy(final byte[][] a, final byte param) {
if (N.isNullOrEmpty(a)) {
return;
}
for (int i = 0, n = a.length; i < n; i++) {
multipliedBy(a[i], param);
}
}
public static void multipliedBy(final byte[][][] a, final byte param) {
if (N.isNullOrEmpty(a)) {
return;
}
for (int i = 0, n = a.length; i < n; i++) {
multipliedBy(a[i], param);
}
}
public static void dividedBy(final byte[] a, final byte param) {
if (N.isNullOrEmpty(a)) {
return;
}
for (int i = 0, n = a.length; i < n; i++) {
a[i] /= param;
}
}
public static void dividedBy(final byte[][] a, final byte param) {
if (N.isNullOrEmpty(a)) {
return;
}
for (int i = 0, n = a.length; i < n; i++) {
dividedBy(a[i], param);
}
}
public static void dividedBy(final byte[][][] a, final byte param) {
if (N.isNullOrEmpty(a)) {
return;
}
for (int i = 0, n = a.length; i < n; i++) {
dividedBy(a[i], param);
}
}
public static void replaceAll(final byte[] a, final Try.ByteUnaryOperator operator) throws E {
if (N.isNullOrEmpty(a)) {
return;
}
for (int i = 0, n = a.length; i < n; i++) {
a[i] = operator.applyAsByte(a[i]);
}
}
public static void replaceAll(final byte[][] a, final Try.ByteUnaryOperator operator) throws E {
if (N.isNullOrEmpty(a)) {
return;
}
for (int i = 0, n = a.length; i < n; i++) {
replaceAll(a[i], operator);
}
}
public static void replaceAll(final byte[][][] a, final Try.ByteUnaryOperator operator) throws E {
if (N.isNullOrEmpty(a)) {
return;
}
for (int i = 0, n = a.length; i < n; i++) {
replaceAll(a[i], operator);
}
}
public static void replaceIf(final byte[] a, final Try.BytePredicate predicate, final byte newValue) throws E {
if (N.isNullOrEmpty(a)) {
return;
}
for (int i = 0, n = a.length; i < n; i++) {
if (predicate.test(a[i])) {
a[i] = newValue;
}
}
}
public static void replaceIf(final byte[][] a, final Try.BytePredicate predicate, final byte newValue) throws E {
if (N.isNullOrEmpty(a)) {
return;
}
for (int i = 0, n = a.length; i < n; i++) {
replaceIf(a[i], predicate, newValue);
}
}
public static void replaceIf(final byte[][][] a, final Try.BytePredicate predicate, final byte newValue) throws E {
if (N.isNullOrEmpty(a)) {
return;
}
for (int i = 0, n = a.length; i < n; i++) {
replaceIf(a[i], predicate, newValue);
}
}
public static byte[] flatten(final byte[][] a) {
if (N.isNullOrEmpty(a)) {
return N.EMPTY_BYTE_ARRAY;
}
int count = 0;
for (int i = 0, n = a.length; i < n; i++) {
count += (a[i] == null ? 0 : a[i].length);
}
final byte[] c = new byte[count];
int from = 0;
for (int i = 0, n = a.length; i < n; i++) {
if (N.isNullOrEmpty(a[i])) {
continue;
}
N.copy(a[i], 0, c, from, a[i].length);
from += a[i].length;
}
return c;
}
public static byte[] flatten(final byte[][][] a) {
if (N.isNullOrEmpty(a)) {
return N.EMPTY_BYTE_ARRAY;
}
int count = 0;
for (int i = 0, n = a.length; i < n; i++) {
if (N.isNullOrEmpty(a[i])) {
continue;
}
for (int j = 0, m = a[i].length; j < m; j++) {
if (N.isNullOrEmpty(a[i][j])) {
continue;
}
count += (a[i][j] == null ? 0 : a[i][j].length);
}
}
final byte[] c = new byte[count];
int from = 0;
for (int i = 0, n = a.length; i < n; i++) {
if (N.isNullOrEmpty(a[i])) {
continue;
}
for (int j = 0, m = a[i].length; j < m; j++) {
if (N.isNullOrEmpty(a[i][j])) {
continue;
}
N.copy(a[i][j], 0, c, from, a[i][j].length);
from += a[i][j].length;
}
}
return c;
}
public static byte[][] reshape(final byte[] a, final int m) {
N.checkArgument(m > 0, "'m' must be positive number: m = %s", m);
if (N.isNullOrEmpty(a)) {
return new byte[0][0];
}
final int len = a.length;
final int n = Matth.divide(len, m, RoundingMode.CEILING);
final byte[][] c = new byte[n][];
for (int i = 0, from = 0; i < n; i++, from += m) {
c[i] = N.copyOfRange(a, from, from + N.min(len - from, m));
}
return c;
}
public static byte[][][] reshape(final byte[] a, final int m, final int l) {
N.checkArgument(m > 0 && l > 0, "'m' and 'l' must be positive number: m = %s, l = %s", m, l);
if (N.isNullOrEmpty(a)) {
return new byte[0][0][0];
}
final int len = a.length;
final int n = Matth.divide(len, m * l, RoundingMode.CEILING);
final byte[][][] c = new byte[n][][];
for (int i = 0, from = 0; i < n; i++) {
c[i] = new byte[N.min(m, Matth.divide(len - from, l, RoundingMode.CEILING))][];
for (int j = 0, y = c[i].length; j < y; j++, from += l) {
c[i][j] = N.copyOfRange(a, from, from + N.min(len - from, l));
}
}
return c;
}
public static byte[] add(final byte[] a, final byte[] b) {
final int lenA = N.len(a);
final int lenB = N.len(b);
final byte[] result = new byte[N.min(lenA, lenB)];
for (int i = 0, len = result.length; i < len; i++) {
result[i] = (byte) (a[i] + b[i]);
}
return result;
}
public static byte[] add(final byte[] a, final byte[] b, final byte valueForNoneA, final byte valueForNoneB) {
final int lenA = N.len(a);
final int lenB = N.len(b);
return add(N.max(lenA, lenB), a, b, valueForNoneA, valueForNoneB);
}
private static byte[] add(final int len, final byte[] a, final byte[] b, final byte valueForNoneA, final byte valueForNoneB) {
final int lenA = N.len(a);
final int lenB = N.len(b);
final byte[] result = new byte[len];
for (int i = 0, min = N.min(lenA, lenB, len); i < min; i++) {
result[i] = (byte) (a[i] + b[i]);
}
if (lenA < lenB && lenA < len) {
for (int i = lenA, min = N.min(lenB, len); i < min; i++) {
result[i] = (byte) (valueForNoneA + b[i]);
}
} else if (lenB < lenA && lenB < len) {
for (int i = lenB, min = N.min(lenA, len); i < min; i++) {
result[i] = (byte) (a[i] + valueForNoneB);
}
}
if (N.max(lenA, lenB) < len) {
for (int i = N.max(lenA, lenB); i < len; i++) {
result[i] = (byte) (valueForNoneA + valueForNoneB);
}
}
return result;
}
public static byte[] add(final byte[] a, final byte[] b, final byte[] c) {
final int lenA = N.len(a);
final int lenB = N.len(b);
final int lenC = N.len(c);
final byte[] result = new byte[N.min(lenA, lenB, lenC)];
for (int i = 0, len = result.length; i < len; i++) {
result[i] = (byte) (a[i] + b[i] + c[i]);
}
return result;
}
public static byte[] add(final byte[] a, final byte[] b, final byte[] c, final byte valueForNoneA, final byte valueForNoneB, final byte valueForNoneC) {
final int lenA = N.len(a);
final int lenB = N.len(b);
final int lenC = N.len(c);
return add(N.max(lenA, lenB, lenC), a, b, c, valueForNoneA, valueForNoneB, valueForNoneC);
}
private static byte[] add(final int len, final byte[] a, final byte[] b, final byte[] c, final byte valueForNoneA, final byte valueForNoneB,
final byte valueForNoneC) {
final int lenA = N.len(a);
final int lenB = N.len(b);
final int lenC = N.len(c);
final byte[] result = new byte[len];
for (int i = 0, min = N.min(lenA, lenB, lenC, len); i < min; i++) {
result[i] = (byte) (a[i] + b[i] + c[i]);
}
if (N.min(lenA, lenB, lenC) < len) {
for (int i = N.min(lenA, lenB, lenC); i < len; i++) {
result[i] = (byte) ((i < lenA ? a[i] : valueForNoneA) + (i < lenB ? b[i] : valueForNoneB) + (i < lenC ? c[i] : valueForNoneC));
}
}
return result;
}
public static byte[][] add(final byte[][] a, final byte[][] b) {
final int lenA = N.len(a);
final int lenB = N.len(b);
final byte[][] result = new byte[N.min(lenA, lenB)][];
for (int i = 0, len = result.length; i < len; i++) {
result[i] = add(a[i], b[i]);
}
return result;
}
public static byte[][] add(final byte[][] a, final byte[][] b, final byte valueForNoneA, final byte valueForNoneB) {
return add(N.max(N.len(a), N.len(b)), N.max(maxSubArrayLen(a), maxSubArrayLen(b)), a, b, valueForNoneA, valueForNoneB);
}
private static byte[][] add(final int len, final int rowLen, final byte[][] a, final byte[][] b, final byte valueForNoneA, final byte valueForNoneB) {
final int lenA = N.len(a);
final int lenB = N.len(b);
final byte[][] result = new byte[len][];
for (int i = 0, min = N.min(lenA, lenB, len); i < min; i++) {
result[i] = add(rowLen, a[i], b[i], valueForNoneA, valueForNoneB);
}
if (lenA < lenB && lenA < len) {
for (int i = lenA, min = N.min(lenB, len); i < min; i++) {
result[i] = add(rowLen, null, b[i], valueForNoneA, valueForNoneB);
}
} else if (lenB < lenA && lenB < len) {
for (int i = lenB, min = N.min(lenA, len); i < min; i++) {
result[i] = add(rowLen, a[i], null, valueForNoneA, valueForNoneB);
}
}
if (N.max(lenA, lenB) < len) {
for (int i = N.max(lenA, lenB); i < len; i++) {
result[i] = add(rowLen, (byte[]) null, (byte[]) null, valueForNoneA, valueForNoneB);
}
}
return result;
}
public static byte[][] add(final byte[][] a, final byte[][] b, final byte[][] c) {
final int lenA = N.len(a);
final int lenB = N.len(b);
final int lenC = N.len(c);
final byte[][] result = new byte[N.min(lenA, lenB, lenC)][];
for (int i = 0, len = result.length; i < len; i++) {
result[i] = add(a[i], b[i], c[i]);
}
return result;
}
public static byte[][] add(final byte[][] a, final byte[][] b, final byte[][] c, final byte valueForNoneA, final byte valueForNoneB,
final byte valueForNoneC) {
return add(N.max(N.len(a), N.len(b), N.len(c)), N.max(maxSubArrayLen(a), maxSubArrayLen(b), maxSubArrayLen(c)), a, b, c, valueForNoneA, valueForNoneB,
valueForNoneC);
}
private static byte[][] add(final int len, final int rowLen, final byte[][] a, final byte[][] b, final byte[][] c, final byte valueForNoneA,
final byte valueForNoneB, final byte valueForNoneC) {
final int lenA = N.len(a);
final int lenB = N.len(b);
final int lenC = N.len(c);
final byte[][] result = new byte[len][];
for (int i = 0, min = N.min(lenA, lenB, lenC, len); i < min; i++) {
result[i] = add(rowLen, a[i], b[i], c[i], valueForNoneA, valueForNoneB, valueForNoneC);
}
if (N.min(lenA, lenB, lenC) < len) {
for (int i = N.min(lenA, lenB, lenC); i < len; i++) {
result[i] = add(rowLen, i < lenA ? a[i] : null, i < lenB ? b[i] : null, i < lenC ? c[i] : null, valueForNoneA, valueForNoneB, valueForNoneC);
}
}
return result;
}
public static byte[][][] add(final byte[][][] a, final byte[][][] b) {
final int lenA = N.len(a);
final int lenB = N.len(b);
final byte[][][] result = new byte[N.min(lenA, lenB)][][];
for (int i = 0, len = result.length; i < len; i++) {
result[i] = add(a[i], b[i]);
}
return result;
}
public static byte[][][] add(final byte[][][] a, final byte[][][] b, final byte valueForNoneA, final byte valueForNoneB) {
final int lenA = N.len(a);
final int lenB = N.len(b);
final byte[][][] result = new byte[N.max(lenA, lenB)][][];
for (int i = 0, min = N.min(lenA, lenB); i < min; i++) {
result[i] = add(a[i], b[i], valueForNoneA, valueForNoneB);
}
if (lenA < lenB) {
for (int i = lenA; i < lenB; i++) {
result[i] = add(null, b[i], valueForNoneA, valueForNoneB);
}
} else if (lenB < lenA) {
for (int i = lenB; i < lenA; i++) {
result[i] = add(a[i], null, valueForNoneA, valueForNoneB);
}
}
return result;
}
public static byte[][][] add(final byte[][][] a, final byte[][][] b, final byte[][][] c) {
final int lenA = N.len(a);
final int lenB = N.len(b);
final int lenC = N.len(c);
final byte[][][] result = new byte[N.min(lenA, lenB, lenC)][][];
for (int i = 0, len = result.length; i < len; i++) {
result[i] = add(a[i], b[i], c[i]);
}
return result;
}
public static byte[][][] add(final byte[][][] a, final byte[][][] b, final byte[][][] c, final byte valueForNoneA, final byte valueForNoneB,
final byte valueForNoneC) {
final int lenA = N.len(a);
final int lenB = N.len(b);
final int lenC = N.len(c);
final byte[][][] result = new byte[N.max(lenA, lenB, lenC)][][];
for (int i = 0, min = N.min(lenA, lenB, lenC); i < min; i++) {
result[i] = add(a[i], b[i], c[i], valueForNoneA, valueForNoneB, valueForNoneC);
}
for (int i = N.min(lenA, lenB, lenC), len = result.length; i < len; i++) {
result[i] = add(i < lenA ? a[i] : null, i < lenB ? b[i] : null, i < lenC ? c[i] : null, valueForNoneA, valueForNoneB, valueForNoneC);
}
return result;
}
public static byte[] subtract(final byte[] a, final byte[] b) {
final int lenA = N.len(a);
final int lenB = N.len(b);
final byte[] result = new byte[N.min(lenA, lenB)];
for (int i = 0, len = result.length; i < len; i++) {
result[i] = (byte) (a[i] - b[i]);
}
return result;
}
public static byte[] subtract(final byte[] a, final byte[] b, final byte valueForNoneA, final byte valueForNoneB) {
final int lenA = N.len(a);
final int lenB = N.len(b);
return subtract(N.max(lenA, lenB), a, b, valueForNoneA, valueForNoneB);
}
private static byte[] subtract(final int len, final byte[] a, final byte[] b, final byte valueForNoneA, final byte valueForNoneB) {
final int lenA = N.len(a);
final int lenB = N.len(b);
final byte[] result = new byte[len];
for (int i = 0, min = N.min(lenA, lenB, len); i < min; i++) {
result[i] = (byte) (a[i] - b[i]);
}
if (lenA < lenB && lenA < len) {
for (int i = lenA, min = N.min(lenB, len); i < min; i++) {
result[i] = (byte) (valueForNoneA - b[i]);
}
} else if (lenB < lenA && lenB < len) {
for (int i = lenB, min = N.min(lenA, len); i < min; i++) {
result[i] = (byte) (a[i] - valueForNoneB);
}
}
if (N.max(lenA, lenB) < len) {
for (int i = N.max(lenA, lenB); i < len; i++) {
result[i] = (byte) (valueForNoneA - valueForNoneB);
}
}
return result;
}
public static byte[] subtract(final byte[] a, final byte[] b, final byte[] c) {
final int lenA = N.len(a);
final int lenB = N.len(b);
final int lenC = N.len(c);
final byte[] result = new byte[N.min(lenA, lenB, lenC)];
for (int i = 0, len = result.length; i < len; i++) {
result[i] = (byte) (a[i] - b[i] - c[i]);
}
return result;
}
public static byte[] subtract(final byte[] a, final byte[] b, final byte[] c, final byte valueForNoneA, final byte valueForNoneB,
final byte valueForNoneC) {
final int lenA = N.len(a);
final int lenB = N.len(b);
final int lenC = N.len(c);
return subtract(N.max(lenA, lenB, lenC), a, b, c, valueForNoneA, valueForNoneB, valueForNoneC);
}
private static byte[] subtract(final int len, final byte[] a, final byte[] b, final byte[] c, final byte valueForNoneA, final byte valueForNoneB,
final byte valueForNoneC) {
final int lenA = N.len(a);
final int lenB = N.len(b);
final int lenC = N.len(c);
final byte[] result = new byte[len];
for (int i = 0, min = N.min(lenA, lenB, lenC, len); i < min; i++) {
result[i] = (byte) (a[i] - b[i] - c[i]);
}
if (N.min(lenA, lenB, lenC) < len) {
for (int i = N.min(lenA, lenB, lenC); i < len; i++) {
result[i] = (byte) ((i < lenA ? a[i] : valueForNoneA) - (i < lenB ? b[i] : valueForNoneB) - (i < lenC ? c[i] : valueForNoneC));
}
}
return result;
}
public static byte[][] subtract(final byte[][] a, final byte[][] b) {
final int lenA = N.len(a);
final int lenB = N.len(b);
final byte[][] result = new byte[N.min(lenA, lenB)][];
for (int i = 0, len = result.length; i < len; i++) {
result[i] = subtract(a[i], b[i]);
}
return result;
}
public static byte[][] subtract(final byte[][] a, final byte[][] b, final byte valueForNoneA, final byte valueForNoneB) {
return subtract(N.max(N.len(a), N.len(b)), N.max(maxSubArrayLen(a), maxSubArrayLen(b)), a, b, valueForNoneA, valueForNoneB);
}
private static byte[][] subtract(final int len, final int rowLen, final byte[][] a, final byte[][] b, final byte valueForNoneA, final byte valueForNoneB) {
final int lenA = N.len(a);
final int lenB = N.len(b);
final byte[][] result = new byte[len][];
for (int i = 0, min = N.min(lenA, lenB, len); i < min; i++) {
result[i] = subtract(rowLen, a[i], b[i], valueForNoneA, valueForNoneB);
}
if (lenA < lenB && lenA < len) {
for (int i = lenA, min = N.min(lenB, len); i < min; i++) {
result[i] = subtract(rowLen, null, b[i], valueForNoneA, valueForNoneB);
}
} else if (lenB < lenA && lenB < len) {
for (int i = lenB, min = N.min(lenA, len); i < min; i++) {
result[i] = subtract(rowLen, a[i], null, valueForNoneA, valueForNoneB);
}
}
if (N.max(lenA, lenB) < len) {
for (int i = N.max(lenA, lenB); i < len; i++) {
result[i] = subtract(rowLen, (byte[]) null, (byte[]) null, valueForNoneA, valueForNoneB);
}
}
return result;
}
public static byte[][] subtract(final byte[][] a, final byte[][] b, final byte[][] c) {
final int lenA = N.len(a);
final int lenB = N.len(b);
final int lenC = N.len(c);
final byte[][] result = new byte[N.min(lenA, lenB, lenC)][];
for (int i = 0, len = result.length; i < len; i++) {
result[i] = subtract(a[i], b[i], c[i]);
}
return result;
}
public static byte[][] subtract(final byte[][] a, final byte[][] b, final byte[][] c, final byte valueForNoneA, final byte valueForNoneB,
final byte valueForNoneC) {
return subtract(N.max(N.len(a), N.len(b), N.len(c)), N.max(maxSubArrayLen(a), maxSubArrayLen(b), maxSubArrayLen(c)), a, b, c, valueForNoneA,
valueForNoneB, valueForNoneC);
}
private static byte[][] subtract(final int len, final int rowLen, final byte[][] a, final byte[][] b, final byte[][] c, final byte valueForNoneA,
final byte valueForNoneB, final byte valueForNoneC) {
final int lenA = N.len(a);
final int lenB = N.len(b);
final int lenC = N.len(c);
final byte[][] result = new byte[len][];
for (int i = 0, min = N.min(lenA, lenB, lenC, len); i < min; i++) {
result[i] = subtract(rowLen, a[i], b[i], c[i], valueForNoneA, valueForNoneB, valueForNoneC);
}
if (N.min(lenA, lenB, lenC) < len) {
for (int i = N.min(lenA, lenB, lenC); i < len; i++) {
result[i] = subtract(rowLen, i < lenA ? a[i] : null, i < lenB ? b[i] : null, i < lenC ? c[i] : null, valueForNoneA, valueForNoneB,
valueForNoneC);
}
}
return result;
}
public static byte[][][] subtract(final byte[][][] a, final byte[][][] b) {
final int lenA = N.len(a);
final int lenB = N.len(b);
final byte[][][] result = new byte[N.min(lenA, lenB)][][];
for (int i = 0, len = result.length; i < len; i++) {
result[i] = subtract(a[i], b[i]);
}
return result;
}
public static byte[][][] subtract(final byte[][][] a, final byte[][][] b, final byte valueForNoneA, final byte valueForNoneB) {
final int lenA = N.len(a);
final int lenB = N.len(b);
final byte[][][] result = new byte[N.max(lenA, lenB)][][];
for (int i = 0, min = N.min(lenA, lenB); i < min; i++) {
result[i] = subtract(a[i], b[i], valueForNoneA, valueForNoneB);
}
if (lenA < lenB) {
for (int i = lenA; i < lenB; i++) {
result[i] = subtract(null, b[i], valueForNoneA, valueForNoneB);
}
} else if (lenB < lenA) {
for (int i = lenB; i < lenA; i++) {
result[i] = subtract(a[i], null, valueForNoneA, valueForNoneB);
}
}
return result;
}
public static byte[][][] subtract(final byte[][][] a, final byte[][][] b, final byte[][][] c) {
final int lenA = N.len(a);
final int lenB = N.len(b);
final int lenC = N.len(c);
final byte[][][] result = new byte[N.min(lenA, lenB, lenC)][][];
for (int i = 0, len = result.length; i < len; i++) {
result[i] = subtract(a[i], b[i], c[i]);
}
return result;
}
public static byte[][][] subtract(final byte[][][] a, final byte[][][] b, final byte[][][] c, final byte valueForNoneA, final byte valueForNoneB,
final byte valueForNoneC) {
final int lenA = N.len(a);
final int lenB = N.len(b);
final int lenC = N.len(c);
final byte[][][] result = new byte[N.max(lenA, lenB, lenC)][][];
for (int i = 0, min = N.min(lenA, lenB, lenC); i < min; i++) {
result[i] = subtract(a[i], b[i], c[i], valueForNoneA, valueForNoneB, valueForNoneC);
}
for (int i = N.min(lenA, lenB, lenC), len = result.length; i < len; i++) {
result[i] = subtract(i < lenA ? a[i] : null, i < lenB ? b[i] : null, i < lenC ? c[i] : null, valueForNoneA, valueForNoneB, valueForNoneC);
}
return result;
}
public static byte[] multipliedBy(final byte[] a, final byte[] b) {
final int lenA = N.len(a);
final int lenB = N.len(b);
final byte[] result = new byte[N.min(lenA, lenB)];
for (int i = 0, len = result.length; i < len; i++) {
result[i] = (byte) (a[i] * b[i]);
}
return result;
}
public static byte[] multipliedBy(final byte[] a, final byte[] b, final byte valueForNoneA, final byte valueForNoneB) {
final int lenA = N.len(a);
final int lenB = N.len(b);
return multipliedBy(N.max(lenA, lenB), a, b, valueForNoneA, valueForNoneB);
}
private static byte[] multipliedBy(final int len, final byte[] a, final byte[] b, final byte valueForNoneA, final byte valueForNoneB) {
final int lenA = N.len(a);
final int lenB = N.len(b);
final byte[] result = new byte[len];
for (int i = 0, min = N.min(lenA, lenB, len); i < min; i++) {
result[i] = (byte) (a[i] * b[i]);
}
if (lenA < lenB && lenA < len) {
for (int i = lenA, min = N.min(lenB, len); i < min; i++) {
result[i] = (byte) (valueForNoneA * b[i]);
}
} else if (lenB < lenA && lenB < len) {
for (int i = lenB, min = N.min(lenA, len); i < min; i++) {
result[i] = (byte) (a[i] * valueForNoneB);
}
}
if (N.max(lenA, lenB) < len) {
for (int i = N.max(lenA, lenB); i < len; i++) {
result[i] = (byte) (valueForNoneA * valueForNoneB);
}
}
return result;
}
public static byte[] multipliedBy(final byte[] a, final byte[] b, final byte[] c) {
final int lenA = N.len(a);
final int lenB = N.len(b);
final int lenC = N.len(c);
final byte[] result = new byte[N.min(lenA, lenB, lenC)];
for (int i = 0, len = result.length; i < len; i++) {
result[i] = (byte) (a[i] * b[i] * c[i]);
}
return result;
}
public static byte[] multipliedBy(final byte[] a, final byte[] b, final byte[] c, final byte valueForNoneA, final byte valueForNoneB,
final byte valueForNoneC) {
final int lenA = N.len(a);
final int lenB = N.len(b);
final int lenC = N.len(c);
return multipliedBy(N.max(lenA, lenB, lenC), a, b, c, valueForNoneA, valueForNoneB, valueForNoneC);
}
private static byte[] multipliedBy(final int len, final byte[] a, final byte[] b, final byte[] c, final byte valueForNoneA, final byte valueForNoneB,
final byte valueForNoneC) {
final int lenA = N.len(a);
final int lenB = N.len(b);
final int lenC = N.len(c);
final byte[] result = new byte[len];
for (int i = 0, min = N.min(lenA, lenB, lenC, len); i < min; i++) {
result[i] = (byte) (a[i] * b[i] * c[i]);
}
if (N.min(lenA, lenB, lenC) < len) {
for (int i = N.min(lenA, lenB, lenC); i < len; i++) {
result[i] = (byte) ((i < lenA ? a[i] : valueForNoneA) * (i < lenB ? b[i] : valueForNoneB) * (i < lenC ? c[i] : valueForNoneC));
}
}
return result;
}
public static byte[][] multipliedBy(final byte[][] a, final byte[][] b) {
final int lenA = N.len(a);
final int lenB = N.len(b);
final byte[][] result = new byte[N.min(lenA, lenB)][];
for (int i = 0, len = result.length; i < len; i++) {
result[i] = multipliedBy(a[i], b[i]);
}
return result;
}
public static byte[][] multipliedBy(final byte[][] a, final byte[][] b, final byte valueForNoneA, final byte valueForNoneB) {
return multipliedBy(N.max(N.len(a), N.len(b)), N.max(maxSubArrayLen(a), maxSubArrayLen(b)), a, b, valueForNoneA, valueForNoneB);
}
private static byte[][] multipliedBy(final int len, final int rowLen, final byte[][] a, final byte[][] b, final byte valueForNoneA,
final byte valueForNoneB) {
final int lenA = N.len(a);
final int lenB = N.len(b);
final byte[][] result = new byte[len][];
for (int i = 0, min = N.min(lenA, lenB, len); i < min; i++) {
result[i] = multipliedBy(rowLen, a[i], b[i], valueForNoneA, valueForNoneB);
}
if (lenA < lenB && lenA < len) {
for (int i = lenA, min = N.min(lenB, len); i < min; i++) {
result[i] = multipliedBy(rowLen, null, b[i], valueForNoneA, valueForNoneB);
}
} else if (lenB < lenA && lenB < len) {
for (int i = lenB, min = N.min(lenA, len); i < min; i++) {
result[i] = multipliedBy(rowLen, a[i], null, valueForNoneA, valueForNoneB);
}
}
if (N.max(lenA, lenB) < len) {
for (int i = N.max(lenA, lenB); i < len; i++) {
result[i] = multipliedBy(rowLen, (byte[]) null, (byte[]) null, valueForNoneA, valueForNoneB);
}
}
return result;
}
public static byte[][] multipliedBy(final byte[][] a, final byte[][] b, final byte[][] c) {
final int lenA = N.len(a);
final int lenB = N.len(b);
final int lenC = N.len(c);
final byte[][] result = new byte[N.min(lenA, lenB, lenC)][];
for (int i = 0, len = result.length; i < len; i++) {
result[i] = multipliedBy(a[i], b[i], c[i]);
}
return result;
}
public static byte[][] multipliedBy(final byte[][] a, final byte[][] b, final byte[][] c, final byte valueForNoneA, final byte valueForNoneB,
final byte valueForNoneC) {
return multipliedBy(N.max(N.len(a), N.len(b), N.len(c)), N.max(maxSubArrayLen(a), maxSubArrayLen(b), maxSubArrayLen(c)), a, b, c, valueForNoneA,
valueForNoneB, valueForNoneC);
}
private static byte[][] multipliedBy(final int len, final int rowLen, final byte[][] a, final byte[][] b, final byte[][] c, final byte valueForNoneA,
final byte valueForNoneB, final byte valueForNoneC) {
final int lenA = N.len(a);
final int lenB = N.len(b);
final int lenC = N.len(c);
final byte[][] result = new byte[len][];
for (int i = 0, min = N.min(lenA, lenB, lenC, len); i < min; i++) {
result[i] = multipliedBy(rowLen, a[i], b[i], c[i], valueForNoneA, valueForNoneB, valueForNoneC);
}
if (N.min(lenA, lenB, lenC) < len) {
for (int i = N.min(lenA, lenB, lenC); i < len; i++) {
result[i] = multipliedBy(rowLen, i < lenA ? a[i] : null, i < lenB ? b[i] : null, i < lenC ? c[i] : null, valueForNoneA, valueForNoneB,
valueForNoneC);
}
}
return result;
}
public static byte[][][] multipliedBy(final byte[][][] a, final byte[][][] b) {
final int lenA = N.len(a);
final int lenB = N.len(b);
final byte[][][] result = new byte[N.min(lenA, lenB)][][];
for (int i = 0, len = result.length; i < len; i++) {
result[i] = multipliedBy(a[i], b[i]);
}
return result;
}
public static byte[][][] multipliedBy(final byte[][][] a, final byte[][][] b, final byte valueForNoneA, final byte valueForNoneB) {
final int lenA = N.len(a);
final int lenB = N.len(b);
final byte[][][] result = new byte[N.max(lenA, lenB)][][];
for (int i = 0, min = N.min(lenA, lenB); i < min; i++) {
result[i] = multipliedBy(a[i], b[i], valueForNoneA, valueForNoneB);
}
if (lenA < lenB) {
for (int i = lenA; i < lenB; i++) {
result[i] = multipliedBy(null, b[i], valueForNoneA, valueForNoneB);
}
} else if (lenB < lenA) {
for (int i = lenB; i < lenA; i++) {
result[i] = multipliedBy(a[i], null, valueForNoneA, valueForNoneB);
}
}
return result;
}
public static byte[][][] multipliedBy(final byte[][][] a, final byte[][][] b, final byte[][][] c) {
final int lenA = N.len(a);
final int lenB = N.len(b);
final int lenC = N.len(c);
final byte[][][] result = new byte[N.min(lenA, lenB, lenC)][][];
for (int i = 0, len = result.length; i < len; i++) {
result[i] = multipliedBy(a[i], b[i], c[i]);
}
return result;
}
public static byte[][][] multipliedBy(final byte[][][] a, final byte[][][] b, final byte[][][] c, final byte valueForNoneA, final byte valueForNoneB,
final byte valueForNoneC) {
final int lenA = N.len(a);
final int lenB = N.len(b);
final int lenC = N.len(c);
final byte[][][] result = new byte[N.max(lenA, lenB, lenC)][][];
for (int i = 0, min = N.min(lenA, lenB, lenC); i < min; i++) {
result[i] = multipliedBy(a[i], b[i], c[i], valueForNoneA, valueForNoneB, valueForNoneC);
}
for (int i = N.min(lenA, lenB, lenC), len = result.length; i < len; i++) {
result[i] = multipliedBy(i < lenA ? a[i] : null, i < lenB ? b[i] : null, i < lenC ? c[i] : null, valueForNoneA, valueForNoneB, valueForNoneC);
}
return result;
}
public static byte[] dividedBy(final byte[] a, final byte[] b) {
final int lenA = N.len(a);
final int lenB = N.len(b);
final byte[] result = new byte[N.min(lenA, lenB)];
for (int i = 0, len = result.length; i < len; i++) {
result[i] = (byte) (a[i] / b[i]);
}
return result;
}
public static byte[] dividedBy(final byte[] a, final byte[] b, final byte valueForNoneA, final byte valueForNoneB) {
final int lenA = N.len(a);
final int lenB = N.len(b);
return dividedBy(N.max(lenA, lenB), a, b, valueForNoneA, valueForNoneB);
}
private static byte[] dividedBy(final int len, final byte[] a, final byte[] b, final byte valueForNoneA, final byte valueForNoneB) {
final int lenA = N.len(a);
final int lenB = N.len(b);
final byte[] result = new byte[len];
for (int i = 0, min = N.min(lenA, lenB, len); i < min; i++) {
result[i] = (byte) (a[i] / b[i]);
}
if (lenA < lenB && lenA < len) {
for (int i = lenA, min = N.min(lenB, len); i < min; i++) {
result[i] = (byte) (valueForNoneA / b[i]);
}
} else if (lenB < lenA && lenB < len) {
for (int i = lenB, min = N.min(lenA, len); i < min; i++) {
result[i] = (byte) (a[i] / valueForNoneB);
}
}
if (N.max(lenA, lenB) < len) {
for (int i = N.max(lenA, lenB); i < len; i++) {
result[i] = (byte) (valueForNoneA / valueForNoneB);
}
}
return result;
}
public static byte[] dividedBy(final byte[] a, final byte[] b, final byte[] c) {
final int lenA = N.len(a);
final int lenB = N.len(b);
final int lenC = N.len(c);
final byte[] result = new byte[N.min(lenA, lenB, lenC)];
for (int i = 0, len = result.length; i < len; i++) {
result[i] = (byte) (a[i] / b[i] / c[i]);
}
return result;
}
public static byte[] dividedBy(final byte[] a, final byte[] b, final byte[] c, final byte valueForNoneA, final byte valueForNoneB,
final byte valueForNoneC) {
final int lenA = N.len(a);
final int lenB = N.len(b);
final int lenC = N.len(c);
return dividedBy(N.max(lenA, lenB, lenC), a, b, c, valueForNoneA, valueForNoneB, valueForNoneC);
}
private static byte[] dividedBy(final int len, final byte[] a, final byte[] b, final byte[] c, final byte valueForNoneA, final byte valueForNoneB,
final byte valueForNoneC) {
final int lenA = N.len(a);
final int lenB = N.len(b);
final int lenC = N.len(c);
final byte[] result = new byte[len];
for (int i = 0, min = N.min(lenA, lenB, lenC, len); i < min; i++) {
result[i] = (byte) (a[i] / b[i] / c[i]);
}
if (N.min(lenA, lenB, lenC) < len) {
for (int i = N.min(lenA, lenB, lenC); i < len; i++) {
result[i] = (byte) ((i < lenA ? a[i] : valueForNoneA) / (i < lenB ? b[i] : valueForNoneB) / (i < lenC ? c[i] : valueForNoneC));
}
}
return result;
}
public static byte[][] dividedBy(final byte[][] a, final byte[][] b) {
final int lenA = N.len(a);
final int lenB = N.len(b);
final byte[][] result = new byte[N.min(lenA, lenB)][];
for (int i = 0, len = result.length; i < len; i++) {
result[i] = dividedBy(a[i], b[i]);
}
return result;
}
public static byte[][] dividedBy(final byte[][] a, final byte[][] b, final byte valueForNoneA, final byte valueForNoneB) {
return dividedBy(N.max(N.len(a), N.len(b)), N.max(maxSubArrayLen(a), maxSubArrayLen(b)), a, b, valueForNoneA, valueForNoneB);
}
private static byte[][] dividedBy(final int len, final int rowLen, final byte[][] a, final byte[][] b, final byte valueForNoneA, final byte valueForNoneB) {
final int lenA = N.len(a);
final int lenB = N.len(b);
final byte[][] result = new byte[len][];
for (int i = 0, min = N.min(lenA, lenB, len); i < min; i++) {
result[i] = dividedBy(rowLen, a[i], b[i], valueForNoneA, valueForNoneB);
}
if (lenA < lenB && lenA < len) {
for (int i = lenA, min = N.min(lenB, len); i < min; i++) {
result[i] = dividedBy(rowLen, null, b[i], valueForNoneA, valueForNoneB);
}
} else if (lenB < lenA && lenB < len) {
for (int i = lenB, min = N.min(lenA, len); i < min; i++) {
result[i] = dividedBy(rowLen, a[i], null, valueForNoneA, valueForNoneB);
}
}
if (N.max(lenA, lenB) < len) {
for (int i = N.max(lenA, lenB); i < len; i++) {
result[i] = dividedBy(rowLen, (byte[]) null, (byte[]) null, valueForNoneA, valueForNoneB);
}
}
return result;
}
public static byte[][] dividedBy(final byte[][] a, final byte[][] b, final byte[][] c) {
final int lenA = N.len(a);
final int lenB = N.len(b);
final int lenC = N.len(c);
final byte[][] result = new byte[N.min(lenA, lenB, lenC)][];
for (int i = 0, len = result.length; i < len; i++) {
result[i] = dividedBy(a[i], b[i], c[i]);
}
return result;
}
public static byte[][] dividedBy(final byte[][] a, final byte[][] b, final byte[][] c, final byte valueForNoneA, final byte valueForNoneB,
final byte valueForNoneC) {
return dividedBy(N.max(N.len(a), N.len(b), N.len(c)), N.max(maxSubArrayLen(a), maxSubArrayLen(b), maxSubArrayLen(c)), a, b, c, valueForNoneA,
valueForNoneB, valueForNoneC);
}
private static byte[][] dividedBy(final int len, final int rowLen, final byte[][] a, final byte[][] b, final byte[][] c, final byte valueForNoneA,
final byte valueForNoneB, final byte valueForNoneC) {
final int lenA = N.len(a);
final int lenB = N.len(b);
final int lenC = N.len(c);
final byte[][] result = new byte[len][];
for (int i = 0, min = N.min(lenA, lenB, lenC, len); i < min; i++) {
result[i] = dividedBy(rowLen, a[i], b[i], c[i], valueForNoneA, valueForNoneB, valueForNoneC);
}
if (N.min(lenA, lenB, lenC) < len) {
for (int i = N.min(lenA, lenB, lenC); i < len; i++) {
result[i] = dividedBy(rowLen, i < lenA ? a[i] : null, i < lenB ? b[i] : null, i < lenC ? c[i] : null, valueForNoneA, valueForNoneB,
valueForNoneC);
}
}
return result;
}
public static byte[][][] dividedBy(final byte[][][] a, final byte[][][] b) {
final int lenA = N.len(a);
final int lenB = N.len(b);
final byte[][][] result = new byte[N.min(lenA, lenB)][][];
for (int i = 0, len = result.length; i < len; i++) {
result[i] = dividedBy(a[i], b[i]);
}
return result;
}
public static byte[][][] dividedBy(final byte[][][] a, final byte[][][] b, final byte valueForNoneA, final byte valueForNoneB) {
final int lenA = N.len(a);
final int lenB = N.len(b);
final byte[][][] result = new byte[N.max(lenA, lenB)][][];
for (int i = 0, min = N.min(lenA, lenB); i < min; i++) {
result[i] = dividedBy(a[i], b[i], valueForNoneA, valueForNoneB);
}
if (lenA < lenB) {
for (int i = lenA; i < lenB; i++) {
result[i] = dividedBy(null, b[i], valueForNoneA, valueForNoneB);
}
} else if (lenB < lenA) {
for (int i = lenB; i < lenA; i++) {
result[i] = dividedBy(a[i], null, valueForNoneA, valueForNoneB);
}
}
return result;
}
public static byte[][][] dividedBy(final byte[][][] a, final byte[][][] b, final byte[][][] c) {
final int lenA = N.len(a);
final int lenB = N.len(b);
final int lenC = N.len(c);
final byte[][][] result = new byte[N.min(lenA, lenB, lenC)][][];
for (int i = 0, len = result.length; i < len; i++) {
result[i] = dividedBy(a[i], b[i], c[i]);
}
return result;
}
public static byte[][][] dividedBy(final byte[][][] a, final byte[][][] b, final byte[][][] c, final byte valueForNoneA, final byte valueForNoneB,
final byte valueForNoneC) {
final int lenA = N.len(a);
final int lenB = N.len(b);
final int lenC = N.len(c);
final byte[][][] result = new byte[N.max(lenA, lenB, lenC)][][];
for (int i = 0, min = N.min(lenA, lenB, lenC); i < min; i++) {
result[i] = dividedBy(a[i], b[i], c[i], valueForNoneA, valueForNoneB, valueForNoneC);
}
for (int i = N.min(lenA, lenB, lenC), len = result.length; i < len; i++) {
result[i] = dividedBy(i < lenA ? a[i] : null, i < lenB ? b[i] : null, i < lenC ? c[i] : null, valueForNoneA, valueForNoneB, valueForNoneC);
}
return result;
}
public static byte[] dividedBy(final byte[] a, final byte[] b, final byte defaultValueForZero) {
final int lenA = N.len(a);
final int lenB = N.len(b);
final byte[] result = new byte[N.min(lenA, lenB)];
for (int i = 0, len = result.length; i < len; i++) {
result[i] = (byte) (a[i] / (b[i] == 0 ? defaultValueForZero : b[i]));
}
return result;
}
public static byte[] dividedBy(final byte[] a, final byte[] b, final byte valueForNoneA, final byte valueForNoneB, final byte defaultValueForZero) {
final int lenA = N.len(a);
final int lenB = N.len(b);
return dividedBy(N.max(lenA, lenB), a, b, valueForNoneA, valueForNoneB, defaultValueForZero);
}
private static byte[] dividedBy(final int len, final byte[] a, final byte[] b, final byte valueForNoneA, final byte valueForNoneB,
final byte defaultValueForZero) {
final int lenA = N.len(a);
final int lenB = N.len(b);
final byte[] result = new byte[len];
for (int i = 0, min = N.min(lenA, lenB, len); i < min; i++) {
result[i] = (byte) (a[i] / (b[i] == 0 ? defaultValueForZero : b[i]));
}
if (lenA < lenB && lenA < len) {
for (int i = lenA, min = N.min(lenB, len); i < min; i++) {
result[i] = (byte) (valueForNoneA / (b[i] == 0 ? defaultValueForZero : b[i]));
}
} else if (lenB < lenA && lenB < len) {
for (int i = lenB, min = N.min(lenA, len); i < min; i++) {
result[i] = (byte) (a[i] / valueForNoneB);
}
}
if (N.max(lenA, lenB) < len) {
for (int i = N.max(lenA, lenB); i < len; i++) {
result[i] = (byte) (valueForNoneA / valueForNoneB);
}
}
return result;
}
public static byte[] dividedBy(final byte[] a, final byte[] b, final byte[] c, final byte defaultValueForZero) {
final int lenA = N.len(a);
final int lenB = N.len(b);
final int lenC = N.len(c);
final byte[] result = new byte[N.min(lenA, lenB, lenC)];
for (int i = 0, len = result.length; i < len; i++) {
result[i] = (byte) (a[i] / (b[i] == 0 ? defaultValueForZero : b[i]) / (c[i] == 0 ? defaultValueForZero : c[i]));
}
return result;
}
public static byte[] dividedBy(final byte[] a, final byte[] b, final byte[] c, final byte valueForNoneA, final byte valueForNoneB, final byte valueForNoneC,
final byte defaultValueForZero) {
final int lenA = N.len(a);
final int lenB = N.len(b);
final int lenC = N.len(c);
return dividedBy(N.max(lenA, lenB, lenC), a, b, c, valueForNoneA, valueForNoneB, valueForNoneC, defaultValueForZero);
}
private static byte[] dividedBy(final int len, final byte[] a, final byte[] b, final byte[] c, final byte valueForNoneA, final byte valueForNoneB,
final byte valueForNoneC, final byte defaultValueForZero) {
final int lenA = N.len(a);
final int lenB = N.len(b);
final int lenC = N.len(c);
final byte[] result = new byte[len];
for (int i = 0, min = N.min(lenA, lenB, lenC, len); i < min; i++) {
result[i] = (byte) (a[i] / (b[i] == 0 ? defaultValueForZero : b[i]) / (c[i] == 0 ? defaultValueForZero : c[i]));
}
if (N.min(lenA, lenB, lenC) < len) {
for (int i = N.min(lenA, lenB, lenC); i < len; i++) {
result[i] = (byte) ((i < lenA ? a[i] : valueForNoneA) / (i < lenB ? (b[i] == 0 ? defaultValueForZero : b[i]) : valueForNoneB)
/ (i < lenC ? (c[i] == 0 ? defaultValueForZero : c[i]) : valueForNoneC));
}
}
return result;
}
public static byte[][] dividedBy(final byte[][] a, final byte[][] b, final byte defaultValueForZero) {
final int lenA = N.len(a);
final int lenB = N.len(b);
final byte[][] result = new byte[N.min(lenA, lenB)][];
for (int i = 0, len = result.length; i < len; i++) {
result[i] = dividedBy(a[i], b[i], defaultValueForZero);
}
return result;
}
public static byte[][] dividedBy(final byte[][] a, final byte[][] b, final byte valueForNoneA, final byte valueForNoneB, final byte defaultValueForZero) {
return dividedBy(N.max(N.len(a), N.len(b)), N.max(maxSubArrayLen(a), maxSubArrayLen(b)), a, b, valueForNoneA, valueForNoneB, defaultValueForZero);
}
private static byte[][] dividedBy(final int len, final int rowLen, final byte[][] a, final byte[][] b, final byte valueForNoneA, final byte valueForNoneB,
final byte defaultValueForZero) {
final int lenA = N.len(a);
final int lenB = N.len(b);
final byte[][] result = new byte[len][];
for (int i = 0, min = N.min(lenA, lenB, len); i < min; i++) {
result[i] = dividedBy(rowLen, a[i], b[i], valueForNoneA, valueForNoneB, defaultValueForZero);
}
if (lenA < lenB && lenA < len) {
for (int i = lenA, min = N.min(lenB, len); i < min; i++) {
result[i] = dividedBy(rowLen, null, b[i], valueForNoneA, valueForNoneB, defaultValueForZero);
}
} else if (lenB < lenA && lenB < len) {
for (int i = lenB, min = N.min(lenA, len); i < min; i++) {
result[i] = dividedBy(rowLen, a[i], null, valueForNoneA, valueForNoneB, defaultValueForZero);
}
}
if (N.max(lenA, lenB) < len) {
for (int i = N.max(lenA, lenB); i < len; i++) {
result[i] = dividedBy(rowLen, (byte[]) null, (byte[]) null, valueForNoneA, valueForNoneB, defaultValueForZero);
}
}
return result;
}
public static byte[][] dividedBy(final byte[][] a, final byte[][] b, final byte[][] c, final byte defaultValueForZero) {
final int lenA = N.len(a);
final int lenB = N.len(b);
final int lenC = N.len(c);
final byte[][] result = new byte[N.min(lenA, lenB, lenC)][];
for (int i = 0, len = result.length; i < len; i++) {
result[i] = dividedBy(a[i], b[i], c[i], defaultValueForZero);
}
return result;
}
public static byte[][] dividedBy(final byte[][] a, final byte[][] b, final byte[][] c, final byte valueForNoneA, final byte valueForNoneB,
final byte valueForNoneC, final byte defaultValueForZero) {
return dividedBy(N.max(N.len(a), N.len(b), N.len(c)), N.max(maxSubArrayLen(a), maxSubArrayLen(b), maxSubArrayLen(c)), a, b, c, valueForNoneA,
valueForNoneB, valueForNoneC, defaultValueForZero);
}
private static byte[][] dividedBy(final int len, final int rowLen, final byte[][] a, final byte[][] b, final byte[][] c, final byte valueForNoneA,
final byte valueForNoneB, final byte valueForNoneC, final byte defaultValueForZero) {
final int lenA = N.len(a);
final int lenB = N.len(b);
final int lenC = N.len(c);
final byte[][] result = new byte[len][];
for (int i = 0, min = N.min(lenA, lenB, lenC, len); i < min; i++) {
result[i] = dividedBy(rowLen, a[i], b[i], c[i], valueForNoneA, valueForNoneB, valueForNoneC, defaultValueForZero);
}
if (N.min(lenA, lenB, lenC) < len) {
for (int i = N.min(lenA, lenB, lenC); i < len; i++) {
result[i] = dividedBy(rowLen, i < lenA ? a[i] : null, i < lenB ? b[i] : null, i < lenC ? c[i] : null, valueForNoneA, valueForNoneB,
valueForNoneC, defaultValueForZero);
}
}
return result;
}
public static byte[][][] dividedBy(final byte[][][] a, final byte[][][] b, final byte defaultValueForZero) {
final int lenA = N.len(a);
final int lenB = N.len(b);
final byte[][][] result = new byte[N.min(lenA, lenB)][][];
for (int i = 0, len = result.length; i < len; i++) {
result[i] = dividedBy(a[i], b[i], defaultValueForZero);
}
return result;
}
public static byte[][][] dividedBy(final byte[][][] a, final byte[][][] b, final byte valueForNoneA, final byte valueForNoneB,
final byte defaultValueForZero) {
final int lenA = N.len(a);
final int lenB = N.len(b);
final byte[][][] result = new byte[N.max(lenA, lenB)][][];
for (int i = 0, min = N.min(lenA, lenB); i < min; i++) {
result[i] = dividedBy(a[i], b[i], valueForNoneA, valueForNoneB, defaultValueForZero);
}
if (lenA < lenB) {
for (int i = lenA; i < lenB; i++) {
result[i] = dividedBy(null, b[i], valueForNoneA, valueForNoneB, defaultValueForZero);
}
} else if (lenB < lenA) {
for (int i = lenB; i < lenA; i++) {
result[i] = dividedBy(a[i], null, valueForNoneA, valueForNoneB, defaultValueForZero);
}
}
return result;
}
public static byte[][][] dividedBy(final byte[][][] a, final byte[][][] b, final byte[][][] c, final byte defaultValueForZero) {
final int lenA = N.len(a);
final int lenB = N.len(b);
final int lenC = N.len(c);
final byte[][][] result = new byte[N.min(lenA, lenB, lenC)][][];
for (int i = 0, len = result.length; i < len; i++) {
result[i] = dividedBy(a[i], b[i], c[i], defaultValueForZero);
}
return result;
}
public static byte[][][] dividedBy(final byte[][][] a, final byte[][][] b, final byte[][][] c, final byte valueForNoneA, final byte valueForNoneB,
final byte valueForNoneC, final byte defaultValueForZero) {
final int lenA = N.len(a);
final int lenB = N.len(b);
final int lenC = N.len(c);
final byte[][][] result = new byte[N.max(lenA, lenB, lenC)][][];
for (int i = 0, min = N.min(lenA, lenB, lenC); i < min; i++) {
result[i] = dividedBy(a[i], b[i], c[i], valueForNoneA, valueForNoneB, valueForNoneC, defaultValueForZero);
}
for (int i = N.min(lenA, lenB, lenC), len = result.length; i < len; i++) {
result[i] = dividedBy(i < lenA ? a[i] : null, i < lenB ? b[i] : null, i < lenC ? c[i] : null, valueForNoneA, valueForNoneB, valueForNoneC,
defaultValueForZero);
}
return result;
}
public static byte[] zip(final byte[] a, final byte[] b, final Try.ByteBiFunction zipFunction) throws E {
final int lenA = N.len(a);
final int lenB = N.len(b);
final byte[] result = new byte[N.min(lenA, lenB)];
for (int i = 0, len = result.length; i < len; i++) {
result[i] = zipFunction.apply(a[i], b[i]);
}
return result;
}
public static byte[] zip(final byte[] a, final byte[] b, final byte valueForNoneA, final byte valueForNoneB,
final Try.ByteBiFunction