// stores all strings as UTF8 (typically half as big) static class CondensedStrings2 extends AbstractList implements RandomAccess { byte[] data; int[] indices; *() {} // only for serialisation *(L l) { long totalLength = 0; for (S s : l) totalLength += l(toUtf8(s)); int len = (int) totalLength; if (len != totalLength) fail("TOO BIG!!!!!! " + totalLength); data = new byte[len]; int n = l(l); indices = new int[n]; int idx = 0; for (int i = 0; i < n; i++) { S s = l.get(i); try { byte[] x = toUtf8(s); System.arraycopy(x, 0, data, idx, l(x)); indices[i] = idx; idx += l(x); } catch (RuntimeException e) { print("idx=" + idx + ", s=" + s + ", i=" + i +", n=" + n + ", len=" + len); throw e; } } } public S get(int i) ctex { int idx1 = indices[i]; int idx2 = i+1 < indices.length ? indices[i+1] : data.length; ret fastu_fromUtf8(data, idx1, idx2-idx1); } public int size() { ret indices.length; } int totalSize() { ret data.length; } }