Move the gap to a particular position so that insertion and deletion at that point will not require much copying and hence be fast.
| 23 | /// deletion at that point will not require much copying and |
| 24 | /// hence be fast. |
| 25 | void GapTo(int position) { |
| 26 | if (position != part1Length) { |
| 27 | if (position < part1Length) { |
| 28 | memmove( |
| 29 | body + position + gapLength, |
| 30 | body + position, |
| 31 | sizeof(T) * (part1Length - position)); |
| 32 | } else { // position > part1Length |
| 33 | memmove( |
| 34 | body + part1Length, |
| 35 | body + part1Length + gapLength, |
| 36 | sizeof(T) * (position - part1Length)); |
| 37 | } |
| 38 | part1Length = position; |
| 39 | } |
| 40 | } |
| 41 | |
| 42 | /// Check that there is room in the buffer for an insertion, |
| 43 | /// reallocating if more space needed. |
nothing calls this directly
no outgoing calls
no test coverage detected