private fun emitCharMapArray(): Int { val cl: CharClasses = parser.getCharClasses() if (cl.getMaxCharCode() < 256) { emitCharMapArrayUnPacked() return 0 } intervals = cl.getIntervals() println("") println(" /** ") println(" * Translates characters to character classes") println(" */") println(" private static final String ZZ_CMAP_PACKED = ") var n = 0 print(" \"") var i = 0 var numPairs = 0 var count: Int var value: Int while (i < intervals.length) { count = intervals.get(i).end - intervals.get(i).start + 1 value = colMap.get(intervals.get(i).charClass) while (count > 0xFFFF) { printUC(0xFFFF) printUC(value) count -= 0xFFFF numPairs++ n++ }  numPairs++ printUC(count) printUC(value) if (i < intervals.length - 1) { if (++n >= 10) { println("\"+") print(" \"") n = 0 } } i++ } println("\";") println() println(" /** ") println(" * Translates characters to character classes") println(" */") println(" private static final char [] ZZ_CMAP = zzUnpackCMap(ZZ_CMAP_PACKED);") println() return numPairs }
Returns the number of elements in the packed char map array , or zero if the char map array will be not be packed . This will be more than intervals.length if the count for any of the values is more than 0xFFFF , since the number of char map array entries per value is ceil ( count / 0xFFFF )