23 template<
typename A,
typename D >
28 , nMaxAccess( nMaxAccessP)
30 pData[0].aValue = rValue;
34 template<
typename A,
typename D >
39 template<
typename A,
typename D >
49 bool bFound = (
nCount == 1);
50 while (!bFound && nLo <= nHi)
58 if (nEnd < static_cast<tools::Long>(nAccess))
61 if (nStart >= static_cast<tools::Long>(nAccess))
66 return (bFound ? static_cast<size_t>(i) : (nAccess < 0 ? 0 :
nCount-1));
69 template<
typename A,
typename D >
72 if (!(0 <= nStart && nStart <= nMaxAccess && 0 <= nEnd && nEnd <= nMaxAccess
76 if ((nStart == 0) && (nEnd == nMaxAccess))
83 size_t nNeeded =
nCount + 2;
89 std::unique_ptr<DataEntry[]> pNewData(
new DataEntry[nLimit]);
91 pData = std::move(pNewData);
96 bool bCombined =
false;
101 ni = this->
Search( nStart);
103 nInsert = nMaxAccess+1;
104 if (!(
pData[ni].aValue == aNewVal))
106 if (ni == 0 || (
pData[ni-1].nEnd < nStart - 1))
109 if (
pData[ni].nEnd > nEnd)
114 else if (ni > 0 &&
pData[ni-1].nEnd == nStart - 1)
117 if (ni > 0 &&
pData[ni-1].aValue == aNewVal)
119 pData[ni-1].nEnd = nEnd;
120 nInsert = nMaxAccess+1;
139 if (
pData[ni-1].aValue == aNewVal)
144 else if (ni == nInsert)
145 pData[ni-1].nEnd = nStart - 1;
147 nInsert = nMaxAccess+1;
150 else if (ni > 0 && ni == nInsert)
151 pData[ni-1].nEnd = nStart - 1;
157 pData[ni].nEnd = nEnd;
158 pData[ni].aValue = aNewVal;
160 nInsert = nMaxAccess+1;
170 if (nInsert < static_cast<size_t>(nMaxAccess+1))
175 memmove(
pData.get() + nInsert + 1,
pData.get() + nInsert,
179 memmove(
pData.get() + nInsert + 2,
pData.get() + nInsert,
181 pData[nInsert+1] = pData[nInsert-1];
186 pData[nInsert-1].nEnd = nStart - 1;
187 pData[nInsert].nEnd = nEnd;
188 pData[nInsert].aValue = aNewVal;
194 template<
typename A,
typename D >
196 A nDestEnd,
A nSrcStart )
198 assert(
this != &rArray &&
"cannot copy self->self" );
201 for (
A j=nDestStart; j<=nDestEnd; ++j)
203 const D&
rValue = (j==nDestStart ?
204 rArray.
GetValue( j - nDestStart + nSrcStart, nIndex, nRegionEnd) :
206 nRegionEnd = nRegionEnd - nSrcStart + nDestStart;
207 if (nRegionEnd > nDestEnd)
208 nRegionEnd = nDestEnd;
209 this->
SetValue( j, nRegionEnd, rValue);
214 template<
typename A,
typename D >
221 if (nIndex > 0 &&
pData[nIndex-1].nEnd+1 == nStart)
226 pData[nIndex].nEnd += nAccessCount;
227 if (
pData[nIndex].nEnd >= nMaxAccess)
229 pData[nIndex].nEnd = nMaxAccess;
232 }
while (++nIndex <
nCount);
236 template<
typename A,
typename D >
239 const A nPrevLastPos = GetLastPos();
241 Insert(nStart, nAccessCount);
242 for (
A i = nStart;
i <
A(nStart + nAccessCount); ++
i)
245 const A nNewLastPos = GetLastPos();
246 Remove(nPrevLastPos, nNewLastPos - nPrevLastPos);
249 template<
typename A,
typename D >
252 A nEnd = nStart + nAccessCount - 1;
255 if (nEnd >
pData[nIndex].nEnd)
258 if ((nStart == 0 || (nIndex > 0 && nStart ==
pData[nIndex-1].nEnd+1)) &&
266 if (nIndex > 0 &&
pData[nIndex-1].aValue ==
pData[nIndex+1].aValue)
273 memmove(
pData.get() + nIndex,
pData.get() + nIndex + nRemove, (
nCount - (nIndex +
280 pData[nIndex].nEnd -= nAccessCount;
281 }
while (++nIndex <
nCount);
285 template<
typename A,
typename D >
288 const A nPrevLastPos = GetLastPos();
290 Remove(nStart, nAccessCount);
292 const A nNewLastPos = GetLastPos();
293 InsertPreservingSize(nNewLastPos, nNewLastPos - nPrevLastPos, rFillValue);
296 template<
typename A,
typename D >
304 template<
typename A,
typename D >
307 A nRegion = mnRegion + nAccessCount;
309 while (nRegion > mrArray.pData[
nIndex].nEnd)
316 template<
typename A,
typename D >
318 const D& rValueToAnd )
326 if ((this->
pData[nIndex].aValue & rValueToAnd) != this->
pData[nIndex].aValue)
328 A nS = ::std::max<A>( (nIndex>0 ? this->
pData[nIndex-1].nEnd+1 : 0), nStart);
329 A nE = ::std::min( this->
pData[nIndex].nEnd, nEnd);
330 this->
SetValue( nS, nE, this->
pData[nIndex].aValue & rValueToAnd);
333 nIndex = this->
Search( nE + 1);
335 else if (this->
pData[nIndex].nEnd >= nEnd)
339 }
while (nIndex < this->
nCount);
342 template<
typename A,
typename D >
344 const D& rValueToOr )
352 if ((this->
pData[nIndex].aValue | rValueToOr) != this->
pData[nIndex].aValue)
354 A nS = ::std::max<A>( (nIndex>0 ? this->
pData[nIndex-1].nEnd+1 : 0), nStart);
355 A nE = ::std::min( this->
pData[nIndex].nEnd, nEnd);
356 this->
SetValue( nS, nE, this->
pData[nIndex].aValue | rValueToOr);
359 nIndex = this->
Search( nE + 1);
361 else if (this->
pData[nIndex].nEnd >= nEnd)
365 }
while (nIndex < this->
nCount);
368 template<
typename A,
typename D >
371 const D& rValueToAnd )
375 for (
A j=nStart; j<=nEnd; ++j)
378 rArray.
GetValue( j, nIndex, nRegionEnd) :
380 if (nRegionEnd > nEnd)
382 this->
SetValue( j, nRegionEnd, rValue & rValueToAnd);
387 template<
typename A,
typename D >
390 A nEnd = ::std::numeric_limits<A>::max();
394 if (this->
pData[nIndex].aValue & rBitMask)
396 nEnd = this->
pData[nIndex].nEnd;
404 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< ContentProperties > pData
void AndValue(A nPos, const D &rValueToAnd)
void InsertPreservingSize(A nStart, size_t nCount, const D &rFillValue)
virtual ~ScCompressedArray()
A GetLastAnyBitAccess(const D &rBitMask) const
Return the last row where an entry meets the condition: ((aValue & rBitMask) != 0), start searching at 0.
css::uno::Any const & rValue
const BorderLinePrimitive2D *pCandidateB assert(pCandidateA)
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)
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