| 114 | } |
| 115 | } |
| 116 | void DeletePosition(Sci::Position position) { |
| 117 | assert(position < Length()); |
| 118 | Sci::Position partition = starts->PartitionFromPosition(position); |
| 119 | const Sci::Position startPartition = starts->PositionFromPartition(partition); |
| 120 | if (startPartition == position) { |
| 121 | if (partition == 0) { |
| 122 | ClearValue(0); |
| 123 | } else if (partition == starts->Partitions()) { |
| 124 | // This should not be possible |
| 125 | ClearValue(partition); |
| 126 | throw std::runtime_error("SparseVector: deleting end partition."); |
| 127 | } else { |
| 128 | ClearValue(partition); |
| 129 | starts->RemovePartition(partition); |
| 130 | values->Delete(partition); |
| 131 | // Its the previous partition now that gets smaller |
| 132 | partition--; |
| 133 | } |
| 134 | } |
| 135 | starts->InsertText(partition, -1); |
| 136 | } |
| 137 | void Check() const { |
| 138 | if (Length() < 0) { |
| 139 | throw std::runtime_error("SparseVector: Length can not be negative."); |
no test coverage detected