| 91 | } |
| 92 | |
| 93 | func (ra *roaringArray64) appendCopiesAfter(sa roaringArray64, beforeStart uint32) { |
| 94 | // cow only if the two request it, or if we already have a lightweight copy |
| 95 | copyonwrite := ra.copyOnWrite && sa.copyOnWrite |
| 96 | |
| 97 | startLocation := sa.getIndex(beforeStart) |
| 98 | if startLocation >= 0 { |
| 99 | startLocation++ |
| 100 | } else { |
| 101 | startLocation = -startLocation - 1 |
| 102 | } |
| 103 | |
| 104 | for i := startLocation; i < sa.size(); i++ { |
| 105 | thiscopyonewrite := copyonwrite || sa.needsCopyOnWrite(i) |
| 106 | if thiscopyonewrite { |
| 107 | ra.appendContainer(sa.keys[i], sa.containers[i], thiscopyonewrite) |
| 108 | if !sa.needsCopyOnWrite(i) { |
| 109 | sa.setNeedsCopyOnWrite(i) |
| 110 | } |
| 111 | } else { |
| 112 | // since there is no copy-on-write, we need to clone the container (this is important) |
| 113 | ra.appendContainer(sa.keys[i], sa.containers[i].Clone(), thiscopyonewrite) |
| 114 | } |
| 115 | } |
| 116 | } |
| 117 | |
| 118 | func (ra *roaringArray64) removeIndexRange(begin, end int) { |
| 119 | if end <= begin { |