A sparse array indexing; used to indicate whether a specified index is empty or with elements.
The alogrithm assumes elements are 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 40000 pixels which start with 50 white pixels and 39950 black pixels. Then we indicate it in a short array with short[0] == 49 (0 represents 1 pixel), byte[1] == -32768 (since -32768 is the negative "maximum" a short can represent), and byte[2] == -7182 (note -32768 - 7182 == -39950).
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 -32768. No way that byte[1] is -30000 and byte[2] is -9950.
@author henrichen @see SparseByteIndex
|
|