Adds entries to the index and updates subsequent nodes. @param pre insertion position @param clip data clip
(final int pre, final DataClip clip)
| 142 | * @param clip data clip |
| 143 | */ |
| 144 | void insert(final int pre, final DataClip clip) { |
| 145 | // find all document nodes in the given data instance |
| 146 | final IntList il = new IntList(); |
| 147 | final Data src = clip.data; |
| 148 | for(int dpre = clip.start; dpre < clip.end;) { |
| 149 | final int k = src.kind(dpre); |
| 150 | if(k == Data.DOC) il.add(pre + dpre); |
| 151 | dpre += src.size(dpre, k); |
| 152 | } |
| 153 | final int[] pres = il.finish(); |
| 154 | final int ps = pres.length; |
| 155 | |
| 156 | // find insertion offset |
| 157 | final IntList docs = docs(); |
| 158 | int i = docs.sortedIndexOf(pre); |
| 159 | if(i < 0) i = -i - 1; |
| 160 | |
| 161 | // insert paths from given data instance |
| 162 | if(pathIndex) { |
| 163 | final TokenList paths = paths(); |
| 164 | final byte[][] tmp = new byte[ps][]; |
| 165 | for(int t = 0; t < ps; t++) tmp[t] = normalize(clip.data.text(pres[t] - pre, true)); |
| 166 | paths.insert(i, tmp); |
| 167 | } |
| 168 | |
| 169 | // insert PRE values |
| 170 | docs.insert(i, pres); |
| 171 | // adjust PRE values of following document nodes |
| 172 | docs.incFrom(clip.size(), i + ps); |
| 173 | |
| 174 | update(); |
| 175 | } |
| 176 | |
| 177 | /** |
| 178 | * Deletes the specified entry and updates subsequent nodes. |
nothing calls this directly
no test coverage detected