public static <T> List<Object> encode_modified(List<T> list) { return P09.pack(list) .stream() .map( l -> { if (l.size() == 1) { return l.get(0); } return new SimpleEntry<>(l.size(), l.get(0)); }) .collect(toList()); }
public static <T> List<SimpleEntry<Integer, T>> encode(List<T> list) { return P09.pack(list) .stream() .map(l -> new SimpleEntry<>(l.size(), l.get(0))) .collect(toList()); }