50 while (
growSize <
static_cast<ptrdiff_t
>(
body.size() / 6))
92 throw std::runtime_error(
"SplitVector::ReAllocate: negative size.");
94 if (newSize >
static_cast<ptrdiff_t
>(
body.size())) {
101 body.reserve(newSize);
102 body.resize(newSize);
127 template <
typename ParamType>
193 if (insertLength > 0) {
212 if (insertLength > 0) {
220 body[elem] = std::move(emptyOne);
232 if (
Length() < wantedLength) {
238 void InsertFromArray(ptrdiff_t positionToInsert,
const T s[], ptrdiff_t positionFrom, ptrdiff_t insertLength) {
240 if (insertLength > 0) {
241 if ((positionToInsert < 0) || (positionToInsert >
lengthBody)) {
245 GapTo(positionToInsert);
246 std::copy(s + positionFrom, s + positionFrom + insertLength,
body.data() +
part1Length);
270 }
else if (deleteLength > 0) {
285 ptrdiff_t range1Length = 0;
288 range1Length = retrieveLength;
289 if (range1Length > part1AfterPosition)
290 range1Length = part1AfterPosition;
293 buffer += range1Length;
295 const ptrdiff_t range2Length = retrieveLength - range1Length;
SplitVector(const SplitVector &)=delete
T * InsertEmpty(ptrdiff_t position, ptrdiff_t insertLength)
Add some new empty elements.
T * RangePointer(ptrdiff_t position, ptrdiff_t rangeLength) noexcept
Return a pointer to a range of elements, first rearranging the buffer if needed to make that range co...
void EnsureLength(ptrdiff_t wantedLength)
Ensure at least length elements allocated, appending zero valued elements if needed.
ptrdiff_t GetGrowSize() const noexcept
void operator=(const SplitVector &)=delete
void InsertFromArray(ptrdiff_t positionToInsert, const T s[], ptrdiff_t positionFrom, ptrdiff_t insertLength)
Insert text into the buffer from an array.
void RoomFor(ptrdiff_t insertionLength)
Check that there is room in the buffer for an insertion, reallocating if more space needed.
SplitVector()
Construct a split buffer.
void DeleteAll()
Delete all the buffer contents.
SplitVector(SplitVector &&)=delete
void DeleteRange(ptrdiff_t position, ptrdiff_t deleteLength)
Delete a range from the buffer.
void GetRange(T *buffer, ptrdiff_t position, ptrdiff_t retrieveLength) const noexcept
Retrieve a range of elements into an array.
void Insert(ptrdiff_t position, T v)
Insert a single value into the buffer.
ptrdiff_t Length() const noexcept
Retrieve the length of the buffer.
const T & operator[](ptrdiff_t position) const noexcept
Retrieve the element at a particular position.
void Delete(ptrdiff_t position)
Delete one element from the buffer.
ptrdiff_t GapPosition() const noexcept
Return the position of the gap within the buffer.
T * BufferPointer()
Compact the buffer and return a pointer to the first element.
void SetValueAt(ptrdiff_t position, ParamType &&v) noexcept
Set the element at a particular position.
void InsertValue(ptrdiff_t position, ptrdiff_t insertLength, T v)
Insert a number of elements into the buffer setting their value.
const T & ValueAt(ptrdiff_t position) const noexcept
Retrieve the element at a particular position.
void GapTo(ptrdiff_t position) noexcept
Move the gap to a particular position so that insertion and deletion at that point will not require m...
ptrdiff_t growSize
invariant: gapLength == body.size() - lengthBody
void SetGrowSize(ptrdiff_t growSize_) noexcept
ptrdiff_t lengthBody
Returned as the result of out-of-bounds access.
void operator=(SplitVector &&)=delete
T & operator[](ptrdiff_t position) noexcept
Retrieve reference to the element at a particular position.
void ReAllocate(ptrdiff_t newSize)
Reallocate the storage for the buffer to be newSize and copy existing contents to the new buffer.
#define fill(Order, Group, Idx, Charset, Name)
Styling buffer using one element for each run rather than using a filled buffer.