public SequenceSet deepCopy(SequenceSet value) { SequenceSet rc = new SequenceSet(); Sequence sequence = value.getHead(); while (sequence != null) { rc.add(new Sequence(sequence.first, sequence.last)); sequence = sequence.getNext(); } return rc; }
public SequenceSet readPayload(DataInput in) throws IOException { SequenceSet value = new SequenceSet(); int count = in.readInt(); for (int i = 0; i < count; i++) { if (in.readBoolean()) { Sequence sequence = new Sequence(in.readLong(), in.readLong()); value.addLast(sequence); } else { Sequence sequence = new Sequence(in.readLong()); value.addLast(sequence); } } return value; }
public void writePayload(SequenceSet value, DataOutput out) throws IOException { out.writeInt(value.size()); Sequence sequence = value.getHead(); while (sequence != null) { if (sequence.range() > 1) { out.writeBoolean(true); out.writeLong(sequence.first); out.writeLong(sequence.last); } else { out.writeBoolean(false); out.writeLong(sequence.first); } sequence = sequence.getNext(); } }