class PhraseQueue extends PriorityQueue<PhrasePositions> {

    PhraseQueue(int size) {
        super(size);
    }

    @Override
    protected boolean lessThan(PhrasePositions pp1, PhrasePositions pp2) {<FILL_FUNCTION_BODY>}
}

        if (pp1.position == pp2.position) {
            // same doc and pp.position, so decide by actual term positions.
            // rely on: pp.position == tp.position - offset.
            if (pp1.offset == pp2.offset) {
                return pp1.ord < pp2.ord;
            } else {
                return pp1.offset < pp2.offset;
            }
        } else {
            return pp1.position < pp2.position;
        }
    
<no_super_class>