23template<
typename A,
typename D >
28 , nMaxAccess( nMaxAccessP)
30 pData[0].aValue = rValue;
34template<
typename A,
typename D >
44 bool bFound = (
nCount == 1);
45 while (!bFound && nLo <= nHi)
61 return (bFound ?
static_cast<size_t>(i) : (nAccess < 0 ? 0 :
nCount-1));
64template<
typename A,
typename D >
67 if (!(0 <= nStart && nStart <= nMaxAccess && 0 <= nEnd && nEnd <= nMaxAccess
71 if ((nStart == 0) && (nEnd == nMaxAccess))
78 size_t nNeeded =
nCount + 2;
84 std::unique_ptr<DataEntry[]> pNewData(
new DataEntry[nLimit]);
85 memcpy( pNewData.get(),
pData.get(), nCount*
sizeof(DataEntry));
86 pData = std::move(pNewData);
91 bool bCombined =
false;
96 ni = this->
Search( nStart);
98 nInsert = nMaxAccess+1;
99 if (!(pData[ni].aValue == aNewVal))
101 if (ni == 0 || (
pData[ni-1].nEnd < nStart - 1))
104 if (pData[ni].nEnd > nEnd)
109 else if (ni > 0 && pData[ni-1].nEnd == nStart - 1)
112 if (ni > 0 && pData[ni-1].aValue == aNewVal)
115 nInsert = nMaxAccess+1;
126 while (nj < nCount && pData[nj].nEnd <= nEnd)
130 if (nj < nCount && pData[nj].aValue == aNewVal)
134 if (pData[ni-1].aValue == aNewVal)
139 else if (ni == nInsert)
140 pData[ni-1].nEnd = nStart - 1;
142 nInsert = nMaxAccess+1;
145 else if (ni > 0 && ni == nInsert)
146 pData[ni-1].nEnd = nStart - 1;
152 pData[ni].nEnd = nEnd;
153 pData[ni].aValue = aNewVal;
155 nInsert = nMaxAccess+1;
160 (nCount - nj) *
sizeof(DataEntry));
165 if (nInsert <
static_cast<size_t>(nMaxAccess+1))
167 if (nInsert <= nCount)
170 memmove(
pData.get() + nInsert + 1,
pData.get() + nInsert,
171 (nCount - nInsert) *
sizeof(DataEntry));
174 memmove(
pData.get() + nInsert + 2,
pData.get() + nInsert,
175 (nCount - nInsert) *
sizeof(DataEntry));
181 pData[nInsert-1].nEnd = nStart - 1;
182 pData[nInsert].nEnd = nEnd;
183 pData[nInsert].aValue = aNewVal;
189template<
typename A,
typename D >
191 A nDestEnd,
A nSrcStart )
193 assert(
this != &rArray &&
"cannot copy self->self" );
196 for (
A j=nDestStart; j<=nDestEnd; ++j)
198 const D& rValue = (j==nDestStart ?
199 rArray.
GetValue( j - nDestStart + nSrcStart,
nIndex, nRegionEnd) :
201 nRegionEnd = nRegionEnd - nSrcStart + nDestStart;
202 if (nRegionEnd > nDestEnd)
203 nRegionEnd = nDestEnd;
204 this->
SetValue( j, nRegionEnd, rValue);
209template<
typename A,
typename D >
231template<
typename A,
typename D >
234 const A nPrevLastPos = GetLastPos();
236 Insert(nStart, nAccessCount);
237 for (
A i = nStart;
i <
A(nStart + nAccessCount); ++
i)
240 const A nNewLastPos = GetLastPos();
241 Remove(nPrevLastPos, nNewLastPos - nPrevLastPos);
244template<
typename A,
typename D >
247 A nEnd = nStart + nAccessCount - 1;
280template<
typename A,
typename D >
283 const A nPrevLastPos = GetLastPos();
285 Remove(nStart, nAccessCount);
287 const A nNewLastPos = GetLastPos();
288 InsertPreservingSize(nNewLastPos, nNewLastPos - nPrevLastPos, rFillValue);
291template<
typename A,
typename D >
299template<
typename A,
typename D >
302 A nRegion = mnRegion + nAccessCount;
304 while (nRegion > mrArray.pData[
nIndex].nEnd)
311template<
typename A,
typename D >
313 const D& rValueToAnd )
321 if ((this->
pData[nIndex].aValue & rValueToAnd) != this->
pData[nIndex].aValue)
323 A nS = ::std::max<A>( (
nIndex>0 ? this->
pData[nIndex-1].nEnd+1 : 0), nStart);
324 A nE = ::std::min( this->
pData[nIndex].nEnd, nEnd);
325 this->
SetValue( nS, nE, this->
pData[nIndex].aValue & rValueToAnd);
330 else if (this->
pData[nIndex].nEnd >= nEnd)
334 }
while (nIndex < this->
nCount);
337template<
typename A,
typename D >
339 const D& rValueToOr )
347 if ((this->
pData[nIndex].aValue | rValueToOr) != this->
pData[nIndex].aValue)
349 A nS = ::std::max<A>( (
nIndex>0 ? this->
pData[nIndex-1].nEnd+1 : 0), nStart);
350 A nE = ::std::min( this->
pData[nIndex].nEnd, nEnd);
351 this->
SetValue( nS, nE, this->
pData[nIndex].aValue | rValueToOr);
356 else if (this->
pData[nIndex].nEnd >= nEnd)
360 }
while (nIndex < this->
nCount);
363template<
typename A,
typename D >
366 const D& rValueToAnd )
370 for (
A j=nStart; j<=nEnd; ++j)
372 const D& rValue = (j==nStart ?
375 if (nRegionEnd > nEnd)
377 this->
SetValue( j, nRegionEnd, rValue & rValueToAnd);
382template<
typename A,
typename D >
385 A nEnd = ::std::numeric_limits<A>::max();
389 if (this->
pData[nIndex].aValue & rBitMask)
391 nEnd = this->
pData[nIndex].nEnd;
399 if (this->
pData[nIndex].nEnd < 0)
The data type represents bits, manageable by bitwise operations.
void AndValue(A nPos, const D &rValueToAnd)
void CopyFromAnded(const ScBitMaskCompressedArray &rArray, A nStart, A nEnd, const D &rValueToAnd)
Copy values from rArray and bitwise AND them with rValueToAnd.
A GetLastAnyBitAccess(const D &rBitMask) const
Return the last row where an entry meets the condition: ((aValue & rBitMask) != 0),...
void OrValue(A nPos, const D &rValueToOr)
Iterator operator+(size_t) const
const ScCompressedArray & mrArray
Compressed array of row (or column) entries, e.g.
const D & Insert(A nStart, size_t nCount)
Insert rows before nStart and copy value for inserted rows from nStart-1, return that value.
std::unique_ptr< DataEntry[]> pData
ScCompressedArray(A nMaxAccess, const D &rValue)
Construct with nMaxAccess=MAXROW, for example.
void InsertPreservingSize(A nStart, size_t nCount, const D &rFillValue)
void SetValue(A nPos, const D &rValue)
const D & GetNextValue(size_t &nIndex, A &nEnd) const
Get next value and it's region end row.
SC_DLLPUBLIC size_t Search(A nPos) const
Obtain index into entries for nPos.
const D & GetValue(A nPos) const
void CopyFrom(const ScCompressedArray &rArray, A nStart, A nEnd)
Copy rArray.nStart+nSourceDy to this.nStart.
void RemovePreservingSize(A nStart, size_t nCount, const D &rFillValue)
void Remove(A nStart, size_t nCount)
virtual void Insert(SotClipboardFormatId nFormat, const OUString &rFormatName) override
virtual void SetValue(tools::Long nNew) override
std::unique_ptr< sal_Int32[]> pData