@Test public void testSortOrder() { final List<List<String>> data = asList(nodata, data0, data2, data1, data4, data3, data5); final TreeSet<Text> sortedEnc = new TreeSet<>(); final SequenceLexicoder<String> sequenceLexicoder = new SequenceLexicoder<>(new StringLexicoder()); for (final List<String> list : data) { sortedEnc.add(new Text(sequenceLexicoder.encode(list))); } final List<List<String>> unenc = new ArrayList<>(); for (final Text enc : sortedEnc) { unenc.add(sequenceLexicoder.decode(TextUtil.getBytes(enc))); } assertEquals(data, unenc); }
@Override public byte[] encode(final List<E> v) { final byte[][] encElements = new byte[v.size() + 1][]; int index = 0; for (final E element : v) { encElements[index++] = escape(elementLexicoder.encode(element)); } encElements[v.size()] = EMPTY_ELEMENT; return concat(encElements); }
SequenceLexicoder extends AbstractLexicoder<List<E>> { @Override public byte[] encode(final List<E> v) { final byte[][] encElements = new byte[v.size() + 1][]; int index = 0; for (final E element : v) { encElements[index++] = escape(elementLexicoder.encode(element)); } encElements[v.size()] = EMPTY_ELEMENT; return concat(encElements); } }
SequenceLexicoder extends AbstractLexicoder<List<E>> { @Override public byte[] encode(final List<E> v) { final byte[][] encElements = new byte[v.size() + 1][]; int index = 0; for (final E element : v) { encElements[index++] = escape(elementLexicoder.encode(element)); } encElements[v.size()] = EMPTY_ELEMENT; return concat(encElements); } SequenceLexicoder(final Lexicoder<E> elementLexicoder); }
SequenceLexicoder extends AbstractLexicoder<List<E>> { @Override public byte[] encode(final List<E> v) { final byte[][] encElements = new byte[v.size() + 1][]; int index = 0; for (final E element : v) { encElements[index++] = escape(elementLexicoder.encode(element)); } encElements[v.size()] = EMPTY_ELEMENT; return concat(encElements); } SequenceLexicoder(final Lexicoder<E> elementLexicoder); @Override byte[] encode(final List<E> v); }
SequenceLexicoder extends AbstractLexicoder<List<E>> { @Override public byte[] encode(final List<E> v) { final byte[][] encElements = new byte[v.size() + 1][]; int index = 0; for (final E element : v) { encElements[index++] = escape(elementLexicoder.encode(element)); } encElements[v.size()] = EMPTY_ELEMENT; return concat(encElements); } SequenceLexicoder(final Lexicoder<E> elementLexicoder); @Override byte[] encode(final List<E> v);  }