public static int[][] split(byte[] str, int offset, int length, byte[] separator, int[][] indices) { if (indices.length == 0) { return indices; // trivial } final int limit = offset + length; int start = offset; int colIndex = 0; for (int index = offset; index < limit;) { if (onDelimiter(str, index, limit, separator)) { indices[colIndex++] = new int[] {start, index}; if (colIndex >= indices.length) { return indices; } index += separator.length; start = index; } else { index++; } } if (colIndex < indices.length) { indices[colIndex] = new int[]{start, limit}; } return indices; }
public static int[][] split(byte[] str, int offset, int length, byte[] separator, int[][] indices) { if (indices.length == 0) { return indices; // trivial } final int limit = offset + length; int start = offset; int colIndex = 0; for (int index = offset; index < limit;) { if (onDelimiter(str, index, limit, separator)) { indices[colIndex++] = new int[] {start, index}; if (colIndex >= indices.length) { return indices; } index += separator.length; start = index; } else { index++; } } if (colIndex < indices.length) { indices[colIndex] = new int[]{start, limit}; } return indices; }