newRunContainer16FromArray populates a new runContainer16 from the contents of arr.
(arr *arrayContainer)
| 253 | // newRunContainer16FromArray populates a new |
| 254 | // runContainer16 from the contents of arr. |
| 255 | func newRunContainer16FromArray(arr *arrayContainer) *runContainer16 { |
| 256 | // keep this in sync with newRunContainer16FromVals above |
| 257 | |
| 258 | rc := &runContainer16{} |
| 259 | ah := addHelper16{rc: rc} |
| 260 | |
| 261 | n := arr.getCardinality() |
| 262 | var cur, prev uint16 |
| 263 | switch { |
| 264 | case n == 0: |
| 265 | // nothing more |
| 266 | case n == 1: |
| 267 | ah.m = append(ah.m, newInterval16Range(arr.content[0], arr.content[0])) |
| 268 | ah.actuallyAdded++ |
| 269 | default: |
| 270 | ah.runstart = arr.content[0] |
| 271 | ah.actuallyAdded++ |
| 272 | for i := 1; i < n; i++ { |
| 273 | prev = arr.content[i-1] |
| 274 | cur = arr.content[i] |
| 275 | ah.add(cur, prev, i) |
| 276 | } |
| 277 | ah.storeIval(ah.runstart, ah.runlen) |
| 278 | } |
| 279 | rc.iv = ah.m |
| 280 | return rc |
| 281 | } |
| 282 | |
| 283 | // set adds the integers in vals to the set. Vals |
| 284 | // must be sorted in increasing order; if not, you should set |
searching dependent graphs…