23 template<
typename A,
typename D >
28 , nMaxAccess( nMaxAccessP)
30 pData[0].aValue = rValue;
34 template<
typename A,
typename D >
44 bool bFound = (
nCount == 1);
45 while (!bFound && nLo <= nHi)
53 if (nEnd < static_cast<tools::Long>(nAccess))
56 if (nStart >= static_cast<tools::Long>(nAccess))
61 return (bFound ? static_cast<size_t>(i) : (nAccess < 0 ? 0 :
nCount-1));
64 template<
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]);
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)
114 pData[ni-1].nEnd = nEnd;
115 nInsert = nMaxAccess+1;
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;
165 if (nInsert < static_cast<size_t>(nMaxAccess+1))
170 memmove(
pData.get() + nInsert + 1,
pData.get() + nInsert,
174 memmove(
pData.get() + nInsert + 2,
pData.get() + nInsert,
176 pData[nInsert+1] = pData[nInsert-1];
181 pData[nInsert-1].nEnd = nStart - 1;
182 pData[nInsert].nEnd = nEnd;
183 pData[nInsert].aValue = aNewVal;
189 template<
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);
209 template<
typename A,
typename D >
216 if (nIndex > 0 &&
pData[nIndex-1].nEnd+1 == nStart)
218 const D& rValue =
pData[nIndex].aValue;
221 pData[nIndex].nEnd += nAccessCount;
222 if (
pData[nIndex].nEnd >= nMaxAccess)
224 pData[nIndex].nEnd = nMaxAccess;
227 }
while (++nIndex <
nCount);
231 template<
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);
244 template<
typename A,
typename D >
247 A nEnd = nStart + nAccessCount - 1;
250 if (nEnd >
pData[nIndex].nEnd)
253 if ((nStart == 0 || (nIndex > 0 && nStart ==
pData[nIndex-1].nEnd+1)) &&
261 if (nIndex > 0 &&
pData[nIndex-1].aValue ==
pData[nIndex+1].aValue)
268 memmove(
pData.get() + nIndex,
pData.get() + nIndex + nRemove, (
nCount - (nIndex +
275 pData[nIndex].nEnd -= nAccessCount;
276 }
while (++nIndex <
nCount);
280 template<
typename A,
typename D >
283 const A nPrevLastPos = GetLastPos();
285 Remove(nStart, nAccessCount);
287 const A nNewLastPos = GetLastPos();
288 InsertPreservingSize(nNewLastPos, nNewLastPos - nPrevLastPos, rFillValue);
291 template<
typename A,
typename D >
299 template<
typename A,
typename D >
302 A nRegion = mnRegion + nAccessCount;
304 while (nRegion > mrArray.pData[
nIndex].nEnd)
311 template<
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);
328 nIndex = this->
Search( nE + 1);
330 else if (this->
pData[nIndex].nEnd >= nEnd)
334 }
while (nIndex < this->
nCount);
337 template<
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);
354 nIndex = this->
Search( nE + 1);
356 else if (this->
pData[nIndex].nEnd >= nEnd)
360 }
while (nIndex < this->
nCount);
363 template<
typename A,
typename D >
366 const D& rValueToAnd )
370 for (
A j=nStart; j<=nEnd; ++j)
372 const D& rValue = (j==nStart ?
373 rArray.
GetValue( j, nIndex, nRegionEnd) :
375 if (nRegionEnd > nEnd)
377 this->
SetValue( j, nRegionEnd, rValue & rValueToAnd);
382 template<
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)
const D & GetNextValue(size_t &nIndex, A &nEnd) const
Get next value and it's region end row.
void CopyFromAnded(const ScBitMaskCompressedArray &rArray, A nStart, A nEnd, const D &rValueToAnd)
Copy values from rArray and bitwise AND them with rValueToAnd.
void Remove(A nStart, size_t nCount)
std::unique_ptr< sal_Int32[]> pData
void AndValue(A nPos, const D &rValueToAnd)
void InsertPreservingSize(A nStart, size_t nCount, const D &rFillValue)
A GetLastAnyBitAccess(const D &rBitMask) const
Return the last row where an entry meets the condition: ((aValue & rBitMask) != 0), start searching at 0.
SC_DLLPUBLIC size_t Search(A nPos) const
Obtain index into entries for nPos.
const ScCompressedArray & mrArray
void SetValue(A nPos, const D &rValue)
void RemovePreservingSize(A nStart, size_t nCount, const D &rFillValue)
ScCompressedArray(A nMaxAccess, const D &rValue)
Construct with nMaxAccess=MAXROW, for example.
const D & GetValue(A nPos) const
Iterator operator+(size_t) const
void CopyFrom(const ScCompressedArray &rArray, A nStart, A nEnd)
Copy rArray.nStart+nSourceDy to this.nStart.
Compressed array of row (or column) entries, e.g.
The data type represents bits, manageable by bitwise operations.
void OrValue(A nPos, const D &rValueToOr)
virtual void Insert(SotClipboardFormatId nFormat, const OUString &rFormatName) override
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
virtual void SetValue(tools::Long nNew) override