LibreOffice Module sc (master) 1
Classes | Public Member Functions | Protected Attributes | List of all members
ScCompressedArray< A, D > Class Template Reference

Compressed array of row (or column) entries, e.g. More...

#include <compressedarray.hxx>

Inheritance diagram for ScCompressedArray< A, D >:
[legend]

Classes

struct  DataEntry
 
class  Iterator
 
struct  RangeData
 

Public Member Functions

 ScCompressedArray (A nMaxAccess, const D &rValue)
 Construct with nMaxAccess=MAXROW, for example. More...
 
void Reset (const D &rValue)
 
void SetValue (A nPos, const D &rValue)
 
void SetValue (A nStart, A nEnd, const D &rValue)
 
const DGetValue (A nPos) const
 
A GetLastPos () const
 
const DGetValue (A nPos, size_t &nIndex, A &nEnd) const
 Get value for a row, and it's region end row. More...
 
RangeData GetRangeData (A nPos) const
 Get range data for a row, i.e. More...
 
const DGetNextValue (size_t &nIndex, A &nEnd) const
 Get next value and it's region end row. More...
 
const DInsert (A nStart, size_t nCount)
 Insert rows before nStart and copy value for inserted rows from nStart-1, return that value. More...
 
void InsertPreservingSize (A nStart, size_t nCount, const D &rFillValue)
 
void Remove (A nStart, size_t nCount)
 
void RemovePreservingSize (A nStart, size_t nCount, const D &rFillValue)
 
void CopyFrom (const ScCompressedArray &rArray, A nStart, A nEnd)
 Copy rArray.nStart+nSourceDy to this.nStart. More...
 
void CopyFrom (const ScCompressedArray &rArray, A nDestStart, A nDestEnd, A nSrcStart)
 
SC_DLLPUBLIC size_t Search (A nPos) const
 Obtain index into entries for nPos. More...
 
Iterator begin () const
 

Protected Attributes

size_t nCount
 
size_t nLimit
 
std::unique_ptr< DataEntry[]> pData
 
A nMaxAccess
 

Detailed Description

template<typename A, typename D>
class ScCompressedArray< A, D >

Compressed array of row (or column) entries, e.g.

heights, flags, ...

The array stores ranges of values such that equal consecutive values occupy only one entry. Initially it consists of one DataEntry with an implied start row/column of 0 and an end row/column of access type maximum value.

typename A := access type, e.g. SCROW or SCCOL, must be a POD.

typename D := data type, e.g. sal_uInt16 or sal_uInt8 or whatever, may also be a struct or class.

D::operator==() and D::operator=() must be implemented. Force template instantiation for a specific type in source/core/data/compressedarray.cxx

TODO: Currently the allocated memory never shrinks, must manually invoke Resize() if needed.

Definition at line 45 of file compressedarray.hxx.

Constructor & Destructor Documentation

◆ ScCompressedArray()

template<typename A , typename D >
ScCompressedArray< A, D >::ScCompressedArray ( A  nMaxAccess,
const D rValue 
)

Construct with nMaxAccess=MAXROW, for example.

Definition at line 24 of file compressedarray.cxx.

References nCount, ScCompressedArray< A, D >::nMaxAccess, pData, and ScCompressedArray< A, D >::pData.

Member Function Documentation

◆ begin()

template<typename A , typename D >
Iterator ScCompressedArray< A, D >::begin ( ) const
inline

Definition at line 116 of file compressedarray.hxx.

◆ CopyFrom() [1/2]

template<typename A , typename D >
void ScCompressedArray< A, D >::CopyFrom ( const ScCompressedArray< A, D > &  rArray,
A  nDestStart,
A  nDestEnd,
A  nSrcStart 
)

◆ CopyFrom() [2/2]

template<typename A , typename D >
void ScCompressedArray< A, D >::CopyFrom ( const ScCompressedArray< A, D > &  rArray,
A  nStart,
A  nEnd 
)
inline

Copy rArray.nStart+nSourceDy to this.nStart.

Definition at line 106 of file compressedarray.hxx.

References ScCompressedArray< A, D >::CopyFrom().

Referenced by ScCompressedArray< A, D >::CopyFrom().

◆ GetLastPos()

template<typename A , typename D >
A ScCompressedArray< A, D >::GetLastPos ( ) const
inline

