()
| 1245 | } |
| 1246 | |
| 1247 | func (ac *arrayContainer) numberOfRuns() (nr int) { |
| 1248 | n := len(ac.content) |
| 1249 | var runlen uint16 |
| 1250 | var cur, prev uint16 |
| 1251 | |
| 1252 | switch n { |
| 1253 | case 0: |
| 1254 | return 0 |
| 1255 | case 1: |
| 1256 | return 1 |
| 1257 | default: |
| 1258 | for i := 1; i < n; i++ { |
| 1259 | prev = ac.content[i-1] |
| 1260 | cur = ac.content[i] |
| 1261 | |
| 1262 | if cur == prev+1 { |
| 1263 | runlen++ |
| 1264 | } else { |
| 1265 | if cur < prev { |
| 1266 | panic("the fundamental arrayContainer assumption of sorted ac.content was broken") |
| 1267 | } |
| 1268 | if cur == prev { |
| 1269 | panic("the fundamental arrayContainer assumption of deduplicated content was broken") |
| 1270 | } else { |
| 1271 | nr++ |
| 1272 | runlen = 0 |
| 1273 | } |
| 1274 | } |
| 1275 | } |
| 1276 | nr++ |
| 1277 | } |
| 1278 | return |
| 1279 | } |
| 1280 | |
| 1281 | // convert to run or array *if needed* |
| 1282 | func (ac *arrayContainer) toEfficientContainer() container { |
no outgoing calls
no test coverage detected