Code with Finding: |
class BidiOrder {
/**
* Return reordering array breaking lines at offsets in linebreaks.
* <p>
* The reordering array maps from a visual index to a logical index.
* Lines are concatenated from left to right. So for example, the
* fifth character from the left on the third line is
* <pre> getReordering(linebreaks)[linebreaks[1] + 4]</pre>
* (linebreaks[1] is the position after the last character of the
* second line, which is also the index of the first character on the
* third line, and adding four gets the fifth character from the left).
* <p>
* The linebreaks array must include at least one value.
* The values must be in strictly increasing order (no duplicates)
* between 1 and the length of the text, inclusive. The last value
* must be the length of the text.
*
* @param linebreaks the offsets at which to break the paragraph.
*/
public int[] getReordering(int[] linebreaks) {
validateLineBreaks(linebreaks, textLength);
byte[] levels = getLevels(linebreaks);
return computeMultilineReordering(levels, linebreaks);
}
}
|