◆ GetNextValue()

template<typename A , typename D >
const D & ScCompressedArray< A, D >::GetNextValue ( size_t &  nIndex,
A nEnd 
) const

Get next value and it's region end row.

If nIndex<nCount, nIndex is incremented first. If the resulting nIndex>=nCount, the value of the last entry is returned again.

Definition at line 170 of file compressedarray.hxx.

References D, nCount, nIndex, and pData.

Referenced by ScCompressedArray< A, D >::CopyFrom(), and ScBitMaskCompressedArray< A, D >::CopyFromAnded().

◆ GetRangeData()

template<typename A , typename D >
ScCompressedArray< A, D >::RangeData ScCompressedArray< A, D >::GetRangeData ( A  nPos) const

Get range data for a row, i.e.

value and start and end rows with that value

Definition at line 159 of file compressedarray.hxx.

References aData, nIndex, nPos, pData, and Search.

◆ GetValue() [1/2]

template<typename A , typename D >
const D & ScCompressedArray< A, D >::GetValue ( A  nPos) const

◆ GetValue() [2/2]

template<typename A , typename D >
const D & ScCompressedArray< A, D >::GetValue ( A  nPos,
size_t &  nIndex,
A nEnd 
) const

Get value for a row, and it's region end row.

Definition at line 151 of file compressedarray.hxx.

References D, nIndex, nPos, pData, and Search.

◆ Insert()

template<typename A , typename D >
const D & ScCompressedArray< A, D >::Insert ( A  nStart,
size_t  nCount 
)

Insert rows before nStart and copy value for inserted rows from nStart-1, return that value.

Definition at line 210 of file compressedarray.cxx.

References D, nCount, nIndex, pData, and Search.

◆ InsertPreservingSize()

template<typename A , typename D >
void ScCompressedArray< A, D >::InsertPreservingSize ( A  nStart,
size_t  nCount,
const D rFillValue 
)

Definition at line 232 of file compressedarray.cxx.

References A, i, Insert(), Remove, and SetValue().

◆ Remove()

template<typename A , typename D >
void ScCompressedArray< A, D >::Remove ( A  nStart,
size_t  nCount 
)

Definition at line 245 of file compressedarray.cxx.

References A, nCount, nIndex, pData, Search, and SetValue().

◆ RemovePreservingSize()

template<typename A , typename D >
void ScCompressedArray< A, D >::RemovePreservingSize ( A  nStart,
size_t  nCount,
const D rFillValue 
)

Definition at line 281 of file compressedarray.cxx.

References A, and Remove.

◆ Reset()

template<typename A , typename D >
void ScCompressedArray< A, D >::Reset ( const D rValue)

Definition at line 126 of file compressedarray.hxx.

References D, nCount, and pData.

◆ Search()

template<typename A , typename D >
size_t ScCompressedArray< A, D >::Search ( A  nPos) const

Obtain index into entries for nPos.

Definition at line 35 of file compressedarray.cxx.

References i, nCount, and pData.

Referenced by ScBitMaskCompressedArray< A, D >::AndValue(), and ScBitMaskCompressedArray< A, D >::OrValue().

◆ SetValue() [1/2]

template<typename A , typename D >
void ScCompressedArray< A, D >::SetValue ( A  nPos,
const D rValue 
)

◆ SetValue() [2/2]

template<typename A , typename D >
void ScCompressedArray< A, D >::SetValue ( A  nStart,
A  nEnd,
const D rValue 
)

Definition at line 65 of file compressedarray.cxx.

References Reset.

Member Data Documentation

◆ nCount

template<typename A , typename D >
size_t ScCompressedArray< A, D >::nCount
protected

◆ nLimit

template<typename A , typename D >
size_t ScCompressedArray< A, D >::nLimit
protected

Definition at line 120 of file compressedarray.hxx.

◆ nMaxAccess

template<typename A , typename D >
A ScCompressedArray< A, D >::nMaxAccess
protected

Definition at line 122 of file compressedarray.hxx.

Referenced by ScCompressedArray< A, D >::ScCompressedArray().

◆ pData

template<typename A , typename D >
std::unique_ptr<DataEntry[]> ScCompressedArray< A, D >::pData
protected

The documentation for this class was generated from the following files: