Maturity Index: Experimental
Rather, it is indexed by character offsets : the message at: or runLengthAt: takes a character offset as argument, and translates this offset to a segment offset (the segment to which the character belongs) and returns the attributes or segment length, for that segment.
The size of a RunArray is the largest character offset plus one;it is not the number of segments.
+newCreates an empty RunArray collection.
-free
-valuesReturns a collection of OrdCltn instances (each element being a list of TextAttribute instances).
-runsReturns the run array (array of int).
-at:(unsigned)iReturns a collection of TextAttributes for the i-th character.
This method translates a character offset into a segment number. The segment number is cached so that a subsequent call to at: or runLengthAt: doesn't have to recompute it.
- (unsigned)runLengthAt:(unsigned)iReturns the number of remaining characters in the string segment to which the character at position i belongs. If i is the first character of a run, this method returns the size of the run. Otherwise it returns the size minus the index of character in the run.
- (unsigned)sizeReturns the size of the RunArray, which is the same as the size of the String instance for this RunArray object.
The number of runs can be obtained by sending a size message to the object returned by values.
-addAttribute:attribfrom:(unsigned)psize:(unsigned)sAdds attrib to the attribute lists for the s characters from position p.
Note: This method is optimized for adding at the end of the RunArray.
-at:(unsigned)anOffsetinsert:(char*)aStringcount:(int)n
-deleteFrom:(unsigned)pto:(unsigned)q
-concat:b
-coalesceMerges adjacent lists of TextAttribute instances, by testing whether they are equal (in the sense of TextAttribute's isEqual method).
-printOn:(IOD)aFilePrints the RunArray values.