List of utility methods to do Array Flatten
Object[] | flattenArray(Object... objects) flatten Array List result = new ArrayList(); for (Object obj : objects) { if (obj instanceof Object[]) { result.addAll(Arrays.asList((Object[]) obj)); } else if (obj instanceof List) { result.addAll((List) obj); } else { result.add(obj); ... |
String | flattenArray(Object[] words) Converts object array to a big string separated by comma. return flattenArray(words, ","); |
String | flattenArray(String[] aString) Flattens a string array for printing with NO commas StringBuilder sb = new StringBuilder(); for (String s : aString) { if (sb.length() > 0) sb.append(" "); sb.append(s.toString()); return sb.toString(); |
String | flattenBytes(byte[] b) flatten Bytes String out = ""; for (int i = 0; i < b.length; i++) { out += ", " + b[i]; return out; |
int | flattenIndices(int[] indices, int[] extents) Given n-dimensional indices and their dimensional extents flatten them into a 1d index. int totalIdx = 0; for (int i = 0; i < indices.length; i++) { int idx = indices[i]; for (int j = 0; j < i; j++) { int extent = extents[j]; idx *= extent; totalIdx += idx; ... |
String | flattenNTriples(final String[] values) Flatten a list of triples to n-tuples containing many objects for the same subject/predicate pair. final Map<String, StringBuilder> map = new HashMap<String, StringBuilder>(); return flattenNTriples(values, map); |
String | flattenStringArray(String[] s_array, String delimiter) flatten String Array StringBuffer flat = new StringBuffer(); for (int i = 0; i < s_array.length; i++) { flat.append(s_array[i]).append(delimiter); return flat.toString(); |