public static void mergeTo()

in core/src/main/java/org/apache/ignite/activestore/impl/subscriber/lead/MergeHelper.java [40:69]


    public static void mergeTo(List<TxInfo> from, LinkedList<TxInfo> to) {
        if (from.isEmpty()) {
            return;
        }
        Iterator<TxInfo> fromIterator = from.iterator();
        ListIterator<TxInfo> toIterator = to.listIterator();
        TxInfo currentFromElement = null;
        if (toIterator.hasNext()) {
            currentFromElement = fromIterator.next();
            while (currentFromElement != null && toIterator.hasNext()) {
                TxInfo existing = toIterator.next();
                int compare = COMPARATOR.compare(existing, currentFromElement);
                if (compare == 0) {
                    toIterator.remove();
                    toIterator.add(currentFromElement);
                    currentFromElement = fromIterator.hasNext() ? fromIterator.next() : null;
                } else if (compare > 0) {
                    toIterator.previous();
                    toIterator.add(currentFromElement);
                    currentFromElement = fromIterator.hasNext() ? fromIterator.next() : null;
                }
            }
        }
        if (currentFromElement != null) {
            to.add(currentFromElement);
        }
        while (fromIterator.hasNext()) {
            to.add(fromIterator.next());
        }
    }