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]
Collaboration 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...
 
virtual ~ScCompressedArray ()
 
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 46 of file compressedarray.hxx.

Constructor & Destructor Documentation

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.

template<typename A , typename D >
ScCompressedArray< A, D >::~ScCompressedArray ( )
virtual

Definition at line 35 of file compressedarray.cxx.

Member Function Documentation

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

Definition at line 119 of file compressedarray.hxx.

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 109 of file compressedarray.hxx.

Referenced by ScCompressedArray< SCROW, sal_uInt16 >::CopyFrom().

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

Definition at line 84 of file compressedarray.hxx.

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 173 of file compressedarray.hxx.

References D, nCount, and pData.

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

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 162 of file compressedarray.hxx.

References aData, ScCompressedArray< A, D >::RangeData::maValue, ScCompressedArray< A, D >::RangeData::mnRow1, ScCompressedArray< A, D >::RangeData::mnRow2, nIndex, pData, and Search.

template<typename A, typename D >
const D & ScCompressedArray< A, D >::GetValue ( A  nPos) const
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 154 of file compressedarray.hxx.

References D, pData, and Search.

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 215 of file compressedarray.cxx.

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

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

Definition at line 237 of file compressedarray.cxx.

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

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

Definition at line 250 of file compressedarray.cxx.

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

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

Definition at line 286 of file compressedarray.cxx.

References A, and Remove.

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

Definition at line 129 of file compressedarray.hxx.

References D, nCount, and pData.

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

Obtain index into entries for nPos.

Definition at line 40 of file compressedarray.cxx.

References i, nCount, and pData.

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

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

Definition at line 70 of file compressedarray.cxx.

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

Member Data Documentation

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

Definition at line 123 of file compressedarray.hxx.

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

Definition at line 125 of file compressedarray.hxx.

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

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: