class Terms {

    synchronized void append( long index, long term )
    {
        if ( index != max + 1 )
        {
            throw new IllegalStateException( format( "Must append in order. %s but expected index is %d",
                    appendMessage( index, term ), max + 1 ) );
        }
        else if ( size > 0 && term < terms[size - 1] )
        {
            throw new IllegalStateException( format( "Non-monotonic term. %s but highest term is %d",
                    appendMessage( index, term ), terms[size - 1] ) );
        }

        max = index;

        if ( size == 0 || term != terms[size - 1] )
        {
            setSize( size + 1 );
            indexes[size - 1] = index;
            terms[size - 1] = term;
        }
    }

      Terms( long prevIndex, long prevTerm );

}