A sparse array indexing; used to indicate whether a specified index is empty or with elements.
The alogrithm assumes the elements is mostly stored in a continueous way. So this issue can be converted to the compression of black/white pixels issue. We use negative number to indicate continuous black pixels(empty) while zero and postive number to indicate continuous white pixels(with element), so the representation of a horizontal line can be compressed into short arrays.
e.g. We use byte array to represent a horizontal line with 200 pixels which start with 50 white pixels and 150 black pixels. Then we indicate it in a byte array with byte[0] == 49 (0 represents 1 pixel), byte[1] == -128 (since -128 is the negative "maximum" a byte can represent), and byte[2] == -22 (note -128 -22 == -150).
The implementation will guarantee the array with lower index will hold as many index as possible. i.e. for the above example, byte[1] must be -128. No way that byte[1] is -100 and byte[2] is -50.
@author henrichen @see SparseShortIndex
|
|