29#if OSL_DEBUG_LEVEL > 2
30#define CHECKIDX( p, n, i, c ) CheckIdx( p, n, i, c );
31void CheckIdx(
BlockInfo** ppInf, sal_uInt16 nBlock, sal_Int32 nSize, sal_uInt16 nCur )
33 assert( !nSize || nCur < nBlock );
36 for( sal_uInt16 nCnt = 0; nCnt < nBlock; ++nCnt, ++ppInf )
38 nIdx += (*ppInf)->nElem;
40 assert( !nCnt || (*(ppInf-1))->nEnd + 1 == (*ppInf)->nStart );
42 assert(nIdx == nSize);
45#define CHECKIDX( p, n, i, c )
87 return p->mvData[
idx -
p->nStart ];
95 if(
p->nStart <=
pos &&
p->nEnd >=
pos )
105 if(
p->nStart <=
pos &&
p->nEnd >=
pos )
109 else if( pos < p->nStart &&
m_nCur > 0 )
112 if(
p->nStart <=
pos &&
p->nEnd >=
pos )
117 sal_uInt16 lower = 0, upper =
m_nBlock - 1;
121 sal_uInt16
n = lower + ( upper - lower ) / 2;
122 cur = (
n == cur ) ?
n+1 :
n;
124 if(
p->nStart <=
pos &&
p->nEnd >=
pos )
127 if(
p->nStart >
pos )
141 sal_Int32
idx = (*pp)->nEnd + 1;
179 p->nStart =
p->nEnd = 0;
240 auto pTo = pFrom + 1;
244 ++((*pTo)->m_nOffset);
282 if(
pos !=
p->nElem )
285 auto pFrom =
p->mvData.begin() +
p->nElem;
286 auto pTo = pFrom + 1;
290 ++( *pTo )->m_nOffset;
296 p->mvData[
pos ] = pElem;
310 sal_uInt16 nBlkdel = 0;
312 sal_uInt16 nBlk1 = cur;
313 sal_uInt16 nBlk1del = USHRT_MAX;
320 sal_uInt16 nel =
p->nElem - sal_uInt16(
pos);
321 if( sal_Int32(nel) > nElem )
322 nel = sal_uInt16(nElem);
324 if( (
pos + nel ) < sal_Int32(
p->nElem) )
326 auto pTo =
p->mvData.begin() +
pos;
327 auto pFrom = pTo + nel;
328 int nCount =
p->nElem - nel - sal_uInt16(
pos);
332 (*pTo)->m_nOffset = (*pTo)->m_nOffset - nel;
337 p->nElem =
p->nElem - nel;
342 if( USHRT_MAX == nBlk1del )
355 for( sal_uInt16
i = nBlk1del;
i < ( nBlk1del + nBlkdel );
i++ )
358 if( ( nBlk1del + nBlkdel ) <
m_nBlock )
360 memmove(
m_ppInf.get() + nBlk1del,
m_ppInf.get() + nBlk1del + nBlkdel,
368 p->nEnd =
p->nElem-1;
397 p->mvData[
idx -
p->nStart ] = pElem;
411 sal_uInt16 nLast = 0;
412 sal_uInt16 nBlkdel = 0;
413 sal_uInt16 nFirstChgPos = USHRT_MAX;
418 for( sal_uInt16 cur = 0; cur <
m_nBlock; ++cur )
421 sal_uInt16
n =
p->nElem;
426 if( nLast && (
n > nLast ) && ( nLast < nMax ) )
430 if( USHRT_MAX == nFirstChgPos )
439 auto pFrom =
p->mvData.begin();
444 (*pElem)->m_pBlock = pLast;
445 (*pElem)->m_nOffset = nOff++;
451 p->nElem =
p->nElem -
n;
463 pElem =
p->mvData.begin();
469 (*pElem)->m_nOffset = (*pElem)->m_nOffset -
n;
494 p->nEnd =
p->nElem - 1;
497 if(
m_nCur >= nFirstChgPos )
#define CHECKIDX(p, n, i, c)
const sal_uInt16 nBlockGrowSize
Resize block management by this constant.
BlockInfo * InsBlock(sal_uInt16)
insert block
sal_uInt16 m_nBlock
number of blocks
std::unique_ptr< BlockInfo *[]> m_ppInf
block info
sal_uInt16 m_nMaxBlock
current max. number of blocks
void Insert(BigPtrEntry *p, sal_Int32 pos)
void Remove(sal_Int32 pos, sal_Int32 n=1)
void BlockDel(sal_uInt16)
some blocks were deleted
void Replace(sal_Int32 pos, BigPtrEntry *p)
sal_uInt16 Index2Block(sal_Int32) const
block search
sal_uInt16 Compress()
Compress the array.
sal_Int32 m_nSize
number of elements
void UpdIndex(sal_uInt16)
recalculate indices
BigPtrEntry * operator[](sal_Int32) const
sal_uInt16 m_nCur
last used block
void Move(sal_Int32 from, sal_Int32 to)
sal_uInt16 nElem
number of elements
std::array< BigPtrEntry *, MAXENTRY > mvData
data block
sal_Int32 nEnd
start- and end index