summaryrefslogtreecommitdiff
path: root/scaddins
diff options
context:
space:
mode:
authorNoel Grandin <noel@peralex.com>2014-01-10 11:07:59 +0200
committerNoel Grandin <noel@peralex.com>2014-01-20 13:14:41 +0200
commit1f3eed97de1c3dcbf532cd63023239a4543ae1dc (patch)
treed80a2d1296e091ba44613a56ad9536a507908a60 /scaddins
parent20c4de49ac040e4c232d59f1ce0c86660b0ebc09 (diff)
convert custom list implementation ScaDoubleList to std::vector
Change-Id: I98865a54f675ebdb7724327305f9f9a5eeccfeb4
Diffstat (limited to 'scaddins')
-rw-r--r--scaddins/source/analysis/analysis.cxx26
-rw-r--r--scaddins/source/analysis/analysishelper.cxx7
-rw-r--r--scaddins/source/analysis/analysishelper.hxx19
-rw-r--r--scaddins/source/analysis/financial.cxx12
4 files changed, 24 insertions, 40 deletions
diff --git a/scaddins/source/analysis/analysis.cxx b/scaddins/source/analysis/analysis.cxx
index f2fa49feacb5..8e9590b04750 100644
--- a/scaddins/source/analysis/analysis.cxx
+++ b/scaddins/source/analysis/analysis.cxx
@@ -683,9 +683,10 @@ AnalysisAddIn::getMultinomial( const uno::Reference< beans::XPropertySet >& xOpt
double nZ = 0;
double fRet = 1.0;
- for( const double *p = aValList.First(); p; p = aValList.Next() )
+ for( sal_uInt32 i = 0; i < aValList.Count(); ++i )
{
- double n = (*p >= 0.0) ? rtl::math::approxFloor( *p ) : rtl::math::approxCeil( *p );
+ const double d = aValList.Get(i);
+ double n = (d >= 0.0) ? rtl::math::approxFloor( d ) : rtl::math::approxCeil( d );
if ( n < 0.0 )
throw lang::IllegalArgumentException();
@@ -787,15 +788,10 @@ double SAL_CALL AnalysisAddIn::getGcd( const uno::Reference< beans::XPropertySet
if( aValList.Count() == 0 )
return 0.0;
- const double* p = aValList.First();
- double f = *p;
-
- p = aValList.Next();
-
- while( p )
+ double f = aValList.Get(0);
+ for( sal_uInt32 i = 1; i < aValList.Count(); ++i )
{
- f = GetGcd( *p, f );
- p = aValList.Next();
+ f = GetGcd( aValList.Get(i), f );
}
RETURN_FINITE( f );
@@ -812,22 +808,18 @@ double SAL_CALL AnalysisAddIn::getLcm( const uno::Reference< beans::XPropertySet
if( aValList.Count() == 0 )
return 0.0;
- const double* p = aValList.First();
- double f = *p;
+ double f = aValList.Get(0);
if( f == 0.0 )
return f;
- p = aValList.Next();
-
- while( p )
+ for( sal_uInt32 i = 1; i < aValList.Count(); ++i )
{
- double fTmp = *p;
+ double fTmp = aValList.Get(i);
if( f == 0.0 )
return f;
else
f = fTmp * f / GetGcd( fTmp, f );
- p = aValList.Next();
}
RETURN_FINITE( f );
diff --git a/scaddins/source/analysis/analysishelper.cxx b/scaddins/source/analysis/analysishelper.cxx
index e7b24a138cd4..a122abcbc8a1 100644
--- a/scaddins/source/analysis/analysishelper.cxx
+++ b/scaddins/source/analysis/analysishelper.cxx
@@ -1660,13 +1660,6 @@ void SortedIndividualInt32List::InsertHolidayList(
//-----------------------------------------------------------------------------
-ScaDoubleList::~ScaDoubleList()
-{
- for( double* pDbl = const_cast< double* >( First() ); pDbl; pDbl = const_cast< double* >( Next() ) )
- delete pDbl;
-}
-
-
void ScaDoubleList::Append(
const uno::Sequence< uno::Sequence< double > >& rValueSeq ) throw( uno::RuntimeException, lang::IllegalArgumentException )
{
diff --git a/scaddins/source/analysis/analysishelper.hxx b/scaddins/source/analysis/analysishelper.hxx
index d250f736c3a9..f2c74a3ba385 100644
--- a/scaddins/source/analysis/analysishelper.hxx
+++ b/scaddins/source/analysis/analysishelper.hxx
@@ -331,12 +331,13 @@ public:
//-----------------------------------------------------------------------------
-class ScaDoubleList : protected MyList
+class ScaDoubleList
{
+private:
+ std::vector<double> maVector;
protected:
- inline void ListAppend( double fValue ) { MyList::Append( new double( fValue ) ); }
+ inline void ListAppend( double fValue ) { maVector.push_back(fValue); }
- using MyList::Append;
inline void Append( double fValue ) throw( css::uno::RuntimeException, css::lang::IllegalArgumentException )
{ if( CheckInsert( fValue ) ) ListAppend( fValue ); }
@@ -362,14 +363,12 @@ protected:
sal_Bool bIgnoreEmpty ) throw( css::uno::RuntimeException, css::lang::IllegalArgumentException );
public:
- virtual ~ScaDoubleList();
-
- using MyList::Count;
- inline const double* Get( sal_uInt32 nIndex ) const
- { return static_cast< const double* >( MyList::GetObject( nIndex ) ); }
+ virtual ~ScaDoubleList() {}
- inline const double* First() { return static_cast< const double* >( MyList::First() ); }
- inline const double* Next() { return static_cast< const double* >( MyList::Next() ); }
+ inline sal_uInt32 Count() const
+ { return maVector.size(); }
+ inline double Get( sal_uInt32 n ) const
+ { return maVector[n]; }
void Append( const css::uno::Sequence< css::uno::Sequence< double > >& rValueArr )
throw( css::uno::RuntimeException, css::lang::IllegalArgumentException );
diff --git a/scaddins/source/analysis/financial.cxx b/scaddins/source/analysis/financial.cxx
index bfaec15eb757..0378222b24b1 100644
--- a/scaddins/source/analysis/financial.cxx
+++ b/scaddins/source/analysis/financial.cxx
@@ -461,8 +461,8 @@ double SAL_CALL AnalysisAddIn::getOddlyield( const css::uno::Reference< css::bea
// ============================================================================
// XIRR helper functions
-#define V_(i) (*rValues.Get(i))
-#define D_(i) (*rDates.Get(i))
+#define V_(i) (rValues.Get(i))
+#define D_(i) (rDates.Get(i))
/** Calculates the resulting amount for the passed interest rate and the given XIRR parameters. */
static double lcl_sca_XirrResult( const ScaDoubleList& rValues, const ScaDoubleList& rDates, double fRate )
@@ -579,11 +579,11 @@ double SAL_CALL AnalysisAddIn::getXnpv(
throw css::lang::IllegalArgumentException();
double fRet = 0.0;
- double fNull = *aDateList.Get( 0 );
+ double fNull = aDateList.Get( 0 );
fRate++;
for( sal_Int32 i = 0 ; i < nNum ; i++ )
- fRet += *aValList.Get( i ) / ( pow( fRate, ( *aDateList.Get( i ) - fNull ) / 365.0 ) );
+ fRet += aValList.Get( i ) / ( pow( fRate, ( aDateList.Get( i ) - fNull ) / 365.0 ) );
RETURN_FINITE( fRet );
}
@@ -654,8 +654,8 @@ double SAL_CALL AnalysisAddIn::getFvschedule( double fPrinc, const css::uno::Seq
aSchedList.Append( rSchedule );
- for( const double* p = aSchedList.First() ; p ; p = aSchedList.Next() )
- fPrinc *= 1.0 + *p;
+ for( sal_uInt32 i = 0; i < aSchedList.Count(); ++i )
+ fPrinc *= 1.0 + aSchedList.Get(i);
RETURN_FINITE( fPrinc );
}