public AtomContext merge(AtomContext other) { if (other == null || other.atoms == null || other.atoms.object == null) { return this; } if (atoms == null || atoms.object == null) { return this; } if (atoms.exclusive()) { atoms.object = Lexicographic.merge(atoms.object, other.atoms.object); other.discard(); return this; } if (other.atoms.exclusive()) { return other.merge(this); } List<ByteBuffer> merged = Lexicographic.merge(atoms.object, other.atoms.object); discard(); other.discard(); atoms = new RefCount<>(merged); atoms.ref(); return this; }
AtomContext(List<ByteBuffer> atoms) { this(new RefCount<>(atoms)); }
AtomContext(RefCount<List<ByteBuffer>> atoms) { this.atoms = atoms; this.atoms.ref(); }
void discard() { atoms.deref(); atoms = null; }