| 61 | } |
| 62 | template <typename ParamType> |
| 63 | void SetValueAt(Sci::Position position, ParamType &&value) { |
| 64 | assert(position < Length()); |
| 65 | const Sci::Position partition = starts->PartitionFromPosition(position); |
| 66 | const Sci::Position startPartition = starts->PositionFromPartition(partition); |
| 67 | if (value == T()) { |
| 68 | // Setting the empty value is equivalent to deleting the position |
| 69 | if (position == 0) { |
| 70 | ClearValue(partition); |
| 71 | } else if (position == startPartition) { |
| 72 | // Currently an element at this position, so remove |
| 73 | ClearValue(partition); |
| 74 | starts->RemovePartition(partition); |
| 75 | values->Delete(partition); |
| 76 | } |
| 77 | // Else element remains empty |
| 78 | } else { |
| 79 | if (position == startPartition) { |
| 80 | // Already a value at this position, so replace |
| 81 | ClearValue(partition); |
| 82 | values->SetValueAt(partition, std::forward<ParamType>(value)); |
| 83 | } else { |
| 84 | // Insert a new element |
| 85 | starts->InsertPartition(partition + 1, position); |
| 86 | values->Insert(partition + 1, std::forward<ParamType>(value)); |
| 87 | } |
| 88 | } |
| 89 | } |
| 90 | void InsertSpace(Sci::Position position, Sci::Position insertLength) { |
| 91 | assert(position <= Length()); // Only operation that works at end. |
| 92 | const Sci::Position partition = starts->PartitionFromPosition(position); |
no test coverage detected