public List txnIds()

in accord-core/src/main/java/accord/primitives/KeyDeps.java [437:486]


    public List<TxnId> txnIds(Range range)
    {
        int startIndex = keys.indexOf(range.start());
        if (startIndex < 0) startIndex = -1 - startIndex;
        else if (!range.startInclusive()) ++startIndex;

        int endIndex = keys.indexOf(range.end());
        if (endIndex < 0) endIndex = -1 - endIndex;
        else if (range.endInclusive()) ++endIndex;

        if (startIndex == endIndex)
            return Collections.emptyList();

        int maxLength = Math.min(txnIds.length, startOffset(endIndex) - startOffset(startIndex));
        int[] scratch = cachedInts().getInts(maxLength);
        int count = 0;
        for (int i = startIndex ; i < endIndex ; ++i)
        {
            int ri = startOffset(i), re = endOffset(i);
            if (ri == re)
                continue;

            System.arraycopy(scratch, 0, scratch, maxLength - count, count);
            int li = maxLength - count, le = maxLength;
            count = 0;
            while (li < le && ri < re)
            {
                int c = scratch[li] - keysToTxnIds[ri];
                if (c <= 0)
                {
                    scratch[count++] = scratch[li++];
                    if (c == 0) ++ri;
                }
                else
                {
                    scratch[count++] = keysToTxnIds[ri++];
                }
            }
            while (li < le)
                scratch[count++] = scratch[li++];
            while (ri < re)
                scratch[count++] = keysToTxnIds[ri++];

            if (count == maxLength)
                break;
        }

        int[] ids = cachedInts().completeAndDiscard(scratch, count);
        return txnIds(ids, 0, count);
    }